Hello,
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?
// Closing trades
// Stop Loss
C11 = close < BollingerDown [20](close)
// Target Profit
BBL = BollingerDown [20](close)
Distance = (low - BBL )*3
C12 = close + Distance
MyConditionsCloture = C11 OR C12
if MyConditionsCloture AND OnMarket then
SELL 1 lot AT market
endif
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:
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.
Then you need to replace line 13 with:
MyConditionsCloture = (close <= C11) OR (close >= C12)
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 ? 🙂
My fault, sorry.
You have to replace line 4 by:
C11 = BollingerDown [20](close)
and line 13 by:
MyConditionsCloture = (close <= C11) OR (close >= C12)
Use the @ sign only when you have to address someone among many users.
In this case it’s just the two of us.
Thank you 🙂