Modification of the robot that trades the PinBar pattern (a candle with a huge shadow upwards or downwards) for simultaneous trading across the entire platform.
The robot is interesting not only for its equity (which has a lot to show), but also for its approach of trading dozens of assets at the same time. Let's discuss the robot's logic and where its source code is located in the project.
1. Example in the project.
To start, you should open the robot's source code. It is located here within the project:
2. Robot parameters.
1. Regime – mode of operation.
a. Off – Disabled.
b. On – Enabled and will enter both longs and shorts.
c. OnlyLong – Enabled and will enter only long positions.
d. OnlyShort – Enabled and will enter only short positions.
e. OnlyClosePosition – Can only close a position, will not enter a new one.
2. Max positions – maximum simultaneous number of positions.
3. Volume type – mode for selecting volume.
a. Contracts – number of contracts for the instrument.
b. Contract currency – currency of the contract.
c. Deposit percent – percentage of the deposit.
4. Volume – volume value. What exactly depends on the previous point. In the case of Contracts, the volume of the instrument is specified. In the case of Contract currency, here the number of rubles or dollars needed to enter is specified. In the case of Deposit percent, here the % of the total deposit needed to enter the contract is indicated.
5. Asset in portfolio – here you need to specify the name of the currency that will be used to calculate the volume if you chose the volume type “Deposit percent”. In the tester, leave “Prime”. In crypto, this is usually “USDT”. In ALOR, it is “RUB”.
6. Slippage % - slippage for order prices.
7. Max height candles percent – maximum size of the signal candle from low to high in %.
8. Min height candles percent – minimum size of the signal candle from low to high in %.
9. Trail Stop % - the size of the trailing stop order for exiting the position.
10. Sma Period – the length of the moving average.
3. Entry and exit logic.
Entry into positions occurs after detecting such candles:
At the same time, this robot additionally looks at the "moving average" indicator and enters according to the trend, i.e., goes long only when the market price is above the moving average. It goes short only when the market price is below the moving average.
Exit from the position is carried out using a trailing stop order.
This modification includes size limits for the candle in %. That is, entries are filtered by the size of the PinBar, and the candle must fall within a range of values.
4. What about the profit?
On the MOEX SPOT TOP 20, the profit per contract is 0.22%, which is not much with the settings described above. However, the number of trades in tests since 2019 is over 4,000, which provides excellent opportunities for filtering bad entries and further modernizing the algorithm.
In addition, this robot can and should be used as an example of how to correctly search for interesting candlestick patterns on the chart in the broad market to achieve robust results right away, as it is essentially one of the methods for quick and quality cross-testing – simultaneous trading on dozens of instruments.
Wishing you successful algorithms!