i'm coding a simple indicator
but when applied source code as below, it's wrong
i'm a newbie, i'm appreciate with your help!
_SECTION_BEGIN("test");
MA50 = MA (C,50);
MA144 = MA (C, 144);
MA200 = MA (C,200);
val1 = LastValue(MA50);
val2 = LastValue(MA144);
val3 = LastValue(MA50);
val4 = LastValue(Close);
Plot(MA50, "MA50", colorRed, styleLine, Null, Null, 0 );
Plot(MA144, "MA144", colorRed, styleLine, Null, Null, 0 );
Plot(MA200, "MA200", colorRed, styleLine, Null, Null, 0 );
if (val4 > val1 AND val4 > val2 AND val4 > val3)
{
PlotShapes(shapeUpArrow,ParamColor("UpArrow",10),0,L);
}
else
{
PlotShapes(shapeDownArrow,ParamColor("DownArrow",10),0,L);
}
_SECTION_END();
PlotShapes takes an array of shapes for each bar.
This will create an array of up or down arrows, then create another array that only shows the shape on the last bar by comparing the bar index to the last barIndex.
_SECTION_BEGIN("test");
MA50 = MA (C,50);
MA144 = MA (C, 144);
MA200 = MA (C,200);
Plot(MA50, "MA50", colorRed, styleLine, Null, Null, 0 );
Plot(MA144, "MA144", colorRed, styleLine, Null, Null, 0 );
Plot(MA200, "MA200", colorRed, styleLine, Null, Null, 0 );
bar = BarIndex();
isLastBar = LastValue(bar) == bar;
isUp = Close > MA50 AND Close > MA144 AND Close > MA200;
shape = IIf(isUp, shapeUpArrow, shapeDownArrow);
shapeColor = IIf(isUp, ParamColor("UpArrow", colorLime), ParamColor("DownArrow",colorBlue));
PlotShapes(IIf(isLastBar, shape, shapeNone), shapeColor, 0, Low);
_SECTION_END();