Forums › ProRealTime English forum › ProOrder support › MultiTimeFrame simple conditions › Reply To: MultiTimeFrame simple conditions
01/28/2019 at 10:01 PM
#89867
Hi all,
Here I upload my version…
I like this concept, I called it: MULTI-SIMPLICITY TYPE A
// MULTI-SIMPLICITY TYPE A
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 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
// MULTI-SIMPLICITY TYPE A DEFPARAM CumulateOrders = false // Cumulating positions DEFPARAM PreLoadBars = 1000 //cargar informacion //Parameters to be optimized //Pentry1=6 //Kprofit=1.5 ontime=1 IF hour <= 2 or hour >= 22 then ontime=0 ELSIF DayOfWeek <= 1 and hour <= 4 then ontime=0 ELSIF DayOfWeek >= 5 and hour >= 20 then ontime=0 ENDIF MetaRange=max(pipsize,pipsize*round(average[34](average[21](average[13](average[8](average[5](round(range/pipsize)))))))) /////////// LEO CHANNEL ////////////////// PXentry1=max (2, round(0.6*Pentry1) ) highest1=highest[Pentry1](high) IF highest1 = highest1[PXentry1] then Re1=highest1 ENDIF IF high > Re1 then Re1=high ENDIF lowest1=lowest[Pentry1](low) IF lowest1 = lowest1[PXentry1] then S1=lowest1 ENDIF If low < S1 then S1=low ENDIF ConditionLong00001= close>average[20](close) and average[20](Close[1])>average[20](Close) and lowest[5](low) > average[200](Close) and average[200](Close[1])<average[200](Close) ConditionShort00001= close<average[20](close) and average[20](Close[1])<average[20](Close) and highest[5](high) < average[200](Close) and average[200](Close[1])>average[200](Close) timeframe(15 minutes,updateonclose) ConditionLong00002= close>average[20](close) and average[20](Close[1])>average[20](Close) and lowest[5](low) > average[200](Close) and average[200](Close[1])<average[200](Close) ConditionShort00002= close<average[20](close) and average[20](Close[1])<average[20](Close) and highest[5](high) < average[200](Close) and average[200](Close[1])>average[200](Close) timeframe(30 minutes,updateonclose) ConditionLong00003= close>average[20](close) and average[20](Close[1])>average[20](Close) and lowest[5](low) > average[200](Close) and average[200](Close[1])<average[200](Close) ConditionShort00003= close<average[20](close) and average[20](Close[1])<average[20](Close) and highest[5](high) < average[200](Close) and average[200](Close[1])>average[200](Close) timeframe(60 minutes,updateonclose) ConditionLong00004= close>average[20](close) and average[20](Close[1])>average[20](Close) and lowest[5](low) > average[200](Close) and average[200](Close[1])<average[200](Close) ConditionShort00004= close<average[20](close) and average[20](Close[1])<average[20](Close) and highest[5](high) < average[200](Close) and average[200](Close[1])>average[200](Close) timeframe(120 minutes,updateonclose) ConditionLong00005= close>average[20](close) and average[20](Close[1])>average[20](Close) and lowest[5](low) > average[200](Close) and average[200](Close[1])<average[200](Close) ConditionShort00005= close<average[20](close) and average[20](Close[1])<average[20](Close) and highest[5](high) < average[200](Close) and average[200](Close[1])>average[200](Close) timeframe(240 minutes,updateonclose) ConditionLong00006= close>average[20](close) and average[20](Close[1])>average[20](Close) and lowest[5](low) > average[200](Close) and average[200](Close[1])<average[200](Close) ConditionShort00006= close<average[20](close) and average[20](Close[1])<average[20](Close) and highest[5](high) < average[200](Close) and average[200](Close[1])>average[200](Close) timeframe(default) ConditionLong = ConditionLong00001 + ConditionLong00002 + ConditionLong00003 + ConditionLong00004 + ConditionLong00005 + ConditionLong00006 ConditionShort = ConditionShort00001 +ConditionShort00002+ ConditionShort00003+ConditionShort00004+ConditionShort00005+ConditionShort00006 //---------------------------------------------------------- // >>>>>>>>>>>>>> ENTRY POSITIONS <<<<<<<<<<<<<<<<<< //---------------------------------------------------------- // ---> LONG POSITIONS IF NOT LongOnMarket and ontime=1 THEN IF ConditionLong > 2 THEN stoplosslong= (close-S1)/pipsize+2*MetaRange/pipsize//in pips targetprofitlong=stoplosslong*Kprofit //in pips BUY 1 CONTRACTS AT MARKET SET STOP pLOSS stoplosslong SET TARGET pPROFIT targetprofitlong ENDIF ENDIF // ---> SHORT POSITIONS IF NOT ShortOnMarket and ontime=1 THEN IF ConditionShort > 2 THEN StopLossShort=(Re1-close)/pipsize+2*MetaRange/pipsize // in pips targetprofitshort=StopLossShort*Kprofit // in pips SELLSHORT 1 CONTRACTS AT MARKET SET STOP pLOSS StopLossShort SET TARGET pPROFIT targetprofitshort ENDIF ENDIF //--------------------------------------------------------- //>>>>>>>>>>>>>>>>>> EXIT POSITIONS <<<<<<<<<<<<<<<<<< //--------------------------------------------------------- If LongOnMarket THEN //////////////// UNTIL PARTIAL CLOSURE OF POSITION IS ACTIVE //////////////// //If close > TRADEPRICE+targetprofitlong*pipsize THEN //SELL AT MARKET //ENDIF //IF close < TRADEPRICE-stoplosslong*pipsize THEN //SELL AT MARKET //ENDIF IF highest[BARINDEX-TRADEINDEX+1](high) > TRADEPRICE+0.75*stoplosslong*pipsize and (BARINDEX-TRADEINDEX)>=2 THEN Kexit=((TRADEPRICE+targetprofitlong*pipsize)-highest[BARINDEX-TRADEINDEX+1](high)) / ( (TRADEPRICE+targetprofitlong*pipsize) - (TRADEPRICE+0.75*stoplosslong*pipsize)) IF low < highest[BARINDEX-TRADEINDEX+1](high)-Kexit*0.75*stoplosslong*pipsize and close < typicalprice then SELL AT MARKET ELSIF close < highest[BARINDEX-TRADEINDEX+1](high)-Kexit*0.75*stoplosslong*pipsize THEN SELL AT MARKET ENDIF ENDIF //////////////////////////// IF CLOSE < S1[1] THEN SELL AT MARKET ENDIF IF high > TRADEPRICE + 0.75*stoplosslong*pipsize THEN SET STOP pLOSS 0.01 ENDIF IF TIME > 214500 and DayOfWeek=5 then SELL AT MARKET ENDIF ENDIF // Bedingungen zum Ausstieg aus Short-Positionen IF ShortOnMarket THEN //////////////// UNTIL PARTIAL CLOSURE OF POSITION IS ACTIVE //////////////// //IF close < TRADEPRICE-targetprofitshort*pipsize THEN //EXITSHORT AT MARKET //ENDIF //IF close > TRADEPRICE+stoplossshort*pipsize THEN //EXITSHORT AT MARKET //ENDIF IF lowest[BARINDEX-TRADEINDEX+1](low) < TRADEPRICE-0.75*stoplossshort*pipsize and (BARINDEX-TRADEINDEX)>=2THEN Kexit=(lowest[BARINDEX-TRADEINDEX+1](low)-(TRADEPRICE-TargetProfitShort*pipsize) ) / ( (TRADEPRICE-0.75*stoplossshort*pipsize)-(TRADEPRICE-TargetProfitShort*pipsize)) IF high > lowest[BARINDEX-TRADEINDEX+1](low) + Kexit*0.75*stoplossshort*pipsize and close > typicalprice THEN EXITSHORT AT MARKET ELSIF close > lowest[BARINDEX-TRADEINDEX+1](low) + Kexit*0.75*stoplossshort*pipsize THEN EXITSHORT AT MARKET ENDIF ENDIF //////////////////////////////// IF CLOSE > Re1[1] THEN EXITSHORT AT MARKET ENDIF IF low < TRADEPRICE - 0.75*stoplossshort*pipsize THEN SET STOP pLOSS 0.01 ENDIF IF TIME > 214500 and DayOfWeek=5 then EXITSHORT AT MARKET ENDIF ENDIF |