PP Fractals // Error message

Viewing 14 posts - 16 through 29 (of 29 total)
  • Author
    Posts
  • #189023 quote
    Khaled
    Participant
    Veteran

    Peter, As i mentioned above (#189007) the original code generates a profit VS the code modified by Nicolas generates a loss. So, there is something in this PP Fractals code that plays a role of filter beyond the graphing.

    #189024 quote
    PeterSt
    Participant
    Master

    what @Nicolas is saying. So to me it now seems that he (from his own code ever back ?) tells that the arrays were only there for graphing, while you don’t graph anything. So just eliminate the code concerned (?).

    Which is exactly what he has done for you (I checked and understand it now). So the challenge is : why is the result not the same.
    Probably because the approach with the array failed ? or the arrays themselves fail ? (it really is too easy to make mistakes, the way PRT set them up).

    image_2022-02-28_122756.png image_2022-02-28_122756.png
    #189029 quote
    Khaled
    Participant
    Veteran

    I’m not putting in doubt what Nicolas has done. However, I see (as you see it in your backtest) there is a big difference between with and without.

    Do you mean that there might be something wrong in the calculation of the Arrays that generates “fake” Profits? It’s very likely. May be the solution/answer is with Vonasi the author of the original code 🙂

    #189030 quote
    GraHal
    Participant
    Master

    May be the solution/answer is with Vonasi the author of the original code

    For info … we’ve not seen Vonasi hereabouts for 9 months or so!

    Khaled thanked this post
    #189032 quote
    PeterSt
    Participant
    Master

    I think the problem lies in this part :

    LongConso = long=1 and close > $resistancevalue[z]
    ShortConso = short=-1 and close < $supportvalue[z]
    

    My “coder hunch” tells me that z is eliminated from the new code, while z is (was) necessary for this part. So it is not about a and b, but this z. I can’t see quickly how to change that – hopefully @Nicolas can.
    And maybe I am wrong. But both codes really are 100% the same, except for the part which is commented out (and the new usage of resistancevalue ans supportvalue).

    Khaled thanked this post
    #189033 quote
    PeterSt
    Participant
    Master

    For info … we’ve not seen Vonasi hereabouts for 9 months or so!

    umd followed him. If you know what I mean … (and if not then too bad).

    #189034 quote
    Khaled
    Participant
    Veteran

    I see exactly what you mean 🙂 🙂 🙂

    PeterSt thanked this post
    #189038 quote
    PeterSt
    Participant
    Master

    Something else (not), we should not forget that something *is* wrong somewhere with the arrays approach. And avoiding their purpose (the graphing) is not really the very best idea.

    Without the arrays, this error still occurs for the 1M backtest. I will report it, then together with nontheless’s report (elsewhere) they may see commonalities.

    image_2022-02-28_125714.png image_2022-02-28_125714.png image_2022-02-28_130312.png image_2022-02-28_130312.png
    #189042 quote
    Nicolas
    Keymaster
    Master

    Problem is that the array can increment 12 times per hour, so the 1 million column of  the array could be reach pretty fast, please try the new version below:

    DEFPARAM CUMULATEORDERS = FALSE
    TIMEFRAME(60 minutes,updateonclose)
    a=a+1
    b=b+1
    
    TIMEFRAME(60 minutes)
    LongConso=0
    ShortConso= 0
    Long=0
    Short=0
    
    
    
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //PRC_SwingLine Ron Black | indicator by Nicolas
    if upsw=1 then
    if high>hH then
    hH=high
    endif
    if low>hL then
    hL=low
    endif
    if high<hL then
    upsw=0
    lL=low
    lH=high
    endif
    endif
    
    if upsw=0 then
    if low<lL then
    lL=low
    endif
    if high<lH then
    lH=high
    endif
    if low>lH then
    upsw=1
    hH=high
    hL=low
    endif
    endif
    
    
    if upsw=1 then
    swingline=hL
    else
    swingline=lH
    endif
    
    
    if close>open then
    iRange = abs(close-open)
    elsif close<open then
    iRange = abs(open-close)
    endif
    
    if close>open then
    UpWick = high - close
    LoWick = open-low
    elsif close<open then
    UpWick = high-open
    LoWick = close-low
    endif
    
    
    // LONG
    if close>open then
    if close[1]>open[1] then
    if close>close[1] then
    long1=1
    endif
    endif
    endif
    if close>open then
    if close[1]<open[1] then
    if close>open[1] then
    long2=1
    endif
    endif
    endif
    
    
    if iRange>UpWick or LoWick>UpWick then
    long3 = 1
    endif
    
    
    //if close>close[1] and close[2]>close[1] then
    //long4 = 1
    //endif
    
    
    if high>high[1] or low>low[1] then
    long5=1
    endif
    
    
    if (long1 or long2) and long3 and long5 and close>swingline then
    Long=1
    endif
    
    
    // SHORT
    if close<open then
    if close[1]>open[1] then
    if close<open[1] then
    short1=1
    endif
    endif
    endif
    
    if close<open then
    if close[1]<open[1] then
    if close<close[1] then
    short2=1
    endif
    endif
    endif
    
    
    if iRange>LoWick or LoWick<UpWick then
    short3 = 1
    endif
    
    //if close<close[1] and close[2]<close[1] then
    //short4 = 1
    //endif
    
    if high<high[1] or low<low[1] then
    short5=1
    endif
    
    if (Short1 or short2) and short3 and short5 and close<swingline then
    Short=-1
    endif
    
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // SR PP Fractal Lines by Vonasi
    
    //BarsBefore = 1
    //BarsAfter = 1
    Support = 1
    Resistance = 1
    Points = 1
    
    //Make sure all settings are valid ones
    BarsBefore = max(BarsBefore,1)
    BarsAfter = max(BarsAfter,1)
    StartBack = max(0,startback)
    
    if barindex >= barsbefore + barsafter then
    
    //Look for a low fractal
    BarLookBack  = BarsAfter + 1
    if low[BarsAfter] < lowest[BarsBefore](low)[BarLookBack] THEN
    if low[BarsAfter] = lowest[BarLookBack](low) THEN
    //if barindex[barsafter]<>$supportbar[a] then//a<99999 then
    //a = a + 1
    //endif
    $supportbar[a] = barindex[barsafter]
    $supportvalue[a] = low[barsafter]
    endif
    endif
    
    //Look for a high fractal
    if high[BarsAfter] > highest[BarsBefore](high)[BarLookBack] THEN
    if high[BarsAfter] = highest[BarLookBack](high) THEN
    //if barindex[barsafter]<>$resistancebar[b] then
    //b = b + 1
    //endif
    $resistancebar[b] = barindex[barsafter]
    $resistancevalue[b] = high[barsafter]
    endif
    endif
    
    if islastbarupdate then
    //support line
    if a >= 2 then
    if support then
    flag = 0
    zz = 0
    for z = a-zz downto 1
    for xx = 1 to a
    if z-xx < 1 then
    break
    endif
    if $supportvalue[z] > $supportvalue[z-xx] then
    if points then
    endif
    flag = 1
    break
    endif
    if zz<99999 then
    zz = zz + 1
    endif
    next
    if flag = 1 then
    break
    endif
    zz = 0
    next
    endif
    endif
    
    //resistance line
    if b >= 2 then
    if resistance then
    flag = 0
    zz = 0
    for z = b-zz downto 1
    for xx = 1 to b
    if z-xx < 1 then
    break
    endif
    if $resistancevalue[z] < $resistancevalue[z-xx] then
    if points then
    endif
    flag = 1
    break
    endif
    if zz<99999 then
    zz = zz + 1
    endif
    next
    if flag = 1 then
    break
    endif
    zz = 0
    next
    endif
    endif
    endif
    endif
    
    
    
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    LongConso = long=1 and close > $resistancevalue[z]
    ShortConso = short=-1 and close < $supportvalue[z]
    
    
    
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    TIMEFRAME(5 minutes, UPDATEONCLOSE)
    
    nLots = min(10,round((2000+STRATEGYPROFIT)/(close*.5*.1),1))
    
    IF NOT LongOnMarket AND LongConso THEN
    BUY nLots CONTRACTS AT MARKET
    ENDIF
    IF NOT ShortOnMarket AND ShortConso THEN
    SELLSHORT nLots CONTRACTS AT MARKET
    ENDIF
    
    
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    If LongOnMarket AND ShortConso THEN
    SELL AT MARKET
    SELLSHORT nLots CONTRACTS AT MARKET
    ENDIF
    
    IF ShortOnMarket AND LongConso THEN
    EXITSHORT AT MARKET
    BUY nLots CONTRACTS AT MARKET
    ENDIF
    
    
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    TIMEFRAME(1 minute)
    SET STOP %LOSS .3 //SL
    SET TARGET %PROFIT 1.6 //TP
    #189046 quote
    Khaled
    Participant
    Veteran

    Thank you very much Nicolas!!! I left home, so I’ve no access to my PRT now. I’ll test it later today and let you know.

     

    Basically, what I’m trying to acheive is a Strategy that works without any time-based indicator for Entry Signals (no MA, no RSI, etc.), only price, price and price. I found the Swing Line that you shared in another post quite effective with (UPDATEONCLOSE) and TF>H1, but I need to add more filters like Breakout of Trendlines.

    May be we can do that without Arrays?

    #189051 quote
    PeterSt
    Participant
    Master

    Thank you for your help, @Nicolas.
    The result is unchanged, but more importantly, this is not workable because of slowness and *that* tells me that something with the array-accesses is not correct (asking for an undefined element will trigger the error-trap under the hood and this is ultimately slow). The 100K takes 20 minutes to calculate. This was not so at all with the earlier version from Khaled (using arrays).

    I am only the messenger. 😐

    Khaled thanked this post
    image_2022-02-28_145310.png image_2022-02-28_145310.png image_2022-02-28_152307.png image_2022-02-28_152307.png
    #189054 quote
    Khaled
    Participant
    Veteran

    Dear Trading Companions 🙂

    First, please let me thank you for all the help and time you have spent trying to help. Obviously, this is more about the learning journey than the immediate end result in itself.

    Second, the 2nd code reworked by Nicolas didn’t work LIVE. I had again and again the same error of 1,000,000 rows.

    Third and happily, I managed to replace the PP Fractals code by another code from Vonasi called Fractals Average https://www.prorealcode.com/prorealtime-indicators/fractals-average/, where I replaced the two trigger variables with “MidAvg”. I got results not far away and it is live now as we speak. Let’s how it behaves over the afternoon.

    I’ll keep you posted.

    If anyone thinks of a piece of code somewhere on this forum which uses only price for Trend, Breakout, etc., please let me know. I defenitly want to build a system without any time-based indicators (MA, RSI, etc.).

    Again, thank you for your support. I feel blessed.

    #189064 quote
    Nicolas
    Keymaster
    Master

    New try (I did not compare tjhe result with initial version)

    DEFPARAM CUMULATEORDERS = FALSE
    TIMEFRAME(60 minutes)
    LongConso=0
    ShortConso= 0
    Long=0
    Short=0
    once $lastbarindexa[0]=barindex
    once $lastbarindexb[0]=barindex
    
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //PRC_SwingLine Ron Black | indicator by Nicolas
    if upsw=1 then
    if high>hH then
    hH=high
    endif
    if low>hL then
    hL=low
    endif
    if high<hL then
    upsw=0
    lL=low
    lH=high
    endif
    endif
    
    if upsw=0 then
    if low<lL then
    lL=low
    endif
    if high<lH then
    lH=high
    endif
    if low>lH then
    upsw=1
    hH=high
    hL=low
    endif
    endif
    
    
    if upsw=1 then
    swingline=hL
    else
    swingline=lH
    endif
    
    
    if close>open then
    iRange = abs(close-open)
    elsif close<open then
    iRange = abs(open-close)
    endif
    
    if close>open then
    UpWick = high - close
    LoWick = open-low
    elsif close<open then
    UpWick = high-open
    LoWick = close-low
    endif
    
    
    // LONG
    if close>open then
    if close[1]>open[1] then
    if close>close[1] then
    long1=1
    endif
    endif
    endif
    if close>open then
    if close[1]<open[1] then
    if close>open[1] then
    long2=1
    endif
    endif
    endif
    
    
    if iRange>UpWick or LoWick>UpWick then
    long3 = 1
    endif
    
    
    //if close>close[1] and close[2]>close[1] then
    //long4 = 1
    //endif
    
    
    if high>high[1] or low>low[1] then
    long5=1
    endif
    
    
    if (long1 or long2) and long3 and long5 and close>swingline then
    Long=1
    endif
    
    
    // SHORT
    if close<open then
    if close[1]>open[1] then
    if close<open[1] then
    short1=1
    endif
    endif
    endif
    
    if close<open then
    if close[1]<open[1] then
    if close<close[1] then
    short2=1
    endif
    endif
    endif
    
    
    if iRange>LoWick or LoWick<UpWick then
    short3 = 1
    endif
    
    //if close<close[1] and close[2]<close[1] then
    //short4 = 1
    //endif
    
    if high<high[1] or low<low[1] then
    short5=1
    endif
    
    if (Short1 or short2) and short3 and short5 and close<swingline then
    Short=-1
    endif
    
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // SR PP Fractal Lines by Vonasi
    
    //BarsBefore = 1
    //BarsAfter = 1
    Support = 1
    Resistance = 1
    Points = 1
    
    //Make sure all settings are valid ones
    BarsBefore = max(BarsBefore,1)
    BarsAfter = max(BarsAfter,1)
    StartBack = max(0,startback)
    
    if barindex >= barsbefore + barsafter then
    
    //Look for a low fractal
    BarLookBack  = BarsAfter + 1
    if low[BarsAfter] < lowest[BarsBefore](low)[BarLookBack] THEN
    if low[BarsAfter] = lowest[BarLookBack](low) THEN
    //if barindex[barsafter]<>$supportbar[a] then//a<99999 then
    //a = a + 1
    //endif
    if barindex>$lastbarindexa[0] then 
    a=a+1
    $lastbarindexa[0]=barindex
    endif
    $supportbar[a] = barindex[barsafter]
    $supportvalue[a] = low[barsafter]
    endif
    endif
    
    //Look for a high fractal
    if high[BarsAfter] > highest[BarsBefore](high)[BarLookBack] THEN
    if high[BarsAfter] = highest[BarLookBack](high) THEN
    //if barindex[barsafter]<>$resistancebar[b] then
    //b = b + 1
    //endif
    if barindex>$lastbarindexb[0] then
    b=b+1
    $lastbarindexb[0]=barindex
    endif
    $resistancebar[b] = barindex[barsafter]
    $resistancevalue[b] = high[barsafter]
    endif
    endif
    
    if islastbarupdate then
    //support line
    if a >= 2 then
    if support then
    flag = 0
    zz = 0
    for z = a-zz downto 1
    for xx = 1 to a
    if z-xx < 1 then
    break
    endif
    if $supportvalue[z] > $supportvalue[z-xx] then
    if points then
    endif
    flag = 1
    break
    endif
    if zz<99999 then
    zz = zz + 1
    endif
    next
    if flag = 1 then
    break
    endif
    zz = 0
    next
    endif
    endif
    
    //resistance line
    if b >= 2 then
    if resistance then
    flag = 0
    zz = 0
    for z = b-zz downto 1
    for xx = 1 to b
    if z-xx < 1 then
    break
    endif
    if $resistancevalue[z] < $resistancevalue[z-xx] then
    if points then
    endif
    flag = 1
    break
    endif
    if zz<99999 then
    zz = zz + 1
    endif
    next
    if flag = 1 then
    break
    endif
    zz = 0
    next
    endif
    endif
    endif
    endif
    
    
    
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    LongConso = long=1 and close > $resistancevalue[z]
    ShortConso = short=-1 and close < $supportvalue[z]
    
    
    
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    TIMEFRAME(5 minutes, UPDATEONCLOSE)
    
    nLots = min(10,round((2000+STRATEGYPROFIT)/(close*.5*.1),1))
    
    IF NOT LongOnMarket AND LongConso THEN
    BUY nLots CONTRACTS AT MARKET
    ENDIF
    IF NOT ShortOnMarket AND ShortConso THEN
    SELLSHORT nLots CONTRACTS AT MARKET
    ENDIF
    
    
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    If LongOnMarket AND ShortConso THEN
    SELL AT MARKET
    SELLSHORT nLots CONTRACTS AT MARKET
    ENDIF
    
    IF ShortOnMarket AND LongConso THEN
    EXITSHORT AT MARKET
    BUY nLots CONTRACTS AT MARKET
    ENDIF
    
    
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    TIMEFRAME(1 minute)
    SET STOP %LOSS .3 //SL
    SET TARGET %PROFIT 1.6 //TP
    Khaled thanked this post
    #189075 quote
    PeterSt
    Participant
    Master

    It is normally fast again.
    The results are not like the original (at all).

    Khaled thanked this post
    image_2022-02-28_171918.png image_2022-02-28_171918.png
Viewing 14 posts - 16 through 29 (of 29 total)
  • You must be logged in to reply to this topic.

PP Fractals // Error message


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Khaled @khaled Participant
Summary

This topic contains 28 replies,
has 4 voices, and was last updated by PeterSt
3 years, 11 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 02/28/2022
Status: Active
Attachments: 15 files
Logo Logo
Loading...