Hi there! Perhaps someone can help me.
I try to set a StopLoss when price break the SAR Indicator (with the value of one bar after entering the trade).
I know I can define the number of bars to look back, but how can I set it to the value from entering the trade?
I hope it is clear what I mean.
JSParticipant
Senior
Hi @debux
If I understand correctly, you want to place the “StopLoss” after entering a position…
For example, you can use:
If OnMarket and NOT OnMarket[1] then
Set Stop Loss …
EndIf
Thank You! I will try it…
Hi @JS
unfortunatly it doesn‘t work. I will try to explain the problem in more detail:
Lets say I enter a long position when overcrossing the parabolic SAR indicator.
At this moment, the value of the Indicator switches the sides, now the value of the Indicator is lower.
I would like to set the StopLoss to this new value.
If i just say, set StopLoss when undercrossing SAR it is not correct, because the SAR is changing its value after each candle and is moving closer to the price of the underlying.
Regards, debux
JSParticipant
Senior
Hi @debux
You can try this…
mySAR = SAR[0.02,0.02,0.2]
IF LOW < mySAR and Close < Open THEN
SellShort 1 contract at Market
Set Stop Loss mySAR
ENDIF
IF HIGH > mySAR and Close >= Open THEN
Buy 1 contract at Market
Set Stop Loss mySAR
ENDIF
JSParticipant
Senior
Sorry, “Stop Loss” must be of course “Stop Price” …
DefParam CumulateOrders = False
mySAR = SAR[0.02,0.02,0.2]
IF LOW < mySAR and Close < Open THEN
SellShort 1 contract at Market
Set Stop Price mySAR
ENDIF
IF HIGH > mySAR and Close >= Open THEN
Buy 1 contract at Market
Set Stop Price mySAR
ENDIF
Hi @JS
Thank you very much for your help. It works now…
Cheers, debux