Hi
I’ve been having my positive stop shift back to normal SL when it pulls back a bit, esentially when it doesnt meet criteria to shift to positive stop I think…it confused me a bit so I put in code so that is shouldn’t do it, but it continues to do it.
I included code into the SL and TP so tat it wouldn’t be calculated after its been set, but it still continues to shift back to its original stoploss..
I have created a ticket, but am I missing something obvious?
Below is related code, I’ve added code to rule out it shifting only, but it appears to continue… there is no other code relating to the stoploss or new positive stop
IF not onmarket and stoptrade and longcond and mybullish and clong and tradeok and tradestoplong and tradestopatr and bullishmacd4 and myatrnow and ranging THEN // // and mybullishconf removed but retained macd
BUY myamountlong PERPOINT AT MARKET
endif
//===============================================
//To keep positive stop
//===============================================
If not onmarket then
keepstop=0
endif
If longonmarket and keepstop=0 then //and keepstop=0
set stop loss longrisk
set target pprofit longrisk*1.1
keepstop=1 // keep positive stop once set
endif
//===============================================
//End To keep positive stop
//===============================================
IF TDclose THEN
SELL AT MARKET
ENDIF
IF not onmarket and stoptrade and shortcond and mybearish and cshort and tradeok and tradestopshort and tradestopatr and bearishmacd4 and myatrnow and ranging THEN // and mybearishconf removed but retained macd
SELLSHORT myamountshort PERPOINT AT MARKET
endif
//===============================================
//To keep positive stop
//===============================================
If not onmarket then
keepstop=0
endif
If shortonmarket and keepstop=0 then//and keepstop=0
set stop loss shortrisk
set target pprofit shortrisk*1.1
keepstop=1 //// keep positive stop once set
endif
//===============================================
//End To keep positive stop
//===============================================
IF TDclose THEN //myexitshort or
EXITSHORT AT MARKET
ENDIF
endif
//set stop to positive
If not onmarket then
setstop=1
endif
//0=off 1=on
If not OnMarket then
NewSL = 0
Endif
If NewSL = 0 and PositionPerf > 0 and setstop Then
Pips = tradeprice * PositionPerf
If setstop=1 and longonmarket and Pips >= (longrisk/1.8) and ((longrisk/1.8)- (longrisk/3.1))>=5.5 Then//drawdown0
myfactor3=longrisk/3.1
NewSL = tradeprice + myfactor3
setstop=0
endif
If setstop=1 and shortonmarket and Pips >= (shortrisk/1.8) and ((shortrisk/1.8)- (shortrisk/3.1))>=5.5 Then//drawdown0
myfactor3=shortrisk/3.1
NewSL = tradeprice - myfactor3
setstop=0
endif
If NewSL > 0 Then
SELL at NewSL STOP
EXITshort at NewSL STOP
Endif
Endif
Try moving the last ENDIF to just before line 53.
Roberto,
?
I think you wanted to suggest something else ?
You are right PeterSt, I had to write try moving the last ENDIF to just before line 65.