Multi timeframe – MTF indicators for ProRealTime

Viewing 15 posts - 91 through 105 (of 165 total)
  • Author
    Posts
  • #196495 quote
    jacksonliam341
    Blocked
    New

    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?

    #200246 quote
    jrh_han
    Participant
    New

    I 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.

    defparam DRAWONLASTBARONLY = true
    
    timeframe(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 vermieden
    
    lookBack = 5
    
    if islastbarupdate and barindex > lastcalcyearlybarindex then
    for y = BerechnungsPeriodeJahre + lookBack downto BerechnungsPeriodeJahre + 1 do
    curhighestclose = max(curhighestclose, close[y])
    if curhighestclose > prevvalue then
    highjahr = year - y
    prevvalue = curhighestclose
    endif
    next
    
    if open[BerechnungsPeriodeJahre] >= curhighestclose then
    highjahr = Year[BerechnungsPeriodeJahre]
    endif
    
    // Startwerte = Werte am Anfang der Berechnungsperiode
    bedopen              = open[BerechnungsPeriodeJahre] >= curhighestclose
    firstopen            = max(open[BerechnungsPeriodeJahre], curhighestclose)
    StartJahr            = Year[BerechnungsPeriodeJahre]
    auswertungszeitraumJ = Year - StartJahr + (days - days[1])/365
    
    lastcalcyearlybarindex = barindex
    endif
    
    timeframe(monthly)
    BerechnungsPeriodeMonate = round(auswertungszeitraumJ*12)
    
    //// MonatsSchlusskurse speichern
    $MClose[barindex] = close
    
    if IsLastBarUpdate then
    if barindex > lastcalcmonthlybarindex then
    for m = BerechnungsPeriodeMonate downto 0 do
    // Datenerfassung für Draw Down Berechnungen
    highestOC = max(highestOC, max(close[m], open[m]))
    lowestclose  = min(close[m], lowestclose)
    
    if (highestOC > prevhighestOC) then
    prevhighestOC = highestOC
    lowestclose      = highestOC
    endif
    
    if lowestclose < prevhighestOC then
    currDrawDownmax    = max(currDrawDownmax, 1 - lowestClose / highestOC)
    elsif lowestclose >= prevhighestOC then
    GesamtSummeDrawDowns = GesamtSummeDrawDowns + currDrawDownmax
    currDrawDownmax = 0
    endif
    
    // Datenerfassung für monatliches Verlustrisiko für beendete Monate, zeitliche Gewichtung
    // Gewichtungsfaktor: letzter Monat = BerechnungsPeriodeMonate, erster Monat = 1
    if m > 0 then
    gewichtungsfaktor = BerechnungsPeriodeMonate - m + 1
    if close[m] < open[m] then
    VerlustMonate = VerlustMonate + 1
    sumgewichteterVerlustMonatlich = sumgewichteterVerlustMonatlich + (1 - close[m]/open[m]) * gewichtungsfaktor
    sumGewichtungsfaktorVerlust = sumGewichtungsfaktorVerlust + gewichtungsfaktor
    endif
    else
    gewichtungsfaktor = 0
    endif
    next
    
    //Datenerfassung für variable GewinnKonstanzVarZeitraum
    for firstmonth =  lastset($MClose) - BerechnungsPeriodeMonate to lastset($MClose) do
    for nextmonths = firstmonth + 1 to lastset($MClose) - 1 do
    if $MClose[nextmonths] > $MClose[firstmonth] then
    GewinnPerioden = GewinnPerioden + 1
    endif
    AnzahlPerioden = AnzahlPerioden + 1
    next
    next
    
    // Auf letztem Balken Wert für Summe DD berechnen, auch wenn DD noch nicht beendet ist
    if currDrawDownmax > 0 then
    GesamtSummeDrawDowns = GesamtSummeDrawDowns + currDrawDownmax
    endif
    
    lastcalcmonthlybarindex = barindex
    endif  //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ätte
    monatlicheVerlustwahrscheinlichkeit = VerlustMonate / BerechnungsPeriodeMonate
    gewichteterDurchschnittVerlust = sumgewichteterVerlustMonatlich / sumGewichtungsfaktorVerlust
    monatlichesVerlustRatio = monatlicheVerlustwahrscheinlichkeit * gewichteterDurchschnittVerlust
    
    // GEWINNKONSTANZ VARIABLER ZEITRAUM
    // Häufigkeit, mit der eine monatliche Anlage mit beliebiger Anlagedauer im
    // Betrachtungszeitraum zu einem positives Ergebnis geführt hätte
    GewinnKonstanzVarZeitraum = GewinnPerioden/AnzahlPerioden
    
    // WERTZUWACHS
    ///////////////////////////////////////////////////////////////
    highestZuwachs = highestOC/firstopen - 1
    currZuwachs    = 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 / auswertungszeitraumJ
    PARmax = exp(potenz * log(1 + highestZuwachs)) - 1
    
    // WAHRSCHEINLICHE PARmax
    if (PARmax >= 0) then
    WahrscheinlichePARmax = PARmax * GewinnKonstanzVarZeitraum
    else
    WahrscheinlichePARmax = PARmax / GewinnKonstanzVarZeitraum
    endif
    
    // CRV
    ///////////////////////////////////////////////////////////////
    if GesamtSummeDrawDowns > 0 then
    CRV = highestZuwachs / GesamtSummeDrawDowns
    else
    CRV = highestZuwachs
    endif
    
    //ALL IN ONE KENNZAHL
    RisikoAdjustiertePerformanceKennzahl = WahrscheinlichePARmax * CRV / monatlichesVerlustRatio
    
    
    // TÄGLICHES HANDELSVOLUMEN IM BETRACHTUNGSZEITRAUM
    tagepromonat = 20
    avgdailyvolume = summation[BerechnungsPeriodeMonate](volume) / (tagepromonat * BerechnungsPeriodeMonate)
    
    
    endif // IsLastBarUpdate TF monthly
    
    timeframe(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) / 100
    firstopenrounded                 = round(firstopen * 100) / 100
    highestOCrounded                 = round(highestOC * 100) / 100
    lowestCloserounded               = round(lowestClose * 100) / 100
    auswertungszeitraumJrounded      = 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 Ankerpunkt
    offsethorsp2 = offsethor + 175
    offsetver = 10 * MoveUpDownFaktor      // vertikale Pos. vom Ankerpunkt
    step      = -22                        // Schrittweite vertikale Pos. für verschiedene Zeilen
    zeilen    = 0
    
    Drawtext("AUSWERTUNGZEITRAUM #auswertungszeitraumJrounded#J ab 01 / #StartJahr#",    offsethor+50,  offsetver + zeilen * step, SansSerif, Bold, 15) coloured( 72, 118, 255) anchor  (left)
    
    zeilen = 1.5 + zeilen
    dist = 20
    Drawtext("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 + zeilen
    Drawtext("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 + zeilen
    Drawtext("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 + zeilen
    Drawtext("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 + zeilen
    Drawtext("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 + zeilen
    Drawtext("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 + zeilen
    Drawtext("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 + zeilen
    Drawtext("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 + zeilen
    Drawtext("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 + zeilen
    Drawtext("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 + zeilen
    if not bedopen then
    Drawtext("First Open = Close #highjahr#",  offsethor - 12,  offsetver + zeilen * step,   SansSerif, Bold, 15) coloured(100, 100 , 255) anchor (left)
    else
    Drawtext("First Open = Open #StartJahr#",  offsethor - 12,  offsetver + zeilen * step,   SansSerif, Bold, 15) coloured(100, 100 , 255) anchor (left)
    endif
    Drawtext("#firstopenrounded# Pkte",      offsethorsp2,         offsetver + zeilen * step,   SansSerif, Bold, 15) coloured(100, 100 , 255) anchor (left)
    
    zeilen = 1 + zeilen
    Drawtext("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 + zeilen
    Drawtext("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 + zeilen
    Drawtext("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 + zeilen
    Drawtext("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"
    
    #200260 quote
    Nicolas
    Keymaster
    Master

    I tried but I dont know what values you are using some of your variable settings (see attached).

    Also be sure to have sufficient units displayed in order for your calculation to get values for yearly and monthly timeframes.

    #200271 quote
    jrh_han
    Participant
    New

    Thank you Nicolas – it was the unsufficient number of units displayed. Sorry for inconvenience, I should have found this reason myself.

    Roger

    #207345 quote
    TraderArun
    Participant
    Junior

    Hi

    The below timeframe is not supported

    TIMEFRAME(6 HOUR)

    Is there any alternative way I can run this?

    Thanks

    #207350 quote
    Nicolas
    Keymaster
    Master

    It’s working just fine for indicators programming, are you trying with a screener code?

    #207357 quote
    TraderArun
    Participant
    Junior

    It’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

    #207360 quote
    Nicolas
    Keymaster
    Master

    ProScreener 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).

    TraderArun thanked this post
    #207451 quote
    ArturAgababyan13
    Participant
    New

    Bonjour,

    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 :

    DEFPARAM CUMULATEORDERS = FALSE
    DEFPARAM NoCashUpdate = FALSE
    DEFPARAM MinOrder = 1
    
    //DEFPARAM FlatBefore = 100000
    //DEFPARAM FlatAfter = 180000
    
    MinSize = 10
    AmplitudeMax = 50
    AmplitudeMin = 20
    
    /*==============================================================================================================================*/
    
    // Ecran 1 : définir la tendance de long terme
    TIMEFRAME(Weekly, updateonclose)
    MACDhistogram = MACD[12,26,9](close)
    
    WeeklyC1 = MACDhistogram < 0 AND MACDhistogram[1] < 0
    WeeklyC2 = MACDhistogram > 0 AND MACDhistogram[1] > 0
    WeeklyC3 = 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 LT
    TIMEFRAME(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 < 30
    DailyC2 = DailyRSI > 70
    DailyC3 = DailyAmplitude > AmplitudeMin AND DailyAmplitude < AmplitudeMax
    
    /*==============================================================================================================================*/
    
    // Ecran 3 : Placer les ordres d'achat et de vente
    TIMEFRAME(1 hour, updateonclose)
    // Conditions pour ouvrir une position à l'achat et pour fermer une position d'achat
    OneHourC1 = Close CROSSES OVER Haut
    OneHourC2 = Close CROSSES UNDER DailySAR
    
    // Ouverture position acheteuse
    IF NOT ONMARKET AND (WeeklyC1 OR WeeklyC2) AND WeeklyC3 AND DailyC1 AND DailyC3 AND Close CROSSES OVER Haut THEN
    BUY MinSize CONTRACTS AT MARKET
    ENDIF
    
    // Clôture position acheteuse
    IF LongOnMarket AND OneHourC2 THEN
    SELL AT MARKET
    ENDIF
    
    // Conditions pour ouvrir une position à la vente et pour fermer une position à la vente
    OneHourC3 = Close CROSSES UNDER Bas
    OneHourC4 = Close CROSSES OVER DailySAR
    
    // Ouverture position vendeuse
    IF NOT OnMarket AND (WeeklyC1 OR WeeklyC2) AND WeeklyC4 AND DailyC2 AND DailyC3 AND OneHourC3 THEN
    SELLSHORT MinSize CONTRACTS AT MARKET
    ENDIF
    
    // Clôture position vendeuse
    IF ShortOnMarket AND OneHourC4 THEN
    EXITSHORT AT MARKET
    ENDIF
    
    // STOP LOSS GARANTIE
    SET STOP LOSS DailyAmplitude
    
    IF STRATEGYPROFIT < -200 THEN
    QUIT
    ENDIF
    

    Je 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 !

    #211788 quote
    AMQ
    Participant
    Average

    Hello 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

    #211792 quote
    Nicolas
    Keymaster
    Master

    @AMQ Please open a dedicated topic in the ProOrder section of the forum (please follow the posting rules).

    #211797 quote
    AMQ
    Participant
    Average

    Ok, thanks Nicolas: done and sorry😊.

    #214678 quote
    Davoud.DA
    Participant
    New

    I made three posts here sharing my strategies. I wanted to help my friends, but unfortunately my posts were deleted.

    #214680 quote
    robertogozzi
    Moderator
    Master

    Yes, 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 🙂

    #214681 quote
    robertogozzi
    Moderator
    Master

    Sorry, i meant in the General Trading Discussions Forum.

Viewing 15 posts - 91 through 105 (of 165 total)
  • You must be logged in to reply to this topic.

Multi timeframe – MTF indicators for ProRealTime


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
Nicolas @nicolas Keymaster
Summary

This topic contains 164 replies,
has 53 voices, and was last updated by PeterSt
9 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 05/27/2020
Status: Active
Attachments: 49 files
Logo Logo
Loading...