PereParticipant
Veteran
I put normally a stop loss on my ProOrders. How can I change it’s value to zero after 2 or 3 candles (if I’m doing profit>x)?
I tried following:
sl=100
IF LONGONMARKET AND (BARINDEX-TRADEINDEX)>1 AND close>TRADEPRICE THEN
sl=0
ENDIF
SET STOP pLOSS sl
but it goes again to 100 if close<TRADEPRICE on the next candles.
After switching from 100 to 0 I want to remain it there.
Pere – Please use the ‘Insert PRT Code’ button when posting code. i tidied it up for you. 🙂
The problem is that if a trade moves back into a loss then the conditions are not met so the stop loss returns.
What you have coded is not a break even code but one that removes the stoploss completely. Use the search box to search for ‘BreakEven’ and there are plenty of topics with example code available.
This should fix your code but perhaps it is not what you actually want:
if not onmarket and (your entry conditions) then
buy 1 contract at market
sl=100
endif
IF LONGONMARKET AND (BARINDEX-TRADEINDEX)>1 AND close>TRADEPRICE THEN
sl=0
ENDIF
SET STOP pLOSS sl
PereParticipant
Veteran
Thank you Vonasi. I was just preparing the question, but just in this moment I had a power outage of one hour, and I don’t know how the question was posted, but it was.
PereParticipant
Veteran