Forums › ProRealTime English forum › ProOrder support › Strategy DayOpen Straddle for DAX › Reply To: Strategy DayOpen Straddle for DAX
11/05/2018 at 9:11 PM
#84210
the code to combine Williams 3 bar trailing stop with MFE trailing stop
MFETrailing=1
WTrailing=1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
// MFETrailing if MFETrailing then trailingstop = (tradeprice/100)*ts if not onmarket then MAXPRICE = 0 MINPRICE = close priceexit = 0 endif if longonmarket then MAXPRICE = MAX(MAXPRICE,close) if MAXPRICE-tradeprice(1)>=trailingstop*pipsize then priceexit = MAXPRICE-trailingstop*pipsize endif endif if shortonmarket then MINPRICE = MIN(MINPRICE,close) if tradeprice(1)-MINPRICE>=trailingstop*pipsize then priceexit = MINPRICE+trailingstop*pipsize endif endif If onmarket and WTrailing=0 and priceexit>0 then sell at market exitshort at market endif endif // exit larry williams If WTrailing and MFETrailing then count=1 i=0 j=i+1 tot=0 while count<4 do tot=tot+1 if (low[j]>=low[i]) and (high[j]<=high[i]) then //inside bar j=j+1 else count=count+1 i=i+1 J=i+1 endif wend basso=lowest[tot](low) alto=highest[tot](high) if close>alto[1] then ref=basso endif if close<basso[1] then ref=alto endif if onmarket and priceexit>0 then if high<ref then sell at market endif If low>ref then exitshort at market endif endif endif |