Forums › ProRealTime English forum › ProOrder support › Strategy SR Dow J Day › Reply To: Strategy SR Dow J Day
the set target profit needs to be straight below the buy order because it uses average range & close.
It can not be put on the bottom. It’s placed correct and uses the close when conditions are true to go long.
however, you do not use not longonmarket, so, if your are long and conditions are true to go long again are ignored (because DEFPARAM CumulateOrders = false) , it updates the target with the new close of that bar which is incorrect. To have it correct I think you have to use not longonmarket?
If you add not longonmarket performance goes down, however, if you take every signal when in a long and losing position to close & reenter again long, it’s much better.
here again a but, because not sure why the code below makes such a difference.
1 2 3 4 |
if condbuy[1] then buy positionsize contract at market SET TARGET PROFIT 5* averagetruerange[1](close) endif |
or
1 2 3 4 |
if condbuy[1] then buy positionsize contract at market SET TARGET PROFIT 5* averagetruerange[1](close)[1] endif |
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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
// Strategy SR Dow J. Day indicator by roberto gozzi DEFPARAM CumulateOrders = false once tradetype = 2 // [1]long & short; [2]long only; [3]short only once reenter = 0 // [0]off; [1]reenter based on positionperftype once positionperftype = 0 // [0]perf<>ppv; [1]perf<ppv; [2]perf>ppv once positionperfvalue = 0 indicator1 = ADX[10] indicator2 = ADXR[14] c2 = (indicator1[1] > indicator2[1]) indicator11 = ADX[10] c1 = (indicator11[1] >= 15) c30 =TR(close)>25 ONCE PrezzoC = 0 ONCE PrezzoB = 0 ONCE PrezzoA = 0 Prezzo = CALL SRtest IF Prezzo > 0 THEN PrezzoA = PrezzoB PrezzoB = PrezzoC PrezzoC = Prezzo ENDIF positionsize=1 LossMonth =200 once StopMonth=1 IF Month <> Month[1] THEN ProfitMonth=strategyprofit StopMonth=1 endif If strategyprofit<=ProfitMonth-LossMonth then StopMonth=0 endif Cond = PrezzoB > PrezzoA AND PrezzoB > PrezzoC condbuy=StopMonth=1 and close CROSSES UNDER PrezzoB AND C2 AND C1 AND C30 AND Cond > 0 // CONDBUY=CONDBUY AND NOT LONGONMARKET condsell=1 ctime=1 // entry criteria if ctime then if (tradetype=1 or tradetype=2) then if condbuy then buy positionsize contract at market SET TARGET pPROFIT 5* averagetruerange[1](close) endif endif if (tradetype=1 or tradetype=3) then if condsell and not shortonmarket then sellshort positionsize contract at market endif endif if reenter then if positionperftype=1 then positionperformance=positionperf(0)*100<-positionperfvalue // in loss elsif positionperftype=2 then positionperformance=positionperf(0)*100>positionperfvalue // in profit else positionperformance=((positionperf(0)*100)<-positionperfvalue or (positionperf(0)*100)>positionperfvalue) // in loss or profit endif if (tradetype=1 or tradetype=2) then if condbuy and longonmarket and positionperformance then sell at market endif if condbuy[1] then buy positionsize contract at market SET TARGET PROFIT 5* averagetruerange[1](close) // or [1] at the end? endif endif if (tradetype=1 or tradetype=3) then if condsell and shortonmarket and positionperformance then exitshort at market endif if condsell[1] and not shortonmarket then sellshort positionsize contract at market endif endif endif else if longonmarket and condsell then //sell at market endif if shortonmarket and condbuy then //exitshort at market endif endif If longonmarket and (barindex-tradeindex)>=43 then //SELL AT MARKET ENDIF Trailinglong = 2* averagetruerange[5](close) Trailingsteplong = 5* averagetruerange[1](close) TGL = Trailinglong STPL = Trailingsteplong if not onmarket then MAXPRICE = 0 PREZZOUSCITA = 0 ENDIF if longonmarket then MAXPRICE = MAX(MAXPRICE,close) if MAXPRICE-tradeprice(1)>=TGL then PREZZOUSCITA = MAXPRICE-STPL ENDIF ENDIF if onmarket and PREZZOUSCITA>0 then EXITSHORT AT PREZZOUSCITA STOP SELL AT PREZZOUSCITA STOP ENDIF SET STOP %LOSS 8 |