Transformer un iindicateur complexe en screener

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #169212 quote
    steve_
    Participant
    New

    Hello,

    Je me suis mis récemment à Prorealcode et en fouinant dans la bibliothèque, j’ai découvert cet indicateur qui date un peu mais semble donner des signaux d’achat potentiellement intéressants (merci Léo!).

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

    NB: le screener associé fourni par Léo ne donne pas du tout les mêmes signaux… 🙁

    J’essaie de transformer l’indicateur en screener et le résultat n’est pas très concluant (je m’y prends sûrement mal!).

    1- Serait-il possible de détecter chaque soir les valeurs (actions, ETF…) pour lesquelles l’indicateur a dessiné une flèche ascendante pour la dernière séance de cotation ?

    2- Serait-il possible de détecter chaque soir les valeurs (actions, ETF…) pour lesquelles l’indicateur a dessiné une flèche ascendante lors d’une des x  dernières séances de cotation ? (x, variable en paramètre)

    J’ai mis en commentaire les instructions de dessin et au lieu de dessiner une flèche “up”, j’initialise une varaible “CondBuyOk=1” que je passe au screener.

    Ca marche pôôô. 🙁

    Je n’ai pas le résultat attendu.

    Voici ci-dessous mon essai de screener…

    Merci par avance à toute personne pouvant m’aider.

    Je ne demande pas forcément que l’on me donne le poisson tout cuit, je suis prêt à apprendre à le pêcher mais il me faut quelques pistes ! 😉

    (un tuto du genre “Comment transformer un indicateur complexe en screener”)  🙂

    Bon, si un expert a la solution en 10 minutes, je suis preneur, ça me permettra de dormir un peu plus ! :))

    @+

    Steve

    //LOCALS MINIMUMS AND MAXIMUMS USING LEO MOVING AVERAGE
    //Autor: LEO
    
    //VARIABLES TO BE OPTIMIZED
    
    PERIOD=20    //Period for analysis
    Kdouble=0.2 //Factor for defining what is double top or bottom
    
    //-----------
    CondBuyOK=0
    //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=10
    once posmintemp=1
    once maxtemp=high
    once posmaxtemp=1
    
    IF BARINDEX>2 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
    once bullcross=0
    once bearcross=0
    
    IF BARINDEX > PERIOD THEN //For avoid computer errors
    bullcross=LMA crosses over smoothLMA
    bearcross=LMA crosses under smoothLMA
    ENDIF
    
    
    IF bullcross THEN
    BLEVMIN=LEVMIN        //previus local minimum is saved
    BPOSLEVMIN=POSLEVMIN
    LEVMIN=mintemp
    POSLEVMIN=posmintemp
    support=LEVMIN
    //DRAWARROWUP(POSLEVMIN,LEVMIN) coloured(0,0,0,30)
    //DRAWARROWUP(POSLEVMIN,LEVMIN) coloured(85,255,0)
    CondBuyOK=1
    ENDIF
    
    // --> Detecting and locating a local maximum
    IF bearcross THEN
    BLEVMAX=LEVMAX       //previus local maximum is saved
    BPOSLEVMAX=POSLEVMAX
    LEVMAX=maxtemp
    POSLEVMAX=posmaxtemp
    resistance=LEVMAX
    //DRAWARROWDOWN(POSLEVMAX,LEVMAX) coloured(0,0,0,30)
    //DRAWARROWDOWN(POSLEVMAX,LEVMAX) coloured(255,85,0)
    ENDIF
    
    support=min(low,support)
    resistance=max(high,resistance)
    
    
    // << DETECTING DOUBLE TOP OR BOTTOMS  >>
    
    once WidthDoubleTop = high-low
    once WidthDoubleBottom = high-low
    
    //--> Double bottoms
    
    //looking for the top between two local minimums
    IF bullcross THEN
    doublebottomtop=high[BARINDEX-POSLEVMIN+1] // we start looking for the top in between two local minimums
    //POSdoublebottomtop=BARINDEX-POSLEVMIN+1
    FOR i = (BARINDEX-POSLEVMIN+1) to (BARINDEX-BPOSLEVMIN-1) DO
    IF high[i] > doublebottomtop THEN
    doublebottomtop=high[i]
    //POSdoublebottomtop=BARINDEX-i
    ENDIF
    NEXT
    WidthDoubleBottom = doublebottomtop-(BLEVMIN+LEVMIN)/2 // (top betwen local minimums) - (average of the las two local minimums)
    IF abs(BLEVMIN-LEVMIN) < Kdouble*WidthDoubleBottom THEN
    //       <<<<<<<  HERE WE HAVE A DOUBLE BOTTOM FOR TRADING  >>>>>
    //DRAWTRIANGLE(POSLEVMIN,LEVMIN,POSdoublebottomtop,doublebottomtop,BPOSLEVMIN,BLEVMIN) COLOURED(0,255,0,200)
    ENDIF
    ENDIF
    
    //--> Double tops
    
    //looking for the bottom between two local maximums
    IF bearcross THEN
    doubletopbottom=low[BARINDEX-POSLEVMAX+1]
    //POSdoubletopbottom=BARINDEX-POSLEVMAX+1
    FOR i = (BARINDEX-POSLEVMAX+1) to (BARINDEX-BPOSLEVMAX-1) DO
    IF low[i] < doubletopbottom THEN
    doubletopbottom=low[i]
    //POSdoubletopbottom=BARINDEX-i
    ENDIF
    NEXT
    WidthDoubleTop=(BLEVMAX+LEVMAX)/2 -doubletopbottom
    IF abs(BLEVMAX-LEVMAX) < Kdouble*WidthDoubleTop THEN
    //       <<<<<<<  HERE WE HAVE A DOUBLE TOP FOR TRADING  >>>>>
    //DRAWTRIANGLE(POSdoubletopbottom,doubletopbottom,POSLEVMAX,LEVMAX,BPOSLEVMAX,BLEVMAX) COLOURED(255,0,0,200)
    ENDIF
    ENDIF
    SCREENER [CondBuyOk]
    
    //RETURN LMA AS "Leo Moving Average", support as "support", resistance as "resistance", smoothLMA as "smooth LMA" //, lowest[round(0.75*period)](low[1]), highest[round(0.75*period)](high[1])
    
    #169234 quote
    JC_Bywan
    Moderator
    Master

    Salut, le meilleur moyen de débugguer un screener (même s’il vient d’un indicateur) c’est de visualiser les conditions dans… un indicateur.

    Quand il screen tu ne vois pas ce qu’il fait, tu vois juste une liste, et en plus s’y superpose le risque de l’erreur humaine dans l’interprétation de la justesse de la liste. Alors qu’en visualisant les conditions, tu empêches le doute au contraire tu crées des indices, qui l’un après l’autre permettent de tirer sur le fil des indices jusqu’à que ça marche.

    Donc d’abord: visualiser en indicateur condbuyok= 0 ou 1, puis (ou en même temps) visualiser en return ce qui joue dans condbuyok càd apparemment bullcross (qui permet d’entrer dans le if ou pas qui met condbuyok à vrai), s’il y a des anomalies avec bullcross, visualiser ce qui fait bouger bullcross (apparemment lma et smoothlma) etc…

    C’est le genre d’approche “apprendre à pêcher” que tu as demandé, et qui permet de débugguer, comme mise en place dans ce topic qui a permis à l’auteur de résoudre un bug après l’autre: https://www.prorealcode.com/topic/screener-indicateurs-multiples/

    #169352 quote
    steve_
    Participant
    New

    Hello Noobywan,

    J’ai suivi tes bons conseils et le résultat obtenu me laisse perplexe (cf. PJ 01).

    Actions effectuées:

    – duplication de l’indicateur d’origine (auteur Léo)

    – en début de script ajout de “CondBuyOk=0”

    – ajout de “CondBuyOk=1” juste avant de dessiner le flèche verte montante

    IF bullcross THEN
      ...
      CondBuyOk=1
      DRAWARROWUP(POSLEVMIN,LEVMIN) coloured(85,255,0)
    ENDIF

    – renvoie des 3 variables à étudier

    RETURN CondBuyOk,POSLEVMIN,LEVMIN

    Comme tu le vois sur la copie d’écran 01, une flèche verte est dessinée alors que “CondBuyOk=0”!?!

    Je pige pas…

    Par contre, on voit bien (PJ 02) que “CondBuyOk=1” quand les 2 moyennes de l’indicateur se croisent, conformément à la condition:

    bullcross=LMA crosses over smoothLMA

    La logique de fonctionnement du bouzin m’échappe …

    Pourrais-tu (ou tout expert de ProRealCode) m’éclairer STP sur le sujet ?

    Merci.

    @+

    Steve

     

    Le script complet modifié:

    //LOCALS MINIMUMS AND MAXIMUMS USING LEO MOVING AVERAGE
    //Autor: LEO
    
    //VARIABLES TO BE OPTIMIZED
    
    PERIOD=20    //Period for analysis
    Kdouble=0.2 //Factor for defining what is double top or bottom
    
    //-----------
    CondBuyOk=0
    //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=10
    once maxtemp=high
    once posmaxtemp=1
    
    IF BARINDEX>2 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
    once bullcross=0
    once bearcross=0
    
    IF BARINDEX > PERIOD THEN //For avoid computer errors
    bullcross=LMA crosses over smoothLMA
    bearcross=LMA crosses under smoothLMA
    ENDIF
    
    
    IF bullcross THEN
    BLEVMIN=LEVMIN        //previus local minimum is saved
    BPOSLEVMIN=POSLEVMIN
    LEVMIN=mintemp
    POSLEVMIN=posmintemp
    support=LEVMIN
    CondBuyOk=1
    //DRAWARROWUP(POSLEVMIN,LEVMIN) coloured(0,0,0,30)
    DRAWARROWUP(POSLEVMIN,LEVMIN) coloured(85,255,0)
    ENDIF
    
    // --> Detecting and locating a local maximum
    IF bearcross THEN
    BLEVMAX=LEVMAX       //previus local maximum is saved
    BPOSLEVMAX=POSLEVMAX
    LEVMAX=maxtemp
    POSLEVMAX=posmaxtemp
    resistance=LEVMAX
    //DRAWARROWDOWN(POSLEVMAX,LEVMAX) coloured(0,0,0,30)
    DRAWARROWDOWN(POSLEVMAX,LEVMAX) coloured(255,85,0)
    ENDIF
    
    support=min(low,support)
    resistance=max(high,resistance)
    
    
    // << DETECTING DOUBLE TOP OR BOTTOMS  >>
    
    once WidthDoubleTop = high-low
    once WidthDoubleBottom = high-low
    
    //--> Double bottoms
    
    //looking for the top between two local minimums
    IF bullcross THEN
    doublebottomtop=high[BARINDEX-POSLEVMIN+1] // we start looking for the top in between two local minimums
    POSdoublebottomtop=BARINDEX-POSLEVMIN+1
    FOR i = (BARINDEX-POSLEVMIN+1) to (BARINDEX-BPOSLEVMIN-1) DO
    IF high[i] > doublebottomtop THEN
    doublebottomtop=high[i]
    POSdoublebottomtop=BARINDEX-i
    ENDIF
    NEXT
    WidthDoubleBottom = doublebottomtop-(BLEVMIN+LEVMIN)/2 // (top betwen local minimums) - (average of the las two local minimums)
    IF abs(BLEVMIN-LEVMIN) < Kdouble*WidthDoubleBottom THEN
    //       <<<<<<<  HERE WE HAVE A DOUBLE BOTTOM FOR TRADING  >>>>>
    DRAWTRIANGLE(POSLEVMIN,LEVMIN,POSdoublebottomtop,doublebottomtop,BPOSLEVMIN,BLEVMIN) COLOURED(0,255,0,200)
    ENDIF
    ENDIF
    
    //--> Double tops
    
    //looking for the bottom between two local maximums
    IF bearcross THEN
    doubletopbottom=low[BARINDEX-POSLEVMAX+1]
    POSdoubletopbottom=BARINDEX-POSLEVMAX+1
    FOR i = (BARINDEX-POSLEVMAX+1) to (BARINDEX-BPOSLEVMAX-1) DO
    IF low[i] < doubletopbottom THEN
    doubletopbottom=low[i]
    POSdoubletopbottom=BARINDEX-i
    ENDIF
    NEXT
    WidthDoubleTop=(BLEVMAX+LEVMAX)/2 -doubletopbottom
    IF abs(BLEVMAX-LEVMAX) < Kdouble*WidthDoubleTop THEN
    //       <<<<<<<  HERE WE HAVE A DOUBLE TOP FOR TRADING  >>>>>
    DRAWTRIANGLE(POSdoubletopbottom,doubletopbottom,POSLEVMAX,LEVMAX,BPOSLEVMAX,BLEVMAX) COLOURED(255,0,0,200)
    ENDIF
    ENDIF
    
    RETURN CondBuyOk,POSLEVMIN,LEVMIN
    
    //RETURN LMA AS "Leo Moving Average", support as "support", resistance as "resistance", smoothLMA as "smooth LMA" //, lowest[round(0.75*period)](low[1]), highest[round(0.75*period)](high[1])
    
    Indic_debug01.jpg Indic_debug01.jpg Indic_debug02.jpg Indic_debug02.jpg
    #169360 quote
    JC_Bywan
    Moderator
    Master

    Salut, ma première réaction pré-café, c’est que comme ton drawarrowup n’est pas forcément avec une abscisse sur barindex courant (il est mis sur poslevmin, lui même venant de posmintemps, lui-même défini en ligne 31 dans un autre bloc if-endif), alors ça me dit que la flèche verte n’est pas forcément dessinée sur la même barre que celle où buycondok=1, donc la PJ 1 ne suffit pas à conclure à une incohérence sauf ^à être sûr que c’est la lecture du code à cette barre là qui a mis la flèche là, mais comme il y a un autre bullcross que la PJ2 (celui de la dernière barre), il faudrait voir si ce n’est pas un buycondok=1 de la dernière barre qui déclenche la flèche verte en arrière dans l’historique en PJ1.

    #169437 quote
    steve_
    Participant
    New

    Hello,

    Oui, effectivement, mon 1er essai était trop simpliste… 🙁

    Je me suis plongé dans le code cet après-midi pour comprendre cet indicateur et ça vallait le coup.

    Voici ma dernière version d’adaptation de l’indicateur de Léo en screener.

    Le résultat est plutôt satisfaisant. 🙂

    En tête de script, j’ai ajouté la variable LgHisto qui définit la pronfondeur de recherche d’apparition d’une flèche “up” ou “down”.

    J’ai testé sur des actions France, Euro, US, crypto en daily, ça semble bien marcher, c’est même un peu trop beau ! 😉

    Ca ne ramène rien en “daily” sur les cryptos mais ça doit être normal (?).

    Je n’ai pas pu tester avec des UT inférieures au jour (version de démo).

    Voilà, je laisse les experts du forum jouer avec ce screener et me dire ce qu’ils en pensent (pertinence des “signaux”, failles, améliorations possibles…).

    Par avance, merci.

    @+

    Steve

     

    NB: le bouton “insertion code PRT” n’est plus dispo en mode “Visual”, il faut passer par “Text” ?!?


    //LOCALS MINIMUMS AND MAXIMUMS USING LEO MOVING AVERAGE
    //Autor of indicator: LEO
    //Screener adaptation : Steve_
    
    //VARIABLES TO BE OPTIMIZED
    
    PERIOD=20    //Period for analysis
    Kdouble=0.2 //Factor for defining what is double top or bottom
    
    // Arrow up/down must appear during last LgHisto UT
    LgHisto=5
    
    //-----------
    CondBuyOK=0
    //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=10
    once posmintemp=1
    once maxtemp=high
    once posmaxtemp=1
    
    IF BARINDEX>2 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
    once bullcross=0
    once bearcross=0
    
    IF BARINDEX > PERIOD THEN //For avoid computer errors
    bullcross=LMA crosses over smoothLMA
    bearcross=LMA crosses under smoothLMA
    ENDIF
    
    
    IF bullcross THEN
    BLEVMIN=LEVMIN        //previus local minimum is saved
    BPOSLEVMIN=POSLEVMIN
    LEVMIN=mintemp
    POSLEVMIN=posmintemp
    support=LEVMIN
    //DRAWARROWUP(POSLEVMIN,LEVMIN) coloured(0,0,0,30)
    //DRAWARROWUP(POSLEVMIN,LEVMIN) coloured(85,255,0)
    //CondBuyOK=1
    ENDIF
    
    // --> Detecting and locating a local maximum
    IF bearcross THEN
    BLEVMAX=LEVMAX       //previus local maximum is saved
    BPOSLEVMAX=POSLEVMAX
    LEVMAX=maxtemp
    POSLEVMAX=posmaxtemp
    resistance=LEVMAX
    //DRAWARROWDOWN(POSLEVMAX,LEVMAX) coloured(0,0,0,30)
    //DRAWARROWDOWN(POSLEVMAX,LEVMAX) coloured(255,85,0)
    ENDIF
    
    support=min(low,support)
    resistance=max(high,resistance)
    
    
    // << DETECTING DOUBLE TOP OR BOTTOMS  >>
    
    once WidthDoubleTop = high-low
    once WidthDoubleBottom = high-low
    
    //--> Double bottoms
    
    //looking for the top between two local minimums
    IF bullcross THEN
    doublebottomtop=high[BARINDEX-POSLEVMIN+1] // we start looking for the top in between two local minimums
    //POSdoublebottomtop=BARINDEX-POSLEVMIN+1
    FOR i = (BARINDEX-POSLEVMIN+1) to (BARINDEX-BPOSLEVMIN-1) DO
    IF high[i] > doublebottomtop THEN
    doublebottomtop=high[i]
    //POSdoublebottomtop=BARINDEX-i
    ENDIF
    NEXT
    WidthDoubleBottom = doublebottomtop-(BLEVMIN+LEVMIN)/2 // (top betwen local minimums) - (average of the las two local minimums)
    IF abs(BLEVMIN-LEVMIN) < Kdouble*WidthDoubleBottom THEN
    //       <<<<<<<  HERE WE HAVE A DOUBLE BOTTOM FOR TRADING  >>>>>
    //DRAWTRIANGLE(POSLEVMIN,LEVMIN,POSdoublebottomtop,doublebottomtop,BPOSLEVMIN,BLEVMIN) COLOURED(0,255,0,200)
    ENDIF
    ENDIF
    
    //--> Double tops
    
    //looking for the bottom between two local maximums
    IF bearcross THEN
    doubletopbottom=low[BARINDEX-POSLEVMAX+1]
    //POSdoubletopbottom=BARINDEX-POSLEVMAX+1
    FOR i = (BARINDEX-POSLEVMAX+1) to (BARINDEX-BPOSLEVMAX-1) DO
    IF low[i] < doubletopbottom THEN
    doubletopbottom=low[i]
    //POSdoubletopbottom=BARINDEX-i
    ENDIF
    NEXT
    WidthDoubleTop=(BLEVMAX+LEVMAX)/2 -doubletopbottom
    IF abs(BLEVMAX-LEVMAX) < Kdouble*WidthDoubleTop THEN
    //       <<<<<<<  HERE WE HAVE A DOUBLE TOP FOR TRADING  >>>>>
    //DRAWTRIANGLE(POSdoubletopbottom,doubletopbottom,POSLEVMAX,LEVMAX,BPOSLEVMAX,BLEVMAX) COLOURED(255,0,0,200)
    ENDIF
    ENDIF
    
    // Arrow up position
    PosFlUp=BARINDEX-POSLEVMIN
    // Arrow down position
    PosFlDwn=BARINDEX-POSLEVMAX
    
    // We screen arrows appeared during the last LgHisto UT
    CondBuyOk=(PosFlUp < LgHisto)
    CondSellOk=(PosFlDwn < LgHisto)
    
    // To check results only
    PosFl=posflup * 1000 + PosFlDwn
    
    SCREENER[CondBuyOk OR CondSellOk]( PosFl as "Pos.Up , Down")
    
    
    
    //RETURN LMA AS "Leo Moving Average", support as "support", resistance as "resistance", smoothLMA as "smooth LMA" //, lowest[round(0.75*period)](low[1]), highest[round(0.75*period)](high[1])
    
    #169546 quote
    steve_
    Participant
    New

    Hello,

    Voici une dernière version plus “présentable”, nettoyée de toutes les portions de code de l’indicateur (dessins flèches, triangles…), inutiles  au screener.

    Ca semble OK, je n’ai rien supprimé de trop, j’ai les mêmes résultats que la version précédente. 🙂

    Bref, je laisse les experts du forum jouer avec ce screener et me dire ce qu’ils en pensent (pertinence des “signaux”, failles, améliorations possibles…).

    Par avance, merci.

    @+

    Steve

     

    //LOCALS MINIMUMS AND MAXIMUMS USING LEO MOVING AVERAGE
    //Autor of indicator: LEO
    //Screener adaptation : Steve_
    
    //VARIABLES TO BE OPTIMIZED
    Period=20    //Period for analysis
    
    // We screen arrows up/down appearing during last LgHisto timeframes
    LgHisto=5
    
    //-----------
    // Buy/sell conditions
    CondBuyOK=0
    CondSellOk=0
    
    //Leo Moving Average, formula: LMA= WMA+(WMA-SMA)
    LMA = 2 * weightedaverage[period](close) - average[period](close)
    
    //Smoothed curve of Leo Moving Average
    // BARINDEX : index de la barre courante (0 à n), n=200 par défaut ?
    IF BARINDEX > period THEN
    smoothLMA = weightedaverage[period](LMA)
    ELSE
    smoothLMA = undefined
    ENDIF
    
    // << Storage of minimums and maximums >>
    once posmintemp=10
    once posmaxtemp=1
    
    IF BARINDEX > 2 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
    posmintemp=BARINDEX //postition of minimum temporal
    ENDIF
    IF high > highest[round(0.75*period)](high[1]) then
    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 previous one is stored in de varible B... (before)
    once POSLEVMIN=1
    once POSLEVMAX=1
    once bullcross=0
    once bearcross=0
    
    IF BARINDEX > period THEN // To avoid computer errors
    bullcross = LMA crosses over smoothLMA
    bearcross = LMA crosses under smoothLMA
    ENDIF
    
    // --> Locating a local minimum
    IF bullcross THEN
    POSLEVMIN = posmintemp
    ENDIF
    
    // --> Locating a local maximum
    IF bearcross THEN
    POSLEVMAX = posmaxtemp
    ENDIF
    
    // Arrow up position
    PosFlUp = BARINDEX - POSLEVMIN
    // Arrow down position
    PosFlDwn = BARINDEX - POSLEVMAX
    
    // We screen arrows appeared during the last LgHisto timeframes
    CondBuyOk = (PosFlUp < LgHisto)
    CondSellOk = (PosFlDwn < LgHisto)
    
    // To check results only
    PosFl = posflup * 1000 + PosFlDwn
    
    SCREENER[CondBuyOk OR CondSellOk]( PosFl as "Pos.Up , Down")
    
Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.

Transformer un iindicateur complexe en screener


ProScreener : Scanners de Marché & Détection

New Reply
Author
author-avatar
steve_ @steve_ Participant
Summary

This topic contains 5 replies,
has 2 voices, and was last updated by steve_
4 years, 10 months ago.

Topic Details
Forum: ProScreener : Scanners de Marché & Détection
Language: French
Started: 05/09/2021
Status: Active
Attachments: 2 files
Logo Logo
Loading...