当我尝试比较收盘蜡烛值和 MA 线值时需要 Amibroker AFL 代码的帮助
need help in Amibroker AFL code when i trying to compare Close candle value and MA Line value
我正在编写一个简单的指标
- 条件:当收盘价高于 MA50、MA144 和 MA200
- 愿望:画一个形状向上箭头
但是如下应用源代码时,是错误的
我是新手,感谢您的帮助!
_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 为每个条形获取一组形状。
这将创建一个向上或向下箭头数组,然后创建另一个数组,该数组通过比较柱索引与最后一个 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();
我正在编写一个简单的指标
- 条件:当收盘价高于 MA50、MA144 和 MA200
- 愿望:画一个形状向上箭头
但是如下应用源代码时,是错误的
我是新手,感谢您的帮助!
_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 为每个条形获取一组形状。
这将创建一个向上或向下箭头数组,然后创建另一个数组,该数组通过比较柱索引与最后一个 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();