Multi timeframe – MTF indicators for ProRealTime
Forums › ProRealTime English forum › ProBuilder support › Multi timeframe – MTF indicators for ProRealTime
- This topic has 150 replies, 49 voices, and was last updated 1 week ago by robertogozzi.
Tagged: mtf, mtf indicators
-
-
06/30/2022 at 9:49 PM #196495
I use PRT V10.3 currently after viewing this and it appears to work on 10.3.
I’m trying live and have tried on demo, also backtesting.
So for instance running a trail updating on a lower timeframe to check price regularly instead of the entry timeframe bars is working withuot issue live.
It works well. I dont see here that it is released, so hopefully I wont run into any issues.
I’m running 10.3 premium. Can I assume it is currently released as usable?
09/06/2022 at 2:45 PM #200246I wonder why my Code is not runnig on a daily chart. Used TF’s are yearly and monthly – to my understandig both multiples of 1 day
I appreciate, if you could check for the reason. Even after hours of testing I was not able to get an idea.
The idea behind is, to perform a performance check on shares and to show the result as text in the chart. The return values are foreseen for usage in a screener.
Only InputValue is “BerechnungsPeriodeJahre” = calculation period in years. Meaning how far the lookback shall be in years.
On yearly basis on a per anno yield is calculated, on monthly basis then other performance values.
Performance Measurement123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242defparam DRAWONLASTBARONLY = truetimeframe(yearly)// Als Startwert für Zuwachs-/PARmax Berechnung wird das höchste historische Close bis zum Beginn der// Berechnungsperiode gewählt, jedoch max. 5 Jahre zurück// Dadurch wird ein zu positives Ergebnis wegen eines zwischenzeitlichen, zum Beginn der// Berechnungsperiode noch nicht beendeten DrawDowns vermiedenlookBack = 5if islastbarupdate and barindex > lastcalcyearlybarindex thenfor y = BerechnungsPeriodeJahre + lookBack downto BerechnungsPeriodeJahre + 1 docurhighestclose = max(curhighestclose, close[y])if curhighestclose > prevvalue thenhighjahr = year - yprevvalue = curhighestcloseendifnextif open[BerechnungsPeriodeJahre] >= curhighestclose thenhighjahr = Year[BerechnungsPeriodeJahre]endif// Startwerte = Werte am Anfang der Berechnungsperiodebedopen = open[BerechnungsPeriodeJahre] >= curhighestclosefirstopen = max(open[BerechnungsPeriodeJahre], curhighestclose)StartJahr = Year[BerechnungsPeriodeJahre]auswertungszeitraumJ = Year - StartJahr + (days - days[1])/365lastcalcyearlybarindex = barindexendiftimeframe(monthly)BerechnungsPeriodeMonate = round(auswertungszeitraumJ*12)//// MonatsSchlusskurse speichern$MClose[barindex] = closeif IsLastBarUpdate thenif barindex > lastcalcmonthlybarindex thenfor m = BerechnungsPeriodeMonate downto 0 do// Datenerfassung für Draw Down BerechnungenhighestOC = max(highestOC, max(close[m], open[m]))lowestclose = min(close[m], lowestclose)if (highestOC > prevhighestOC) thenprevhighestOC = highestOClowestclose = highestOCendifif lowestclose < prevhighestOC thencurrDrawDownmax = max(currDrawDownmax, 1 - lowestClose / highestOC)elsif lowestclose >= prevhighestOC thenGesamtSummeDrawDowns = GesamtSummeDrawDowns + currDrawDownmaxcurrDrawDownmax = 0endif// Datenerfassung für monatliches Verlustrisiko für beendete Monate, zeitliche Gewichtung// Gewichtungsfaktor: letzter Monat = BerechnungsPeriodeMonate, erster Monat = 1if m > 0 thengewichtungsfaktor = BerechnungsPeriodeMonate - m + 1if close[m] < open[m] thenVerlustMonate = VerlustMonate + 1sumgewichteterVerlustMonatlich = sumgewichteterVerlustMonatlich + (1 - close[m]/open[m]) * gewichtungsfaktorsumGewichtungsfaktorVerlust = sumGewichtungsfaktorVerlust + gewichtungsfaktorendifelsegewichtungsfaktor = 0endifnext//Datenerfassung für variable GewinnKonstanzVarZeitraumfor firstmonth = lastset($MClose) - BerechnungsPeriodeMonate to lastset($MClose) dofor nextmonths = firstmonth + 1 to lastset($MClose) - 1 doif $MClose[nextmonths] > $MClose[firstmonth] thenGewinnPerioden = GewinnPerioden + 1endifAnzahlPerioden = AnzahlPerioden + 1nextnext// Auf letztem Balken Wert für Summe DD berechnen, auch wenn DD noch nicht beendet istif currDrawDownmax > 0 thenGesamtSummeDrawDowns = GesamtSummeDrawDowns + currDrawDownmaxendiflastcalcmonthlybarindex = barindexendif //if barindex > lastcalcmonthlybarindex// VERLUSTRISIKO MONATLICHER ZEITRAUM// Häufigkeit mit der eine Anlage zu Monatsbeginn mit einer Anlagedauer von 1 Monat im// Betrachtungszeitraum zu einem negativen Ergebnis geführt hättemonatlicheVerlustwahrscheinlichkeit = VerlustMonate / BerechnungsPeriodeMonategewichteterDurchschnittVerlust = sumgewichteterVerlustMonatlich / sumGewichtungsfaktorVerlustmonatlichesVerlustRatio = monatlicheVerlustwahrscheinlichkeit * gewichteterDurchschnittVerlust// GEWINNKONSTANZ VARIABLER ZEITRAUM// Häufigkeit, mit der eine monatliche Anlage mit beliebiger Anlagedauer im// Betrachtungszeitraum zu einem positives Ergebnis geführt hätteGewinnKonstanzVarZeitraum = GewinnPerioden/AnzahlPerioden// WERTZUWACHS///////////////////////////////////////////////////////////////highestZuwachs = highestOC/firstopen - 1currZuwachs = Close/firstopen - 1// HÖCHSTE PER ANNO RENDITE// Rendite p.a. = (1 + Wertentwicklung) ^ (365 / Tage) - 1// PARmax = POW(1 + Zuwachs, potenz) - 1// y = x ^ p muss wegen PRT Fehler wie folgt codiert werden: y = EXP(p * LOG(x))///////////////////////////////////////////////////////////////potenz = 1 / auswertungszeitraumJPARmax = exp(potenz * log(1 + highestZuwachs)) - 1// WAHRSCHEINLICHE PARmaxif (PARmax >= 0) thenWahrscheinlichePARmax = PARmax * GewinnKonstanzVarZeitraumelseWahrscheinlichePARmax = PARmax / GewinnKonstanzVarZeitraumendif// CRV///////////////////////////////////////////////////////////////if GesamtSummeDrawDowns > 0 thenCRV = highestZuwachs / GesamtSummeDrawDownselseCRV = highestZuwachsendif//ALL IN ONE KENNZAHLRisikoAdjustiertePerformanceKennzahl = WahrscheinlichePARmax * CRV / monatlichesVerlustRatio// TÄGLICHES HANDELSVOLUMEN IM BETRACHTUNGSZEITRAUMtagepromonat = 20avgdailyvolume = summation[BerechnungsPeriodeMonate](volume) / (tagepromonat * BerechnungsPeriodeMonate)endif // IsLastBarUpdate TF monthlytimeframe(default)// RUNDUNG FÜR BESSERE DARSTELLUNG///////////////////////////////////////////////////////////////currZuwachsvH = round(currZuwachs * 100)highestZuwachsvH = round(highestZuwachs * 100)PARmaxvH = round(PARmax * 100)GewinnKonstanzVarZeitraumrounded = round(GewinnKonstanzVarZeitraum * 100,1)currDrawDownMaxvH = round(currDrawDownmax * 100)CRVrounded = round(Max(1, CRV))WahrscheinlichePARmaxrounded = round(WahrscheinlichePARmax * 100,0)SummeDrawDownsvH = round(GesamtSummeDrawDowns * 100)lastcloserounded = round(close * 100) / 100firstopenrounded = round(firstopen * 100) / 100highestOCrounded = round(highestOC * 100) / 100lowestCloserounded = round(lowestClose * 100) / 100auswertungszeitraumJrounded = round(auswertungszeitraumJ,1)monatlichesVerlustRatiovH = round(monatlichesVerlustRatio * 100,1)RisikoAdjustiertePerformanceKennzahlrounded = round(RisikoAdjustiertePerformanceKennzahl/10,1)avgdailyvolumerounded = round(avgdailyvolume)// ZUSATZINFORMATIONEN IM INDIKATORCHART ANZEIGEN///////////////////////////////////////////////////////////////offsethor = MoveRightLeftFaktor // horizontale Pos. vom Ankerpunktoffsethorsp2 = offsethor + 175offsetver = 10 * MoveUpDownFaktor // vertikale Pos. vom Ankerpunktstep = -22 // Schrittweite vertikale Pos. für verschiedene Zeilenzeilen = 0Drawtext("AUSWERTUNGZEITRAUM #auswertungszeitraumJrounded#J ab 01 / #StartJahr#", offsethor+50, offsetver + zeilen * step, SansSerif, Bold, 15) coloured( 72, 118, 255) anchor (left)zeilen = 1.5 + zeilendist = 20Drawtext("PerformanceKennzahl", offsethor - dist, offsetver + zeilen * step, SansSerif, Bold, 15) coloured(200, 0, 200) anchor (left)Drawtext("#RisikoAdjustiertePerformanceKennzahlrounded#", offsethorsp2 , offsetver + zeilen * step, SansSerif, Bold, 15) coloured(200, 0, 200) anchor (left)zeilen = 1.5 + zeilenDrawtext("PARmax", offsethor - 3 * dist - 10, offsetver + zeilen * step, SansSerif, Bold, 15) coloured(0, 125 ,0) anchor (left)Drawtext("avg #PARmaxvH# % p.a.", offsethorsp2, offsetver + zeilen * step, SansSerif, Bold, 15) coloured(0, 125 ,0) anchor (left)zeilen = 1 + zeilenDrawtext("GewinnKonstanz langfristig", offsethor - 2, offsetver + zeilen * step, SansSerif, Bold, 15) coloured(0, 125 ,0) anchor (left)Drawtext("#GewinnKonstanzVarZeitraumrounded# %", offsethorsp2, offsetver + zeilen * step, SansSerif, Bold, 15) coloured(0, 125 ,0) anchor (left)zeilen = 1 + zeilenDrawtext("WahrscheinlichePARmax", offsethor - 13, offsetver + zeilen * step, SansSerif, Bold, 15) coloured(0, 125 ,0) anchor (left)Drawtext("avg #WahrscheinlichePARmaxrounded# % p.a.", offsethorsp2, offsetver + zeilen * step, SansSerif, Bold, 15) coloured(0, 125 ,0) anchor (left)zeilen = 1.5 + zeilenDrawtext("CRV", offsethor - 4 * dist - 4, offsetver + zeilen * step, SansSerif, Bold, 15) coloured(250, 200, 250) anchor (left)Drawtext("#CRVrounded# ", offsethorsp2, offsetver + zeilen * step, SansSerif, Bold, 15) coloured(250, 200, 250) anchor (left)zeilen = 1 + zeilenDrawtext("VerlustRatio monatl.", offsethor - 1.4 * dist, offsetver + zeilen * step, SansSerif, Bold, 15) coloured(250, 200, 250) anchor (left)Drawtext("#monatlichesVerlustRatiovH#", offsethorsp2, offsetver + zeilen * step, SansSerif, Bold, 15) coloured(250, 200, 250) anchor (left)zeilen = 1.5 + zeilenDrawtext("last highest Close", offsethor - 1.5 * dist - 6, offsetver + zeilen * step, SansSerif, Bold, 15) coloured(238,59,59) anchor (left)Drawtext("#highestOCrounded# Pkte", offsethorsp2, offsetver + zeilen * step, SansSerif, Bold, 15) coloured(238,59,59) anchor (left)zeilen = 1 + zeilenDrawtext("last Lowest Close", offsethor - 1.5 * dist - 6, offsetver + zeilen * step, SansSerif, Bold, 15) coloured(238,59,59) anchor (left)Drawtext("#lowestCloserounded# Pkte", offsethorsp2, offsetver + zeilen * step, SansSerif, Bold, 15) coloured(238,59,59) anchor (left)zeilen = 1 + zeilenDrawtext("curr. DrawDown max.", offsethor - dist - 4, offsetver + zeilen * step, SansSerif, Bold, 15) coloured(238,59,59) anchor (left)Drawtext("#currDrawDownMaxvH# %", offsethorsp2, offsetver + zeilen * step, SansSerif, Bold, 15) coloured(238,59,59) anchor (left)zeilen = 1 + zeilenDrawtext("Summe DrawDowns", offsethor - dist - 10, offsetver + zeilen * step, SansSerif, Bold, 15) coloured(238,59,59) anchor (left)Drawtext("#SummeDrawDownsvH# %", offsethorsp2, offsetver + zeilen * step, SansSerif, Bold, 15) coloured(238,59,59) anchor (left)zeilen = 1.5 + zeilenif not bedopen thenDrawtext("First Open = Close #highjahr#", offsethor - 12, offsetver + zeilen * step, SansSerif, Bold, 15) coloured(100, 100 , 255) anchor (left)elseDrawtext("First Open = Open #StartJahr#", offsethor - 12, offsetver + zeilen * step, SansSerif, Bold, 15) coloured(100, 100 , 255) anchor (left)endifDrawtext("#firstopenrounded# Pkte", offsethorsp2, offsetver + zeilen * step, SansSerif, Bold, 15) coloured(100, 100 , 255) anchor (left)zeilen = 1 + zeilenDrawtext("Today Close", offsethor - 2.5 * dist - 7, offsetver + zeilen * step, SansSerif, Bold, 15) coloured(100, 100 , 255) anchor (left)Drawtext("#lastcloserounded# Pkte", offsethorsp2, offsetver + zeilen * step, SansSerif, Bold, 15) coloured(100, 100 , 255) anchor (left)zeilen = 1 + zeilenDrawtext("Zuwachs höchster", offsethor - 1.5 * dist - 5, offsetver + zeilen * step, SansSerif, Bold, 15) coloured(100, 100, 255) anchor (left)Drawtext("#highestZuwachsvH# %", offsethorsp2, offsetver + zeilen * step, SansSerif, Bold, 15) coloured(100, 100, 255) anchor (left)zeilen = 1 + zeilenDrawtext("Zuwachs akt.", offsethor - 2.5 * dist - 4, offsetver + zeilen * step, SansSerif, Bold, 15) coloured(100, 100, 255) anchor (left)Drawtext("#currZuwachsvH# %", offsethorsp2, offsetver + zeilen * step, SansSerif, Bold, 15) coloured(100, 100, 255) anchor (left)zeilen = 1 + zeilenDrawtext("avg. daily Volume", offsethor - 1.5 * dist - 8, offsetver + zeilen * step, SansSerif, Bold, 15) coloured(100, 100, 255) anchor (left)Drawtext("#avgdailyvolumerounded# ", offsethorsp2, offsetver + zeilen * step, SansSerif, Bold, 15) coloured(100, 100, 255) anchor (left)// AUSGABE DES ERGEBNISSES///////////////////////////////////////////////////////////////return RisikoAdjustiertePerformanceKennzahlrounded as "PerformanceKennzahl", highestOC as "highest Close", lowestClose as "lowest Close", close as "last Close", avgdailyvolume as "AVG Daily Volume"09/07/2022 at 8:15 AM #20026009/07/2022 at 8:54 AM #20027101/13/2023 at 12:59 PM #207345Hi
The below timeframe is not supported
1TIMEFRAME(6 HOUR)Is there any alternative way I can run this?
Thanks
01/13/2023 at 1:25 PM #20735001/13/2023 at 1:44 PM #207357It’s working just fine for indicators programming, are you trying with a screener code?
Yes, that’s correct. I’m trying to use TIMEFRAME(6 HOUR) in the ProScreener
01/13/2023 at 1:54 PM #207360ProScreener allows only the timeframes available in its “Period” dropdown list, that’s why you can’t use 6-Hours which is not an usual timeframe (and therefore not available).
1 user thanked author for this post.
01/15/2023 at 1:34 AM #207451Bonjour,
J’essaie de programmer une stratégie en MTF en me basant sur le livre de Alexander Elder (stratégie Triple Screen).
Dans le livre il est expliqué que :
- Screen 1 : doit afficher la tendance à long terme
- Screen 2 : doit afficher une tendance opposé au Screen 1 à court terme
- Screen 3 : l’ouverture de position dans le sens de la tendance du Screen 1
Pour cette stratégie j’ai choisi d’utiliser un indicateur de tendance pour le Screen 1, un oscillateur pour le Screen 2 et des conditions de breakout pour le Screen 3.
- Screen 1 : MACD
- Screen 2 : RSI
- Screen 3 : achat si cassure high[1] du timeframe Screen 2 et vente si cassure low[1] du timeframe Screen 2
Voici mon code :
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475DEFPARAM CUMULATEORDERS = FALSEDEFPARAM NoCashUpdate = FALSEDEFPARAM MinOrder = 1//DEFPARAM FlatBefore = 100000//DEFPARAM FlatAfter = 180000MinSize = 10AmplitudeMax = 50AmplitudeMin = 20/*==============================================================================================================================*/// Ecran 1 : définir la tendance de long termeTIMEFRAME(Weekly, updateonclose)MACDhistogram = MACD[12,26,9](close)WeeklyC1 = MACDhistogram < 0 AND MACDhistogram[1] < 0WeeklyC2 = MACDhistogram > 0 AND MACDhistogram[1] > 0WeeklyC3 = MACDhistogram > MACDhistogram[1]WeeklyC4 = MACDhistogram < MACDhistogram[1]/*==============================================================================================================================*/// Ecran 2 : Définir si la tendance intérmédiaire est dans le sens opposé de la tendance LTTIMEFRAME(Daily, updateonclose)DailyRSI = RSI[14](close)DailySAR = SAR[0.02,0.02,0.2]Haut = high[1]Bas = low[1]DailyAmplitude = abs(haut - bas)DailyC1 = DailyRSI < 30DailyC2 = DailyRSI > 70DailyC3 = DailyAmplitude > AmplitudeMin AND DailyAmplitude < AmplitudeMax/*==============================================================================================================================*/// Ecran 3 : Placer les ordres d'achat et de venteTIMEFRAME(1 hour, updateonclose)// Conditions pour ouvrir une position à l'achat et pour fermer une position d'achatOneHourC1 = Close CROSSES OVER HautOneHourC2 = Close CROSSES UNDER DailySAR// Ouverture position acheteuseIF NOT ONMARKET AND (WeeklyC1 OR WeeklyC2) AND WeeklyC3 AND DailyC1 AND DailyC3 AND Close CROSSES OVER Haut THENBUY MinSize CONTRACTS AT MARKETENDIF// Clôture position acheteuseIF LongOnMarket AND OneHourC2 THENSELL AT MARKETENDIF// Conditions pour ouvrir une position à la vente et pour fermer une position à la venteOneHourC3 = Close CROSSES UNDER BasOneHourC4 = Close CROSSES OVER DailySAR// Ouverture position vendeuseIF NOT OnMarket AND (WeeklyC1 OR WeeklyC2) AND WeeklyC4 AND DailyC2 AND DailyC3 AND OneHourC3 THENSELLSHORT MinSize CONTRACTS AT MARKETENDIF// Clôture position vendeuseIF ShortOnMarket AND OneHourC4 THENEXITSHORT AT MARKETENDIF// STOP LOSS GARANTIESET STOP LOSS DailyAmplitudeIF STRATEGYPROFIT < -200 THENQUITENDIFJe souhaite utiliser cette stratégie sur les actions. Je n’ai pas encore paramétré le calcul de la taille de position c’est pour cela que la taille de la position est à 10 actions.
Mon problème et qu’après avoir tester sur plusieurs actions (avec des prix différents > 100€ ou < 100€), le backtest n’affiche rien, comme s’il n’y a pas eu de transactions. Pouvez-vous m’aider à trouver l’erreur ?
Merci d’avance !
03/20/2023 at 1:31 PM #211788Hello everyone, Regarding the multitime frame, I have an automatic strategy that operates in TF 2 min, with filters in daily and weekly TF. Currently carrying out a Backtest takes a long time and we believe that it is due to the daily and weekly checks in TF. Help is requested to see some idea that allows redefining the code and allowing backtests to be carried out in less time. Thank you very much Regards Alfonso
03/20/2023 at 1:40 PM #21179203/20/2023 at 2:07 PM #21179705/14/2023 at 11:23 AM #21467805/14/2023 at 11:45 AM #214680Yes, I spammed all of them as you can’t advertise products other than about ProRealTime.
And, if you advertise ProRealTime products, you can only do that in the Platform Support.
Thank you 🙂
05/14/2023 at 11:47 AM #214681Sorry, i meant in the General Trading Discussions Forum.
-
AuthorPosts