i'm coding a simple indicator
- condition: when close price is higher MA50, MA144 and MA200
- desire: draw a shape up arrow
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.