A basic and simple example of a robot that allows trading candle patterns.
It is called ThreeSoldier. This is a classic candlestick pattern mentioned in almost any trading book about these patterns. And it's still working, by the way. This is exactly what neural networks see when they are fed candles as input.
1. Example in the Project.
First, you should open the source code of the robot. Inside the project, it is located here:
2. Robot Parameters.
1. Regime – working mode.
a. Off – Disabled.
b. On – Enabled and will enter both long and short.
c. OnlyLong – Enabled and will only enter long.
d. OnlyShort – Enabled and will only enter short.
e. OnlyClosePosition – will only close the position and will not enter.
2. Volume Type – method for choosing volume.
a. Contracts – the number of contracts for the instrument.
b. Contract Currency – currency of the contract.
c. Deposit Percent – percentage of the deposit.
3. Volume – the volume value. Specifically, this depends on the previous point. In the case of Contracts, the volume of the instrument is indicated. In the case of Contract Currency, the amount in rubles or dollars needed to enter is indicated. In case of Deposit Percent, a percentage of the total deposit that needs to be entered into the contract is indicated.
4. Asset in Portfolio – here you need to specify the name of the currency that will be used for volume calculation if you selected the “Deposit Percent” volume type. In the tester, we leave it as "Prime." In crypto, it's usually "USDT." In ALOR, it's "RUB."
5. Slippage % – slippage for order prices.
6. Height Soldiers % – the total height of the three candles after which we consider the pattern formed.
7. Min Height One Soldier % – the minimum height of the body of each individual candle, after which we consider the pattern formed.
8. Profit % from Height of Pattern – % of the total height of the pattern that will be taken as the profit value.
9. Stop % from Height of Pattern – % of the total height of the pattern that will be taken as the stop loss value.
3. Logic for Entering and Exiting Positions.
LONG
Entry occurs if over three candles we have accumulated a total movement upwards equal to "Height Soldiers %" . At the same time, each individual candle must be at least "Min Height One Soldier %."
Exit is tied to the total size of the movement over 3 candles. Profit equals the setting "Profit % from Height of Pattern," whereby the total movement over 3 candles is taken, and a specified percentage of that movement is set aside as profit. The stop loss equals the setting "Stop % from Height of Pattern."
SHORT
Entry occurs if over three candles we have accumulated a total movement downwards equal to "Height Soldiers %." At the same time, each individual candle must be at least "Min Height One Soldier %."
Exit is tied to the total size of the movement over 3 candles. Profit equals the setting "Profit % from Height of Pattern," whereby the total movement over 3 candles is taken, and a specified percentage of that movement is set aside as profit. The stop loss equals the setting "Stop % from Height of Pattern."
4. What About Profit?
The optimizer shows some fantastical results. For example, there are settings with such equity.
You could see the settings of this pass in the second part of this article.
Good luck with your algorithms!