Free Robot: Pin Bar Pattern in Trend in OsEngine

Free Robot: Pin Bar Pattern in Trend in OsEngine

The pin bar is a candle with a huge shadow either upwards or downwards. It is one of the most popular candlestick patterns.

Let's consider a robot that trades it. We will analyze its logic and source code.

 

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. The specifics depend 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 specified. In the case of Deposit Percent, a percentage of the total deposit that needs to be entered into the contract is indicated.

4. Asset in Portfolio – 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. Trail Stop % – the size of the trailing stop order used to exit the position.

7. SMA Period – the length of the moving average.

 

3. Logic for Entering and Exiting Positions.

Entry into positions is made after detecting such candles:

Additionally, this robot looks at the "Moving Average" indicator and enters according to the trend. That is, it goes long only when the market price is above the moving average. It enters short only when the market price is below the moving average.

Exiting from a position is done using a trailing stop order.

 

4. What About Profit?

Almost any settings are profitable.

You could see the settings of this pass in the second part of this article.

Good luck with your algorithms!

OsEngine Support