Double bottom or double top

Viewing 15 posts - 16 through 30 (of 48 total)
  • Author
    Posts
  • #50073 quote
    ramarama
    Participant
    Senior

    Thanks for your replies , to test the code I need to add buy and sell condition.

    the code is for returning the values

     

    how to add to this buy and sell condintons

    example

    buy 1 perpoint at support stop

    sellsshort 1 perpoint at resistance stop

    #50096 quote
    AbzAbz
    Participant
    Veteran

    Leo how will put this indicator into a automated system , buy on arrow up and sell on arrow down?

    #50157 quote
    LeoLeo
    Participant
    Veteran

    Yes, right Nicolas! another way can be with a slope of a triangle between two maximums/minimus

    If we learn to analyse the history of the locals minimums and locals maximum, then we can detects not only doble top/bottoms but channels, triangles, even head and shoulders!!!

    And getting an issue that some minimums and maximum in certain cases are duplicated therefore cause a false signals of doble bottoms/top… anyway there is a lot work to do.

    #50158 quote
    LeoLeo
    Participant
    Veteran

    Leo how will put this indicator into a automated system , buy on arrow up and sell on arrow down?

    No, we have the study how the arrows behave and get a profitable robot! 🙂

    #50259 quote
    LeoLeo
    Participant
    Veteran

    Hi all,

    Here my first approximation… I feel very optimistic about this approach although there is a lot work to do (that’s why there is not algorithm to detects double bottom/tops yet )

    Please see the picture attached, the triangle is draw by the algorithm here:

    //LOCALS MINIMUMS AND MAXIMUMS
    
    Kdouble=0.1 //Factor for defining what is double top or bottom
    
    //Leo Moving Average, formula: LMA= WMA+(WMA-SMA)
    LMA=2*weightedaverage[period](close)-average[period](close)
    
    //Smoothed curve of Leo Moving Average
    IF BARINDEX > period THEN
    smoothLMA=weightedaverage[period](LMA)
    ELSE
    smoothLMA=undefined
    ENDIF
    
    // << Storage of minimums and maximums >>
    once mintemp=low
    once posmintemp=1
    once maxtemp=high
    once posmaxtemp=1
    
    IF BARINDEX>1 THEN
    // the value 0.75 is to ensure that the donchian channel is faster than the curves analysis (this value to be checked)
    IF low < lowest[round(0.75*period)](low[1]) THEN
    mintemp=low //minimum temporal
    posmintemp=BARINDEX //postition of minimum temporal
    ENDIF
    IF high > highest[round(0.75*period)](high[1]) then
    maxtemp=high //maximum temporal
    posmaxtemp=BARINDEX //position maximum temporal
    ENDIF
    ENDIF
    
    //  << Detecting and locating a local minimums >>
    //  Where the LMA is crossing the smoothed LMA, there is a maximum or minimum nearby
    //  If there is a new local min/max, the preivus one is stored in de varible B... (before)
    once LEVMIN=low
    once POSLEVMIN=1
    once LEVMAX=high
    once POSLEVMAX=1
    
    IF LMA crosses over smoothLMA THEN
    BLEVMIN=LEVMIN        //previus local minimum is saved
    BPOSLEVMIN=POSLEVMIN
    LEVMIN=mintemp
    POSLEVMIN=posmintemp
    support=LEVMIN
    DRAWARROWUP(POSLEVMIN,LEVMIN) coloured(0,0,0,30)
    ENDIF
    
    // --> Detecting and locating a local maximum
    IF LMA crosses under smoothLMA THEN
    BLEVMAX=LEVMAX       //previus local maximum is saved
    BPOSLEVMAX=POSLEVMAX
    LEVMAX=maxtemp
    POSLEVMAX=posmaxtemp
    resistance=LEVMAX
    DRAWARROWDOWN(POSLEVMAX,LEVMAX) coloured(0,0,0,30)
    ENDIF
    
    support=min(low,support)
    resistance=max(high,resistance)
    
    
    // << DETECTING DOUBLE TOP OR BOTTOMS  >>
    
    once WidthDoubleTop = high-low
    once WidthDoubleBottom = high-low
    
    //--> Double bottoms
    IF LMA crosses over smoothLMA THEN
    WidthDoubleBottom = LEVMAX-(BLEVMIN+LEVMIN)/2 // local max minus average of the las two local min
    IF abs(BLEVMIN-LEVMIN) < Kdouble*WidthDoubleBottom THEN
    DRAWTRIANGLE(POSLEVMIN,LEVMIN,POSLEVMAX,LEVMAX,BPOSLEVMIN,BLEVMIN) COLOURED(0,255,0,200)
    ENDIF
    ENDIF
    //--> Double tops
    IF LMA crosses under smoothLMA THEN
    WidthDoubleTop=(BLEVMAX+LEVMAX)/2 -LEVMIN
    IF abs(BLEVMAX-LEVMAX) < Kdouble*WidthDoubleTop THEN
    DRAWTRIANGLE(POSLEVMIN,LEVMIN,POSLEVMAX,LEVMAX,BPOSLEVMAX,BLEVMAX) COLOURED(255,0,0,200)
    ENDIF
    ENDIF
    
    RETURN LMA AS "LMA", support as "support", resistance as "resistance", smoothLMA as "smooth LMA" //, lowest[round(0.75*period)](low[1]), highest[round(0.75*period)](high[1])
    
    Abz and Ste thanked this post
    Screen-Shot-2017-10-22-at-22.03.40.png Screen-Shot-2017-10-22-at-22.03.40.png
    #50274 quote
    MadrosatMadrosat
    Participant
    Master

    Good morning

    good work Leo
    how can I spot and use the arrows in automatic trading

    #50276 quote
    ramarama
    Participant
    Senior

    Hi Leo

    your code is for screen return

    my coding knowledge is poor add a buy condition and sell condition by removing screen retrun

    can you advice me

    where to add and how to add

    x=5

    buy 1 perpoint at resistance+x stop

    sellshort 1 perpoint at support -x stop

     

    I will change the other conditions after back testing. x=5 and buy condition etc are example only

    after back testing I will post my results

    #50317 quote
    AbzAbz
    Participant
    Veteran

    Leo i tested the first version and i saw that the arrows appears sometimes on the 2-3 previous candle. is this something that you have seen?

    #50343 quote
    LeoLeo
    Participant
    Veteran

    Hi all,

    Madrosat, so far I am developing an algorithm for detecting double top or bottoms. For trading is more or less what Rama says: instead of drawing a triangle, it will be the executing order or a boleean or whatever.

    Rama, right now I do not know how is the executed a trade, the theory is (for long)

    – entry above the resistance

    – stop loss below the support

    – stop profit at a distance of Resistance – support i.e. a trade with profit/risk ratio of one

    … that’s the theory maybe we can entry on the market earlier and take more profit

    Abz, odd that error. What I notice is that some arrows are duplicated ( or repeated), try my last version, please and tell us if it is better.

    #50419 quote
    LeoLeo
    Participant
    Veteran

    Hey,

    I made an algorithm for detecting double top and double bottoms and is working so awesome and I feel so proud of it that I put it in the library as an indicator. Have a look to it when @Nicolas validate it for posting… and please give it a like or comment it, I want to improve my ranking in this forum  🙂

    I think my algo is promising and I hope we work together for make the proper modification for automatic trading.

    mamio thanked this post
    #50520 quote
    swappingswapping
    Participant
    Master

    Hello Leo, very good algorithm

    Tested today and very efficient for visual technical analyse at different frame; Also coupled with LMA is cool

    Thank you (sorry for my english)

    #50521 quote
    NicolasNicolas
    Keymaster
    Legend

    Hey Leo, you made a great job with your approach on these particular patterns, a big thumb up for you 🙂

    #50535 quote
    LeoLeo
    Participant
    Veteran

    Thanks, those message encourage me for continuing my endeavour.

    Here is my detector:

    https://www.prorealcode.com/prorealtime-indicators/double-top-double-bottom-detector/

    Now we have to found a clever way to employ that detector…

    #50606 quote
    MadrosatMadrosat
    Participant
    Master

    Abz as write : Leo i tested the first version and i saw that the arrows appears sometimes on the 2-3 previous candle. is this something that you have seen?

     

    I think arrows are repainting is true Léo??

    Madrosat

    #50635 quote
    LeoLeo
    Participant
    Veteran

    Hi Madrosat,

    around line 20 of the code,  says:

    // the value 0.75 is to ensure that the donchian channel is faster than the curves analysis (this value to be checked)

    I thought this solve the issue, but no…. hope we find another way no repeating the arrows (I.e duplicating the information of a local maximum or minimum)

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

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

Double bottom or double top


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
rama @rama Participant
Summary

This topic contains 47 replies,
has 1 voice, and was last updated by steve_steve_
5 years, 5 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 05/15/2017
Status: Active
Attachments: 7 files
ProRealCode ProRealCode
Loading...