Leo

Double top and double bottom SCREENER

Category: Screeners By: Leo Created: October 31, 2017, 9:11 AM
October 31, 2017, 9:11 AM
Screeners
22 Comments
Double top and double bottom SCREENER

Hi all,

This is a screener that detect double top and double bottom.

A double top or a double bottom, are chartists figures that announce a reversal of trend. In general, a double top is created in the context of a downward trend and therefore marks its end and a return of the bullish movement while a double bottom,  is created in the context of a downward trend and therefore marks its end and a return of the bullish movement.

Base on my Leo Moving Average indicator, the following screener detects double bottom and double top.

I am looking forward to read your comments and improvements in the systems.

If you earn money with this methodology please share your luck with the people in the world who do not.

//LOCALS MINIMUMS AND MAXIMUMS USING LEO MOVING AVERAGE
//Autor: LEO

//VARIABLES TO BE OPTIMIZED

PERIOD=40    //Period for analysis


//Definition of what is a double top or double bottom
Kdouble=0.2 //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

// Direction or trend of the LMA


// << Storage of minimums and maximums >>
once mintemp=low
once posmintemp=1
once maxtemp=high
once posmaxtemp=1

IF BARINDEX>2 THEN
 // the value 0.7 is to ensure that the donchian channel is faster than the curves analysis (this value to be checked)
 IF low < lowest[round(0.7*period)](low[1]) THEN
  mintemp=low //minimum temporal
  posmintemp=BARINDEX //postition of minimum temporal
 ENDIF
 IF high > highest[round(0.7*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 and POSLEVMIN<>posmintemp  THEN
 BLEVMIN=LEVMIN        //previus local minimum is saved
 BPOSLEVMIN=POSLEVMIN
 LEVMIN=mintemp
 POSLEVMIN=posmintemp
 support=LEVMIN
ENDIF

// --> Detecting and locating a local maximum
IF bearcross and POSLEVMAX<>posmaxtemp THEN
 BLEVMAX=LEVMAX       //previus local maximum is saved
 BPOSLEVMAX=POSLEVMAX
 LEVMAX=maxtemp
 POSLEVMAX=posmaxtemp
 resistance=LEVMAX
ENDIF

support=min(low,support)
resistance=max(high,resistance)


// << DETECTING DOUBLE TOP OR BOTTOMS  >>

once WidthDoubleTop = high-low
once WidthDoubleBottom = high-low
once Wpattern=0
once Mpattern=0


//  <<<<<<  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
  // we have a double bottom
  Wpattern=1
 else
  Wpattern=0
 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
  // we have a double top
  Mpattern=1
 else
  Mpattern=0
 ENDIF
ENDIF

//    <<<<<<<<<<  DOUBLE TOP AND DOUBLE BOTTOM FOR TRADING  >>>>>>>>


myATR=AverageTrueRange[2*period](close)

IF Wpattern=1 THEN
 IF close > (doublebottomtop+myATR) or close < (LEVMIN-0.5*myATR) THEN
  Wpattern=0 //  <<<< double bottom has been activated or it was cancelled >>>>>
 ELSE
 //       <<<<<<<  HERE WE HAVE A DOUBLE BOTTOM FOR TRADING  >>>>>
  exactness=abs(BLEVMIN-LEVMIN) / WidthDoubleBottom
 ENDIF
ENDIF

IF Mpattern=1 THEN
 IF close < (doubletopbottom-myATR) or close > (LEVMAX+0.5*myATR) THEN
  Mpattern=0 //double top has been activated or it was cancelled
 ELSE
 //       <<<<<<<  HERE WE HAVE A DOUBLE TOP FOR TRADING  >>>>>
  exactness= abs(BLEVMAX-LEVMAX) / WidthDoubleTop
 ENDIF
ENDIF


SCREENER[Wpattern=1 or Mpattern=1](exactness)

Download
Filename: double-top-and-bottom-screener.itf
Downloads: 1861
Download
Filename: screen-shot-at-1509392480cp48l.png
Downloads: 724
Leo
Leo Veteran
" IF YOU HAVE WEALTH , IT'S A DUTY TO HELP THOSE WHO DON'T " Manoj Bhargava
Author’s Profile

Comments

Saberi2023
3 years ago
#

Hello dear Can you please write it also in java script?

tommygtb
6 years ago
#

what does the criteria mean in the box on the screen is it the time frame the screener searches ie 01.1hour TF , 0.2 2hour? thanks tom

Dadoo
6 years ago
#

Incredible workLeo. Thankyou to share you time and knowledge

sally31120
7 years ago
#

Bonjour, J’ai deux questions concernant Double top and double bottom detector – M&W patterns a) A partir de quand les flèches dessinées sur le graphique sont-elles définitives, car : https://www.prorealcode.com/prorealtime-indicators/double-top-double-bottom-detector/ « lokbuscas • 25/10/2017 # Salut les signaux que la peinture est fantastique. Mais j'ai un doute. L'indicateur repeint-il? ? Dans le passé marque très bien des hauts et des bas Mais dans le présent je n'ai pas de stock que l'indicateur montre les signaux merci » « Nicolas • 25/10/2017 # Je ne pense pas que cet indicateur "repeigne" la façon dont vous pensez. Il donne des signaux après, mais il ne doit pas supprimer un signal donné une fois la barre fermée. » b) Peut-on screener uniquement les flèches en fin de journée et quel en serait le code ? Merci par avance pour vos réponses

Breeze
7 years ago
#

Hi Leo. I am not an IT person so I need help to know how I can run this code. I am a trader in South Africa.

Nicolas
7 years ago
#

Download the itf file on this page, import it into your platform and run it through the ProScreener module.

rama
8 years ago
#

I am using if [Wpattern=1 and (exactness) then buy at market endif however system is not accepting the code for buy orders , what is the correct for buy?

rama
8 years ago
#

I am using the this code to buy or sell in a program which is not working

Mick3y
9 years ago
#

Is there a way to sort the results by price? Let's say just return stocks under X price? Thanks

ludo6977
9 years ago
#

it's very good job léo

djtaktik
9 years ago
#

Nice Screener ! Is it possible to screen when a green or red arrow appears ? thks in advance.

Leo
Leo
9 years ago
#

I do not focus so much in screeners. You can see our progress in the forum. Cheers

Leo
Leo
9 years ago
#

Hi all, We are adding all our ideas and improvements here : https://www.prorealcode.com/topic/dobule-bottom-or-double-top/

Sapo
9 years ago
#

Merci beaucoup pour le partage à bientôt Leo.

ALE
ALE
9 years ago
#

the indicator is here: https://www.prorealcode.com/prorealtime-indicators/double-top-double-bottom-detector/

ALE
ALE
9 years ago
#

Thanks Very Much Leo, could you help us with an example of trading strategy using these signal?

ali zidouri
9 years ago
#

please help i dont know how to convert code to indicator

cantillon
9 years ago
#

Thanks Leo, great piece of code !

Leo
Leo
9 years ago
#

Thanks for your time invested here as well. I hope we all find a way to made a very profitable strategy out of it

Diamant
2 years ago
#

Bonjour Léo, est t'il possible d'avoir le code de l'indicateur ton Double haut et double fond, les screener ne m'est pas utile. Merci

Nicolas
9 years ago
#

Great addition Leo, many thanks for your work on this project and for sharing the code with us! ;)

bolsatonimora2
9 years ago
#

many thanks Leo!!! Great!!

ProRealCode ProRealCode
Loading...