I wish to test a risk/reward ratio of 1/3 on my trading strategies based on the SL level.
For example, for a buy, if my SL is “close < BollingerDown" and the distance between the current price and the current BollingerDown is 25pips, the TP will need to be at 75pips.
Is it possible to calculate this level of TP only when entering the position to keep a fixed TP (which I wish) or will the algo recalculate the distance at each new candle which will change the TP at each calculation (which I do not wish).
Here is the code for this example, how to improve it?
At line 4 you are NOT calculating a Stop Loss, yiou are just assigning a logical value (1 or 0) to C1 whenever CLOSE is below the lower band.
At line 16 you
Change it to:
1
C11=BollingerDown[20](close)
so C1 will retain the price of the lower BB.
Then you’ll have to move lines 3 through 9 within the IF…ENDIF where you have written the BUY instruction, to prevent C11 and C12 from changing each new candle.
Hello @robertogozzi,
Sorry but I didn’t understand how to do it.
For me, the calculation logic is to get the distance between the entrance fee and the SL, then multiply this distance by 3 to get the TP.
Apparently I’m wrong unless it’s my way of coding that’s wrong.
Can you help me with an example or the correct code please ? 🙂
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.