[beta-testing] multi timeframe support for automatic trading, ideas are welcome!
Forums › ProRealTime English forum › ProOrder support › [beta-testing] multi timeframe support for automatic trading, ideas are welcome!
- This topic has 287 replies, 47 voices, and was last updated 4 years ago by Brianoshea.
Tagged: mtf, multitimeframe
-
-
08/24/2018 at 12:19 PM #78933
et
No, i tried both, still different.
If I am forced to use lower time frames to manage a trade on a higher timeframe, the result is totally different. So it means that something is not right.
08/24/2018 at 12:46 PM #7893808/24/2018 at 10:54 PM #79030Hello to everybody!
I have two questions that I would like to clarify; maybe they have already been asked, but I cannot find them.In a multi timeframe scenario, something like that
123if ((not onmarket) and (onmarket<strong>[1]</strong>) then// do something if the strategy has just exited from the marketendif[1] what does it refer to? to the default TF?
And in something like
1234567891011timeframe (5 minutes, updateonclose)MA20 = average [20]bulltrend = summation [3] (MA20> MA20 [1]) = 3// "default" timeframe (the timeframe you will launch the strategy on)timeframe (default)...if (MA20 <MA20<strong>[1]</strong>) then// do something if MA20 is decreasingendif[1] is referred to the value of MA20 in the TF bar 5 minutes before?
Thanks,
Lorenzo08/25/2018 at 5:32 AM #790311) it does not involve TFs, it simply checks whether a trade has just been closed, though you usually use this for in the lowest TF.
2) yes.
1 user thanked author for this post.
08/25/2018 at 8:40 AM #79034but I cannot find them.
This may help?
https://www.prorealcode.com/blog/learning/approach-multi-timeframe-trading-prorealtime/
1 user thanked author for this post.
08/26/2018 at 10:45 AM #79100I think it is because you are trying to buy and sell with those instructions in the 4 hour timeframe when with MTF you should be buying and selling in the default time frame. That is just a poorly educated guess though.
i think that is the reason, but if is like this MTF is useless to use in Trailing stop code, and no so Revolutionary as said for the TF, in fact i think that one of the big problems of PRT is the use of the Trailing Stop function specially with Big TF, in fact if the funcion #trailingstop makes the results of the backtesting unreliable, a big improve should be using MultiFrame even for smaller periods even if the strategy is for a big periods.
If the MTF remains like now, with the only possibility to use MTF starting for a small periods, thats will be not a big improve.
And also, if i use a strategy originally made with the 4hr TF, starting from a lower TF but with the command Timeframe4hr, results should be the same, not differents.
08/26/2018 at 11:51 AM #79104I think it is because you are trying to buy and sell with those instructions in the 4 hour timeframe when with MTF you should be buying and selling in the default time frame.
That’s wrong. In this example, the strategy is buying on a 15-minute timeframe and the orders are managed in a lower TF: Partial closure of positions when price is retracing
a big improve should be using MultiFrame even for smaller periods even if the strategy is for a big periods.
That’s possible, why not using one of the trailing code functions available on the website, like the way I did in the article above?
If the MTF remains like now, with the only possibility to use MTF starting for a small periods, thats will be not a big improve.
That’s obvious that if you are using a lower timeframe to manage your orders, the ‘starting’ TF is the smallest one. But I deplore the fact that the history is limited to this one though..
if i use a strategy originally made with the 4hr TF, starting from a lower TF but with the command Timeframe4hr, results should be the same, not differents.
If the whole code of the strategy is embedded in the timeframe(4 hours, updateonclose), results should be the same (example attached below).
08/26/2018 at 1:25 PM #79109When your strategy works as expected on a 4-h TF, with your trailing stop code embedded in the default TF, you can detect any benefit from MTF just:
- Backtest it from a 4-hour TF using the max time interval allowed for 1-minute chart
- Bscktest it from a 1-minute chart
if this shows benefits, then keep your strategy MTF for the trailing code, otherwise do not!
If you use MTF for your 4-hour strategy to run trailing stop code in a 30-minute TF you’ll never have benefits, because in 30 minutes prices can move so many pips, especially Dax and EurUsd.
MTF should be used if:
- you want to test indicators in more than one TF
- you want to make your trailing stop code more responsive
- you want both
08/29/2018 at 3:22 PM #79299I’m trying a mtf code in demo live, and I wanna share with you how I am unable to see errors in opening trades…
This is the code:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160//-------------------------------------------------------------------------// Codice principale : RSIOMA MTF DAX 30M//-------------------------------------------------------------------------defparam preloadbars=10000defparam cumulateorders=truemyRSIoMA, myLevelUp, myLevelDown, mymedlevel = CALL "PRC_RSIoMA extended"[14, 21, 1, 50, 80, 20](close)TIMEFRAME (Daily, updateonclose)//your daily conditionsdlong=myRSIoMA>myRSIoMA[1]dshort=myRSIoMA<myRSIoMA[1]TIMEFRAME (4 hours, updateonclose)//your 4-hour conditionsh4long=myRSIoMA>mymedlevelh4short=myRSIoMA<mymedlevelTIMEFRAME (1 hour, updateonclose)//your 1-hour conditionsh1long=myRSIoMA>myLevelUph1short=myRSIoMA<myLevelDownmyST=Supertrend[3,10]TIMEFRAME (default)//your code to Enter/Exit trades//your stop loss codeentrylong=myRSIoMA crosses over mylevelupentryshort=myRSIoMA crosses under myleveldownif dlong and h4long and h1long and entrylong thenbuy 1 contracts at marketendifif dshort and h4short and h1short and entryshort thensellshort 1 contracts at marketendifif longonmarket and close crosses under myST or myRSIOMA crosses under mylevelup thensell at marketendifif shortonmarket and close crosses over myST or myRSIOMA crosses over myleveldown thenexitshort at marketendif///breakevenstartBreakeven = 50 //how much pips/points in gain to activate the breakeven function?PointsToKeep = 5 //how much pips/points to keep in profit above of below our entry price when the breakeven is activated (beware of spread)//reset the breakevenLevel when no trade are on marketIF NOT ONMARKET THENbreakevenLevel=0ENDIF// --- BUY SIDE ---//test if the price have moved favourably of "startBreakeven" points alreadyIF LONGONMARKET AND close-tradeprice(1)>=startBreakeven*pipsize THEN//calculate the breakevenLevelbreakevenLevel = tradeprice(1)+PointsToKeep*pipsizeENDIF//place the new stop orders on market at breakevenLevelIF breakevenLevel>0 THENSELL AT breakevenLevel STOPENDIF// --- end of BUY SIDE ---//sell sideIF SHORTONMARKET AND tradeprice(1)-close>startBreakeven*pipsize THEN//calculate the breakevenLevelbreakevenLevel = tradeprice(1)-PointsToKeep*pipsizeENDIF//place the new stop orders on market at breakevenLevelIF breakevenLevel>0 THENEXITSHORT AT breakevenLevel STOPENDIF//stoploss for long positionIf longonmarket then//calculate the long stoploss (difference between the open price of the trade and the lowest low)Slong = Tradeprice-Lowest [15](low)Set stop loss SlongEndif//stoploss for short positionif shortonmarket then//calculate the short order stoploss (difference between the open price of the trade and the highest high)Sshort = Highest [10](high) - TradepriceSet stop loss SshortEndifset target pprofit 100//-------------------------------------------------------------------------// Funzione : PRC_RSIoMA extended//-------------------------------------------------------------------------//PRC_RSIoMA extended | indicator//27.08.2018//Nicolas @ www.prorealcode.com//Sharing ProRealTime knowledge//converted from MT5 version// --- settings//RsiPeriod = 14 // Rsi period//PriceSmoothing = 21 // Price smoothing (<= 1 for no smoothing)//PriceSmoothingM = 1 // Price smoothing method (MA mode)//MinMaxPeriod = 50 // Floating levels period (<= 1 for fixed levels)//LevelUp = 80.0 // Up level %//LevelDown = 20.0 // Down level %// --- end of settingsRsiPrice = customclose // Price to usen=max(1,PriceSmoothing)ma=average[n,PriceSmoothingM](RsiPrice)rsioma=rsi[RsiPeriod](ma)//levelsmmin = rsiomammax = rsiomafor k=1 to MinMaxPeriod-1 dommin=min(rsioma[k],mmin)mmax=max(rsioma[k],mmax)nextrrange = mmax-mminlevelupz = mmin+LevelUp * rrange/100leveldnz = mmin+LevelDown * rrange/100levelmi = mmin+0.5*rrange//coloursr=192g=192b=192if rsioma>levelupz thenr=50g=205b=50elsif rsioma<leveldnz thenr=255g=165b=0endifslope=rsioma-rsioma[1]long=slope crosses over 0 and rsioma<levelupzshort=slope crosses under 0 and rsioma>levelupzif long thendrawarrowup(rsioma,low) coloured(0,255,0)endifif short thendrawarrowdown(rsioma,high) coloured(255,0,0)endifreturn rsioma coloured(r,g,b) style(line,3) as "RSIoMA",levelupz coloured(50,205,50) style(dottedline,2) as "Level Up", leveldnz coloured(255,165,0) style(dottedline,2) as "Level Down", levelmi coloured(155,155,155) style(dottedline,2) as "mid level"And this is a screenshot from actual live trades:
As you can see, the need for having superior tfs above upperlevel (green zones) and crossing up of base tf (30m) are not respected.
Why?
08/29/2018 at 4:24 PM #79301Line 6 assigns values to variables based on PRC_RSIoMA extended called from the deafult (lower, I guess) TF.
Lines 10-11, 15-16 and 21-22 reflect this behaviour, rather than referencing an indicator for their own TF. You should move line 6 to the beginning of each TF using different variable names:
12345678910111213timeframe (daily,updateonclose)MyAvgD = close > average[20](close)timeframe (4 hours,updateonclose)MyAvgH4 = close > average[20](close)timeframe (1 hours,updateonclose)CrossingUP = average[5](close) CROSSES OVER average[20](close)timeframe (default)IF MyAvgD AND MyAvgH4 AND CrossingUP THENBUY.....ENDIF08/29/2018 at 4:24 PM #79302Your indicator is declared and calculated in the ‘default’ timeframe and not in any other one. So, even if you are testing above/below levels in other TF, the code will always use the same indicator values.
EDIT: Faster than me Roberto! and with a more precise answer! 😉
1 user thanked author for this post.
08/29/2018 at 5:48 PM #7930408/29/2018 at 9:17 PM #7931808/29/2018 at 9:56 PM #79324You should use
1myRSIoMAD, myLevelUpD, myLevelDownD, mymedleveD = CALL "PRC_RSIoMA extended"[14, 21, 1, 50, 80, 20](close)for the DAILY TF and
1myRSIoMA1H, myLevelUp1H, myLevelDown1H, mymedlevel1H = CALL "PRC_RSIoMA extended"[14, 21, 1, 50, 80, 20](close)for the 1-hour TF.
08/29/2018 at 10:10 PM #79326 -
AuthorPosts
Find exclusive trading pro-tools on