//a = 1
//b = 0.1
//c = 0.1
MinStop = 10 //10 pips minimum stop loss required
Points2Keep = 0.01 //0.01% points to keep
set stop ploss max(MinStop,TradePrice(1) * a / 100 / pipsize)
trailingPercent = b
stepPercent = c
p2k = TradePrice(1) * Points2Keep / 100
if onmarket then
trailingstart = tradeprice(1)*(trailingpercent/100) // - 6*pipsize
trailingstep = tradeprice(1)*(stepPercent/100) // - 6*pipsize
endif
IF NOT ONMARKET THEN
newSL=0
ENDIF
IF LONGONMARKET THEN
IF newSL=0 AND close-tradeprice(1)>=trailingstart THEN
newSL = tradeprice(1)+trailingstep+p2k
ENDIF
IF newSL>0 AND close-newSL>trailingstep THEN
newSL = newSL+trailingstep
ENDIF
ENDIF
IF SHORTONMARKET THEN
IF newSL=0 AND tradeprice(1)-close>=trailingstart THEN
newSL = tradeprice(1)-trailingstep+p2k
ENDIF
IF newSL>0 AND newSL-close>trailingstep THEN
newSL = newSL-trailingstep
ENDIF
ENDIF
IF newSL>0 THEN
SELL AT newSL STOP
EXITSHORT AT newSL STOP
ENDIF