- Katılım
- 23 Eki 2020
- Mesajlar
- 1,828
Plots Support & Resistance levels based on two types of Peaks/Troughs, fully adjustable. |
|
Support & Resistance - Peaks/Troughs { Support & Resistance v2.0 } { Plots support/resistance levels based on normal or hindsight peaks/troughs } { ©Copyright 2004 Jose Silva } { http://www.metastocktools.com } { User inputs } plot:=Input("[1]Support, [2]Resistance, [3]Both, [4]Combination",1,4,3); x:=Input("use [1]High/Low, [2]Close",1,2,1); type:=Input("Type: [1]Normal, [2]Hindsight", 1,2,1); depth:=Input("Peak/Trough minimum depth (0~50%)",0,50,5); pds:=Input("Peak/Trough period base (3~252)", 3,252,5); { Price field } xHi:=If(x=1,H,C); xLo:=If(x=1,L,C); { Non-hindsight Support/Resistance } Hi:= (HHV(xHi,pds-1)>xHi)>Ref(HHV(xHi,pds-1)>xHi,-1); HiVal1:=ValueWhen(1,Hi,Ref(xHi,-1)); Lo:= (LLV(xLo,pds-1)<xLo)>Ref(LLV(xLo,pds-1)<xLo,-1); LoVal1:=ValueWhen(1,Lo,Ref(xLo,-1)); Hi:=Hi AND HiVal1>LoVal1*(1+depth/100); Lo:=Lo AND LoVal1<HiVal1*(1-depth/100); supp:=ValueWhen(1,Lo,Ref(xLo,-1)); res:=ValueWhen(1,Hi,Ref(xHi,-1)); comb:=If(BarsSince(Hi)<BarsSince(Lo),res,supp); { Hindsight Support/Resistance } pkH:=PeakBars(1,xHi,depth); trH:=TroughBars(1,xLo,depth); suppH:=Trough(1,xLo,depth); resH:=Peak(1,xHi,depth); combH:=If(pkH<trH,resH,suppH); { Chosen Support/Resistance } supp:=If(type=1,supp, suppH); res:=If(type=1,res,resH); comb:=If(type=1,comb,combH); { Plot on price chart } If(plot=1,supp,If(plot=2,res, If(plot=3,res,comb))); If(plot=1,supp,If(plot=2,res, If(plot=3,supp,comb))) |
Source / From: |