trend dots based on pivots 5 bar hi and 5bar low

#1
hi friends
This is an effort to start coding a bigger concept in small steps.

step1
plot price as bars
plot 5 bar high and 5 bar low as dots.

step2
congestion zone pivots get white color
here price does remain inside pivot high and pivot low dots.

step3
uptrend
price breaks above pivot high and remains above pivot high
pivot dots get green color
step3
downtrend
price breaks below pivot low and remains below the pivot low.
pivot dots get red color

step4
longer congestion
current pivot high and pivot low remain inside previous pivot high and prev pivot low. prev pivots get white color

more later on
 
#2
Code:
_SECTION_BEGIN("RALLY+DECLINE");
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
n = Param("Bars",5,2,20,1);
H5 = HHV(H,n); L5 = LLV(L,n);
Plot(H5,"HHV5",colorBlueGrey,styleNoLine|styleDots,0,0,1);
Plot(L5,"LLV5",colorLime,styleNoLine|styleDots,0,0,1);
UP = H > Ref(H5,-1); DN = L < Ref(L5,-1);
UP = ExRem(UP,DN); DN = ExRem(DN,UP);
PlotShapes(5*UP+6*DN,colorWhite,0,IIf(UP,L,H),-20);
PriceColor = IIf(BarsSince(UP)<BarsSince(DN), colorBlue, colorRed); 
SetBarFillColor(IIf(C > O, GetChartBkColor(), PriceColor)); 
Plot( C, "Close", PriceColor, styleCandle | styleNoTitle,0,0,0,1);  	
_SECTION_END();
Code for coloring price as per Rally or Decline, based on if price crosses n bar HHV or n bar LLV . . .

n defaults to 5, adjust it as per your requirement . . . (can use higher values for lower TF)


:) Happy
 
Thread starter Similar threads Forum Replies Date
J Day Trading 0
A Forex 12
W AmiBroker 0
N Swing Trading 1
B AmiBroker 0

Similar threads