MultiTimeFrame simple conditions
Forums › ProRealTime English forum › ProOrder support › MultiTimeFrame simple conditions
- This topic has 32 replies, 5 voices, and was last updated 5 years ago by jebus89.
-
-
01/28/2019 at 4:37 PM #8984501/28/2019 at 9:57 PM #89865
I heard an episode of the podcast “better system trader” with a “mean reversion expert”, i cant remember name or episode tho, its one of the older ones. he talks alot about how he uses the RSI in 4 hour and 1 hour (mtf) to create good strategies. Im working on RSI in mtf now and seeing some interesting results, nothing amazing so far tho, pic includes the latest im working on, first algo ive seen working in EU stox so im kinda happy with that, but yea no amazing results so far but im gonna optimize it now and see what happens..
Its long and short, i like to optimize the long and short seperatly to increase the speed of the optimization. As long as i already know that it will not affect the other long/short strategy i figured that should be safe and fine to do, and it saves me a ton of time either optimizing long or short 1 at a time or optimizing them together which could take hours..
1 user thanked author for this post.
01/28/2019 at 10:01 PM #89867Hi all,
Here I upload my version…
I like this concept, I called it: MULTI-SIMPLICITY TYPE A
// MULTI-SIMPLICITY TYPE A123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160// MULTI-SIMPLICITY TYPE ADEFPARAM CumulateOrders = false // Cumulating positionsDEFPARAM PreLoadBars = 1000 //cargar informacion//Parameters to be optimized//Pentry1=6//Kprofit=1.5ontime=1IF hour <= 2 or hour >= 22 thenontime=0ELSIF DayOfWeek <= 1 and hour <= 4 thenontime=0ELSIF DayOfWeek >= 5 and hour >= 20 thenontime=0ENDIFMetaRange=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] thenRe1=highest1ENDIFIF high > Re1 thenRe1=highENDIFlowest1=lowest[Pentry1](low)IF lowest1 = lowest1[PXentry1] thenS1=lowest1ENDIFIf low < S1 thenS1=lowENDIFConditionLong00001= 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 + ConditionLong00006ConditionShort = ConditionShort00001 +ConditionShort00002+ ConditionShort00003+ConditionShort00004+ConditionShort00005+ConditionShort00006//----------------------------------------------------------// >>>>>>>>>>>>>> ENTRY POSITIONS <<<<<<<<<<<<<<<<<<//----------------------------------------------------------// ---> LONG POSITIONSIF NOT LongOnMarket and ontime=1 THENIF ConditionLong > 2 THENstoplosslong= (close-S1)/pipsize+2*MetaRange/pipsize//in pipstargetprofitlong=stoplosslong*Kprofit //in pipsBUY 1 CONTRACTS AT MARKETSET STOP pLOSS stoplosslongSET TARGET pPROFIT targetprofitlongENDIFENDIF// ---> SHORT POSITIONSIF NOT ShortOnMarket and ontime=1 THENIF ConditionShort > 2 THENStopLossShort=(Re1-close)/pipsize+2*MetaRange/pipsize // in pipstargetprofitshort=StopLossShort*Kprofit // in pipsSELLSHORT 1 CONTRACTS AT MARKETSET STOP pLOSS StopLossShortSET TARGET pPROFIT targetprofitshortENDIFENDIF//---------------------------------------------------------//>>>>>>>>>>>>>>>>>> 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//ENDIFIF highest[BARINDEX-TRADEINDEX+1](high) > TRADEPRICE+0.75*stoplosslong*pipsize and (BARINDEX-TRADEINDEX)>=2 THENKexit=((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 thenSELL AT MARKETELSIF close < highest[BARINDEX-TRADEINDEX+1](high)-Kexit*0.75*stoplosslong*pipsize THENSELL AT MARKETENDIFENDIF////////////////////////////IF CLOSE < S1[1] THENSELL AT MARKETENDIFIF high > TRADEPRICE + 0.75*stoplosslong*pipsize THENSET STOP pLOSS 0.01ENDIFIF TIME > 214500 and DayOfWeek=5 thenSELL AT MARKETENDIFENDIF// Bedingungen zum Ausstieg aus Short-PositionenIF 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//ENDIFIF lowest[BARINDEX-TRADEINDEX+1](low) < TRADEPRICE-0.75*stoplossshort*pipsize and (BARINDEX-TRADEINDEX)>=2THENKexit=(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 THENEXITSHORT AT MARKETELSIF close > lowest[BARINDEX-TRADEINDEX+1](low) + Kexit*0.75*stoplossshort*pipsize THENEXITSHORT AT MARKETENDIFENDIF////////////////////////////////IF CLOSE > Re1[1] THENEXITSHORT AT MARKETENDIFIF low < TRADEPRICE - 0.75*stoplossshort*pipsize THENSET STOP pLOSS 0.01ENDIFIF TIME > 214500 and DayOfWeek=5 thenEXITSHORT AT MARKETENDIFENDIF01/28/2019 at 10:07 PM #8986901/28/2019 at 10:09 PM #89870I like this concept, I called it: MULTI-SIMPLICITY TYPE A
Here the walk forward
01/28/2019 at 10:29 PM #89875its nothing atm just trying out something like:
(this is short, reverse for long)
timeframe daily: rsi 2 > 95
timeframe 4 hours: rsi 2 > 95
timeframe 1 hour: rsi crosses under 95
Sell at daily timeframe when rsi 2 crosses under 30
I think its very easy to curvefit something like this so im very sceptical but honestly it also looks applicable in different markets.
01/28/2019 at 10:36 PM #8987701/28/2019 at 10:52 PM #89880I just made something with RSI, looks very nice as well
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157// MULTI-SIMPLICITY TYPE ADEFPARAM CumulateOrders = false // Cumulating positionsDEFPARAM PreLoadBars = 1000 //cargar informacion//Parameters to be optimized//Pentry1=6//Kprofit=1.5//Krsi=30ontime=1IF hour <= 2 or hour >= 22 thenontime=0ELSIF DayOfWeek <= 1 and hour <= 4 thenontime=0ELSIF DayOfWeek >= 5 and hour >= 20 thenontime=0ENDIFMetaRange=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] thenRe1=highest1ENDIFIF high > Re1 thenRe1=highENDIFlowest1=lowest[Pentry1](low)IF lowest1 = lowest1[PXentry1] thenS1=lowest1ENDIFIf low < S1 thenS1=lowENDIFConditionLong00001= RSI[14](close) > average[14](RSI[14](close)) and lowest[7](RSI[14](close))<KrsiConditionShort00001= RSI[14](close) < average[14](RSI[14](close)) and Highest[7](RSI[14](close))>100-Krsitimeframe(15 minutes,updateonclose)ConditionLong00002= RSI[14](close) > average[14](RSI[14](close)) and lowest[7](RSI[14](close))<KrsiConditionShort00002= RSI[14](close) < average[14](RSI[14](close)) and Highest[7](RSI[14](close))>100-Krsitimeframe(30 minutes,updateonclose)ConditionLong00003= RSI[14](close) > average[14](RSI[14](close)) and lowest[7](RSI[14](close))<KrsiConditionShort00003= RSI[14](close) < average[14](RSI[14](close)) and Highest[7](RSI[14](close))>100-Krsitimeframe(60 minutes,updateonclose)ConditionLong00004= RSI[14](close) > average[14](RSI[14](close)) and lowest[7](RSI[14](close))<KrsiConditionShort00004= RSI[14](close) < average[14](RSI[14](close)) and Highest[7](RSI[14](close))>100-Krsitimeframe(120 minutes,updateonclose)ConditionLong00005= RSI[14](close) > average[14](RSI[14](close)) and lowest[7](RSI[14](close))<KrsiConditionShort00005= RSI[14](close) < average[14](RSI[14](close)) and Highest[7](RSI[14](close))>100-Krsitimeframe(240 minutes,updateonclose)ConditionLong00006= RSI[14](close) > average[14](RSI[14](close)) and lowest[7](RSI[14](close))<KrsiConditionShort00006= RSI[14](close) < average[14](RSI[14](close)) and Highest[7](RSI[14](close))>100-Krsitimeframe(default)ConditionLong = ConditionLong00001 + ConditionLong00002 + ConditionLong00003 + ConditionLong00004 + ConditionLong00005 + ConditionLong00006ConditionShort = ConditionShort00001 +ConditionShort00002+ ConditionShort00003+ConditionShort00004+ConditionShort00005+ConditionShort00006//----------------------------------------------------------// >>>>>>>>>>>>>> ENTRY POSITIONS <<<<<<<<<<<<<<<<<<//----------------------------------------------------------// ---> LONG POSITIONSIF NOT LongOnMarket and ontime=1 THENIF ConditionLong > 2 THENstoplosslong= (close-S1)/pipsize+2*MetaRange/pipsize//in pipstargetprofitlong=stoplosslong*Kprofit //in pipsBUY 1 CONTRACTS AT MARKETSET STOP pLOSS stoplosslongSET TARGET pPROFIT targetprofitlongENDIFENDIF// ---> SHORT POSITIONSIF NOT ShortOnMarket and ontime=1 THENIF ConditionShort > 2 THENStopLossShort=(Re1-close)/pipsize+2*MetaRange/pipsize // in pipstargetprofitshort=StopLossShort*Kprofit // in pipsSELLSHORT 1 CONTRACTS AT MARKETSET STOP pLOSS StopLossShortSET TARGET pPROFIT targetprofitshortENDIFENDIF//---------------------------------------------------------//>>>>>>>>>>>>>>>>>> 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//ENDIFIF highest[BARINDEX-TRADEINDEX+1](high) > TRADEPRICE+0.75*stoplosslong*pipsize and (BARINDEX-TRADEINDEX)>=2 THENKexit=((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 thenSELL AT MARKETELSIF close < highest[BARINDEX-TRADEINDEX+1](high)-Kexit*0.75*stoplosslong*pipsize THENSELL AT MARKETENDIFENDIF////////////////////////////IF CLOSE < S1[1] THENSELL AT MARKETENDIFIF high > TRADEPRICE + 0.75*stoplosslong*pipsize THENSET STOP pLOSS 0.01ENDIFIF TIME > 214500 and DayOfWeek=5 thenSELL AT MARKETENDIFENDIF// Bedingungen zum Ausstieg aus Short-PositionenIF 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//ENDIFIF lowest[BARINDEX-TRADEINDEX+1](low) < TRADEPRICE-0.75*stoplossshort*pipsize and (BARINDEX-TRADEINDEX)>=2THENKexit=(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 THENEXITSHORT AT MARKETELSIF close > lowest[BARINDEX-TRADEINDEX+1](low) + Kexit*0.75*stoplossshort*pipsize THENEXITSHORT AT MARKETENDIFENDIF////////////////////////////////IF CLOSE > Re1[1] THENEXITSHORT AT MARKETENDIFIF low < TRADEPRICE - 0.75*stoplossshort*pipsize THENSET STOP pLOSS 0.01ENDIFIF TIME > 214500 and DayOfWeek=5 thenEXITSHORT AT MARKETENDIFENDIF01/28/2019 at 11:24 PM #89885I’ve had an RSI MTF strategy based on four time frames running on forward test on demo since the 22 August. Not many trades but profitable.
…and this is the in sample that is still available for back test.
The long only strategy has a simple daily market sentiment indicator that stops entry in major down markets. It enters if the fast RSI on all four time frames is below a certain level and exits if all four time frame RSI ‘s are over a certain level. It will also check once every 24 hours and if the trade is in profit it will also exit.
There is some light money management in there but it is very light. I worry about the market sentiment filter being over optimized but otherwise it so far seems pretty robust. Very few trades to give confidence yet though.
01/28/2019 at 11:25 PM #89890I think mtf is going from 2d to 3d. theres infinite shit to do.. im going kinda crazy just thinking about it.
Still havnt found a rly good way to take advantage just yet tbh, but i think it could help alot with the setup of the trade. Like saying “where the price has been before your entry” in multiple timeframes to better sort out at what “level” the price is on (high, low, mid range compared to X)
01/28/2019 at 11:34 PM #8989301/28/2019 at 11:35 PM #89894The trouble with MTF is that as we bore down to faster time frames we lose data to test on. I go to bed at night dreaming of PRT offering me 35 years of data on all time frames. Sure back testing would be horrendously slow but I’d put up with that for the other benefits!
01/28/2019 at 11:39 PM #89895could u share the “check if profitable every 24h and exit if profitable`” code?
No rocket science involved.
12345678910timeframe (default)if not onmarket and (my conditions) thenbuy positionsize contracts at markettme = timeendifif onmarket and close > positionprice and time = tme thensell at marketendif1 user thanked author for this post.
01/28/2019 at 11:43 PM #89896haha 35 years ye 😛
Thanks for the code, any chance ur willing to share what ur “disaster filter” is here?
“has a simple daily market sentiment indicator that stops entry in major down markets”
Are we talking like a moving average or an actual indicator? Any chance ud share? my long only systems might want this lol
01/28/2019 at 11:55 PM #89897any chance ur willing to share what ur “disaster filter” is here?
It is nothing special – just a look back to check that price is higher than it was a while back. Hence my concern that it is over fitted. As far as I am aware it has not been triggered yet in the forward test and wasn’t in the back test. It is just there to shut the strategy down in a big downturn. probably too late but better than nothing.
I am still searching for the ‘holy grail’ market sentiment filter that fits multiple markets and have not found it yet despite sometimes thinking that I am close. This last year indices have done all they can to disprove all previous ideas and so proving that history does not repeat itself – well at least not when we want it to!
-
AuthorPosts
Find exclusive trading pro-tools on