Double Top bottom

Viewing 15 posts - 1 through 15 (of 16 total)
  • Author
    Posts
  • #214867 quote
    Aragorna
    Participant
    Junior
    
    fractalP = 10 //fractal period
    percent = 0.030 //maximum percent change between the 2 points
    barlimit = 100 //maximum bars between 2 points
    
    //fractals
    cp=fractalP
    if high[cp] >= highest[(cp)*2+1](high) then //new fractal high found
    $TOPy[lastset($TOPy)+1] = high[cp] //store fractal value
    $TOPx[lastset($TOPx)+1] = barindex[cp] //store fractal barindex
    //COND=Summation[fractalP](Close>$topy[i])=1
    endif
    
    if low[cp] <= lowest[(cp)*2+1](low)  then //new fractal low found
    $BOTy[lastset($BOTy)+1] = low[cp] //store fractal value
    $BOTx[lastset($BOTx)+1] = barindex[cp] //stire fractal barindex
    endif
    
    if(islastbarupdate and isset($topy[0]) and isset($boty[0])) then
    //check points in a range of X percent
    for i = 0 to lastset($TOPy) do //loop through the tops
    for y = 0 to lastset($TOPy) do //check first top with other tops
    change=abs(($topy[y]-$topy[i])/$topy[i]) //percent range between the 2 tops
    bardiff=abs($TOPx[i]-$TOPx[y]) //how many bars between the 2 points?
    Dtop= change<=percent/100 and bardiff<barlimit and bardiff>=fractalP and $topx[i]<>$topx[y]
    next
    next
    
    for i = 0 to lastset($BOTy) do //loop through the bottoms
    for y = 0 to lastset($BOTy) do //check first bottom with other bottoms
    change=abs(($boty[y]-$boty[i])/$boty[i]) //percent range between the 2 bottoms
    bardiff=abs($botx[i]-$botx[y]) //how many bars between the 2 points?
    Dbot= change<=percent/100 and bardiff<barlimit and bardiff>=fractalP and $BOTx[i]<>$BOTx[y]
    next
    next
    endif
    
    if not LONGONMARKET and Dbot then
    buy 1 shares AT MARKET
    ENDIF
    Set Stop loss 30
    Set Target profit 60

    hello to all, I’ve got a simple request. I’m studying the double top-bottom made by Nicolas, I’m trying to make a strategy, just for study. I’d like to go long when  the second bottom at the condition Dbot) is identified, and go short when the second top is identifed. Strategy I’ve tryed does not give any result. can someone give me a tip? thank’0s in advance

    Alessio

    #214876 quote
    GraHal
    Participant
    Master

    Strategy I’ve tryed does not give any result

    No result in backtest or in Live trading?

    What Instrument, TF are you testing on?

    #214879 quote
    GraHal
    Participant
    Master

    I can comfirm that the above code does run on Daily TF on DJI, but results in zero trades.

    Please can you provide a link to the source of the above code? I have searched the Library with no success.

    #214884 quote
    JS
    Participant
    Senior

    Hi GraHal,

    It’s example 6 from the array examples…
    This indicator was not set up as a trading system but perhaps it is possible to turn it into a trading system…

    GraHal thanked this post
    #214885 quote
    Aragorna
    Participant
    Junior

    Hi Grahal, did you find it? code is a little modified but it’s the same in the end. if you load the indicator, you can set it as it’s set in the strategy. I cannot explain why that condition does not work, I’ve graphed it and condition never shows.

    #214887 quote
    GraHal
    Participant
    Master

    I’ve graphed it and condition never shows.

    My conclusion (maybe wrongly?) was that the coincident conditions (x AND y AND z etc) do not occur coincident with each other?

    Also it is frustrating Algo to play with (for me) as, on less than Daily TF, it takes ages to run / optimise etc?

    #214889 quote
    Aragorna
    Participant
    Junior

    conditions occur in the indicator, they have to occur in the strategy as well, I guess. you can test with less candles.

    #214891 quote
    Aragorna
    Participant
    Junior

    maybe Nicolas or Robertogozzi could help us?

    #214892 quote
    GraHal
    Participant
    Master

    I guess. you can test with less candles.

    I was down to 1k bars, but I still lost interest as it took so long … due to the arrays I would think?

    #214894 quote
    Aragorna
    Participant
    Junior

    it doesn’t take so long for me, perhaps your personal computer isn’t powerful enough?

    #214895 quote
    GraHal
    Participant
    Master

    It was quick on Daily but no results so I was trying 1 hour and 5 mins etc and optimising the variables … then it seemd like it had stalled! 🙂

    Optimisation is executed remotely on the PRT servers, our PC do very little so we don’t need super fast PC.

    #215015 quote
    Aragorna
    Participant
    Junior

    It’s a pity that no one can help to understand. It could have a big potential.

    #215019 quote
    GraHal
    Participant
    Master

    Do you understand arrays enough to manipulate the code for better results? Are you able to state exactly what you want to be changed in the code you posted?

    I think there are very few on here who can code arrays successfully?

    Maybe choose a simpler Algo and start a separate Thread?

    #215024 quote
    PeterSt
    Participant
    Master

    FWIW :

    I tried the original code (it is an Indicator), and this works (as indicator indeed). But there it stops because it is wayyyyyy too slow to be workable.
    Copying the code into the program itself does not help, except for that you can see that it won’t trade indeed. This is most probably because the trade points – as shown by the indicator – don’t fall on the bar-ends (the close of them)  so while there would exist a moment that this coincides, in practice you can’t find his because 1000 bars already take 15 minutes to backtest over here and in these 1K bars (of 1 minute) the situation does not occur or it is too tedious to try a few things.

    The solution, in my view, would be to enumerate the arrays one time per backtest (Optimization Parameters combination), so all the array-filling work can be done one time only, instead of 1000 times for testing over 1000 bars (or 200,000 times for 200K bars). But there it stopped to be funny, and I quit this case.

    I did not make screenshots, but they would tell that for the intention of this indicator – trade on the 2nd top etc. – it requires refinement. Read : there would be too many false alarms because the shapes / fractals are not always caught correctly. On the other hand, notice that Nicolas  just used this for a rough “arrays” example, which was a nice job to begin with.

    Now if someone could cause that arrays are being dealt with smarter by PRT (like 10,000 times more efficient), “we” could all try to work on the improvement of such a really working DT/DB indicator. This one really has a good base (says me 😉 ).

    GraHal thanked this post
    #215026 quote
    Aragorna
    Participant
    Junior

    I understand how to manipulate arrays and also create new ones in other indicators. What I do not understand is how to use in a strategy because what I think is correct in conditions of buy and sell does not  work

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

Double Top bottom


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Aragorna @aragorna Participant
Summary

This topic contains 15 replies,
has 4 voices, and was last updated by JS
2 years, 9 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 05/18/2023
Status: Active
Attachments: No files
Logo Logo
Loading...