小弟写了一个AFL指标 以今昨两日的均线下去比较 显示共有4列箭头 分别以今日5,10,21,65MA的值跟昨日的值比较 如果是今日 > 昨日 则红色箭头向上 反之绿色向下 指标完全可用 但小弟自知公式内容写的很笨 烦请哪位高手抽空帮小弟公式内容改一改 改漂亮一点 希望这个写的笨笨的指标能对大家有帮助 谢谢 ---------------------------------------------------------------- _SECTION_BEGIN("TEST"); axismin = Status("axisminy"); axismax = Status("axismaxy"); Plot( C, "Price", colorBlack, styleLine ); MA5_1=MA( Close, 5 ) > Ref( MA( Close, 5 ), -1 ); MA5_2=MA( Close, 5 ) < Ref( MA( Close, 5 ), -1 ); shape = MA5_1 * shapeUpArrow + MA5_2 * shapeDownArrow; y = axismin + 4 * (axismax - axismin)/5; PlotShapes( shape , IIf( MA5_1, colorRed, colorGreen ),0, y , 0); MA10_1=MA( Close, 10 ) > Ref( MA( Close, 10 ), -1 ); MA10_2=MA( Close, 10 ) < Ref( MA( Close, 10 ), -1 ); shape = MA10_1 * shapeUpArrow + MA10_2 * shapeDownArrow; y = axismin + 3 * (axismax - axismin)/5; PlotShapes( shape , IIf( MA10_1, colorRed, colorGreen ),0, y , 0); MA21_1=MA( Close, 21 ) > Ref( MA( Close, 21 ), -1 ); MA21_2=MA( Close, 21 ) < Ref( MA( Close, 21 ), -1 ); shape = MA21_1 * shapeUpArrow + MA21_2 * shapeDownArrow; y = axismin + 2 * (axismax - axismin)/5; PlotShapes( shape , IIf( MA21_1, colorRed, colorGreen ),0, y , 0); MA65_1=MA( Close, 65 ) > Ref( MA( Close, 65 ), -1 ); MA65_2=MA( Close, 65 ) < Ref( MA( Close, 65 ), -1 ); shape = MA65_1 * shapeUpArrow + MA65_2 * shapeDownArrow; y = axismin + 1 * (axismax - axismin)/5; PlotShapes( shape , IIf( MA65_1, colorRed, colorGreen ),0, y, 0); _SECTION_END();
还是改成这样有比较好一点点 ---AFL 真的太好用了 ----------------------------------- _SECTION_BEGIN("TEST"); Plot( C, "Price", colorBlack, styleLine ); axismin = Status("axisminy"); axismax = Status("axismaxy"); MA05=MA( Close, 05 ) > Ref( MA( Close, 05 ), -1 ); shape =IIf( MA05,shapeUpArrow,shapeDownArrow); y = axismin + 4 * (axismax - axismin)/5; PlotShapes( shape , IIf( MA05, colorRed, colorGreen ),0, y , 0); MA10=MA( Close, 10 ) > Ref( MA( Close, 10 ), -1 ); shape =IIf( MA10,shapeUpArrow,shapeDownArrow); y = axismin + 3 * (axismax - axismin)/5; PlotShapes( shape , IIf( MA10, colorRed, colorGreen ),0, y , 0); MA21=MA( Close, 21 ) > Ref( MA( Close, 21 ), -1 ); shape =IIf( MA21,shapeUpArrow,shapeDownArrow); y = axismin + 2 * (axismax - axismin)/5; PlotShapes( shape , IIf( MA21, colorRed, colorGreen ),0, y , 0); MA65=MA( Close, 65 ) > Ref( MA( Close, 65 ), -1 ); shape =IIf( MA65,shapeUpArrow,shapeDownArrow); y = axismin + 1 * (axismax - axismin)/5; PlotShapes( shape , IIf( MA65, colorRed, colorGreen ),0, y, 0); _SECTION_END();
_SECTION_BEGIN("4MA-Arrow"); Title = Name() + " "+WriteVal( DateTime(), formatDateTime) +" MA(C,5)=" + NumToStr( MA(C,5), 0.2 )+" MA(C,10)=" +NumToStr( MA(C,10), 0.2 ) +" MA(C,21)=" + NumToStr( MA(C,21), 0.2 )+" MA(C,65)=" + NumToStr( MA(C,65), 0.2 ); Plot(0,"",47,0); MA1 = MA( C,05 ) > Ref( MA( C,05 ), -1 ); MA2 = MA( C,10 ) > Ref( MA( C, 10 ), -1 ); MA3 = MA( C,21 ) > Ref( MA( C,21 ), -1 ); MA4 = MA( C,65 ) > Ref( MA( C,65 ), -1 ); PlotShapes( IIf( MA1,shapeUpArrow,shapeDownArrow) , IIf( MA1, colorRed, colorGreen ),0, 0.08 , 0); PlotShapes( IIf( MA2,shapeUpArrow,shapeDownArrow) , IIf( MA2, colorRed, colorGreen ),0, 0.06 , 0); PlotShapes( IIf( MA3,shapeUpArrow,shapeDownArrow) , IIf( MA3, colorRed, colorGreen ),0, 0.04 , 0); PlotShapes( IIf( MA4,shapeUpArrow,shapeDownArrow) , IIf( MA4, colorRed, colorGreen ),0, 0.02 , 0); _SECTION_END(); --------------------------------------------------- 针对小弟楼上Indicators的AFL Bug Bug已修正完毕 以上请参考 谢谢
_SECTION_BEGIN("4MA-Arrow"); Title = Name() + " "+WriteVal( DateTime(), formatDateTime) +" MA(C,5)=" + NumToStr( MA(C,5), 0.2 )+" MA(C,10)=" +NumToStr( MA(C,10), 0.2 ) +" MA(C,21)=" + NumToStr( MA(C,21), 0.2 )+" MA(C,65)=" + NumToStr( MA(C,65), 0.2 ); MA1 = MA( C,05 ) > Ref( MA( C,05 ), -1 ); MA2 = MA( C,10 ) > Ref( MA( C, 10 ), -1 ); MA3 = MA( C,21 ) > Ref( MA( C,21 ), -1 ); MA4 = MA( C,65 ) > Ref( MA( C,65 ), -1 ); Plot( 1.2, "", IIf( MA4, colorDarkRed, colorGreen ), styleArea | styleOwnScale | styleNoLabel, 0, 100 ); Plot( 1.3, "", 1, styleArea | styleOwnScale | styleNoLabel, 0, 100 ); Plot( 2.4, "", IIf( MA3, colorRed, colorBrightGreen ), styleArea | styleOwnScale | styleNoLabel, 0, 100 ); Plot( 2.5, "", 1, styleArea | styleOwnScale | styleNoLabel, 0, 100 ); Plot( 3.6, "", IIf( MA2, colorDarkRed, colorBrightGreen ), styleArea | styleOwnScale | styleNoLabel, 0, 100 ); Plot( 3.7, "", 1, styleArea | styleOwnScale | styleNoLabel, 0, 100 ); Plot( 4.8, "", IIf( MA1, colorRed, colorGreen ), styleArea | styleOwnScale | styleNoLabel, 0, 100 ); _SECTION_END();
依据hgy兄的修改 利用 styleArea | styleOwnScale 而改 请参考谢谢 ------------------------------------------------------------ _SECTION_BEGIN("4MA-Arrow"); Title = Name() + " "+WriteVal( DateTime(), formatDateTime) +" MA(C,5)=" + NumToStr( MA(C,5), 0.2 )+" MA(C,10)=" +NumToStr( MA(C,10), 0.2 ) +" MA(C,21)=" + NumToStr( MA(C,21), 0.2 )+" MA(C,65)=" + NumToStr( MA(C,65), 0.2 ); SetChartOptions(0,chartShowArrows | chartShowDates | chartLogarithmic); Plot( C, "C",1, styleCandle ); MA1 = MA( C,05 ) > Ref( MA( C,05 ), -1 ); MA2 = MA( C,10 ) > Ref( MA( C,10 ),-1 ); MA3 = MA( C,21 ) > Ref( MA( C,21 ), -1 ); MA4 = MA( C,65 ) > Ref( MA( C,65 ), -1 ); Plot( 1.0, "", 47, styleLine | styleOwnScale | styleNoLabel , 0, 100 ); Plot( 1.0, "", IIf( MA4, colorRed, colorGreen ), styleArea | styleOwnScale | styleNoLabel, 0, 100 ); Plot( 2.0, "", 47, styleLine | styleOwnScale | styleNoLabel , 0, 100 ); Plot( 2.0, "", IIf( MA3, colorRed, colorGreen ), styleArea | styleOwnScale | styleNoLabel , 0, 100 ); Plot( 3.0, "", 47, styleLine | styleOwnScale | styleNoLabel , 0, 100 ); Plot( 3.0, "", IIf( MA2, colorRed, colorGreen ), styleArea | styleOwnScale | styleNoLabel , 0, 100 ); Plot( 4.0, "", 47, styleLine | styleOwnScale | styleNoLabel , 0, 100 ); Plot( 4.0, "", IIf( MA1, colorRed, colorGreen ), styleArea | styleOwnScale | styleNoLabel , 0, 100 ); _SECTION_END();