我自己写了一个指标,比如用80,和15均线,以15均做为中轴,在另一边镜像一个80均
可我写了后不知道代码错在哪,镜像应该和另一边的80均一样的平滑,但我做出来的和15均一样的弯曲!
下面是代码:
如下图的,黄的是80均,红的为15均,蓝的是镜像出来的,
怎么镜像出来的就不如原来的平滑呢??
- //ver 1.0.0.0
- #property indicator_chart_window
- #property indicator_buffers 1
- #property indicator_color1 Aqua //蓝线
- extern int ma01=15,ma02=80;
- extern string string01=\"平均模式:0 SMA, 1 EMA, 2 SMMA, 3 LWMA\";
- extern int ma_method01=1,ma_method02=1;
- extern string string02=\"价格模式:0 CLOSE, 1 OPEN, 2 HIGH, 3 LOW, 4 MEDIAN, 5 TYPICAL, 6 WEIGHTED\";
- extern int applied_price01=0, applied_price02=0;
- double agpmaline[];
- //+------------------------------------------------------------------+
- //| expert initialization function |
- //+------------------------------------------------------------------+
- int init()
- {
- //----
- SetIndexBuffer(0,agpmaline);
- SetIndexStyle(0,DRAW_LINE,1,2);
- SetIndexDrawBegin(0,0);
- IndicatorDigits(Digits);
- //----
- return(0);
- }
- //+------------------------------------------------------------------+
- //| expert deinitialization function |
- //+------------------------------------------------------------------+
- int deinit()
- {
- //----
-
- //----
- return(0);
- }
- //+------------------------------------------------------------------+
- //| expert start function |
- //+------------------------------------------------------------------+
- int start()
- {
- //----
- int limit;
- int counted_bars=IndicatorCounted();
- if(counted_bars0) counted_bars--;
- limit=Bars-counted_bars;
- double a,b,c;
- for(int i=limit; i>=0; i--)
- {
- a=iMA(NULL,0,ma01,0,ma_method01,applied_price01,i);
- b=iMA(NULL,0,ma02,0,ma_method02,applied_price02,i);
- c=a-b;
- //agpmaline=b + c*2;
- agpmaline=a + c;
- }
-
- //----
- return(0);
- }//+------------------------------------------------------------------+
复制代码
复制代码 |