Plot Barcount, Cum(1) and BarIndex() and you will see it all. If you see anything you don't understand ask again.
BarIndex() is dynamic in indicators. Plotting is my debugger. --- In [email protected], "donpickdonpick" <donpi...@...> wrote: > > Below is some code which finds buy and sell points based on ATR. I am still > learning afl code. > > My question is regarding the construct: > for( i = 4; i < BarCount; i++ ) > > What is the value of BarCount? Is this examining the 4 most recent > barcounts? > > How many barcounts are being processed? All of them available for a symbol? > > Thank you for your help. > > > for( i = 4; i < BarCount; i++ ) > { > if( L[ i ] >= L[ i-2 ] AND > L[ i-1 ] >= L[ i-2 ] AND > L[ i-3 ] >= L[ i-2 ] AND > L[ i-4 ] >= L[ i-2 ] ) > { > support[ i ] = L[ i - 2]; > } > else > if( L[ i ] > H[ i-1 ] * 1.0013 ) > { > support[ i ] = H[ i-1 ] * 0.9945; > } > else > if( L[ i ] > support[ i-1 ] * 1.1 ) > { > support[ i ] = support[ i-1 ] * 1.05; > } > else > { > support[ i ] = support[ i-1 ]; > } > > if( H[ i ] > trends[ i-1 ] AND > H[ i-1 ] > trends[ i-1 ] ) > { > trends[ i ] = Max( trends[ i-1 ], support[ i ] ); > } > else > if( H[ i ] < trends[ i-1 ] AND > H[ i-1 ] < trends[ i-1 ] ) > { > trends[ i ] = Min( trends[ i-1 ], resistance[ i ] ); > } > else > if( H[ i ] >= trends[ i-1 ] ) > trends[ i ] = support[ i ]; > else > trends[ i ] = resistance[ i ]; > > } > > Plot( trends, "Trends", colorRed ); > Plot ( C, "Price", colorBlack, styleCandle ); > //Plot( C, "Price", colorBlack, styleBar ); - Original > Buy = Cross( C, trends ); > Sell = Cross( trends, H ); >
