伊方兰朵 发表于 2017-8-22 14:08:11

在趋势中动态止损

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 DodgerBlue
#property indicator_color2 DodgerBlue
//---- input parameters
extern   double target=2;
extern int AtrPeriod=20;
//---- buffers
double Up[],Dn[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
{
   string short_name;
   IndicatorBuffers(2);
//---- indicator line
   SetIndexStyle(0,DRAW_LINE);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(0,Up);
   SetIndexBuffer(1,Dn);
//---- name for DataWindow and indicator subwindow label
   short_name="ATR("+AtrPeriod+")";
   IndicatorShortName(short_name);
   SetIndexLabel(0,short_name);
   SetIndexLabel(1,short_name);
//----
   SetIndexDrawBegin(0,AtrPeriod);
   SetIndexDrawBegin(1,AtrPeriod);
//----
   return(0);
}
//+------------------------------------------------------------------+
//| Average True Range                                             |
//+------------------------------------------------------------------+
int start()
{
   int i,counted_bars=IndicatorCounted();
//----
   if(counted_bars>0) counted_bars--;
   int limit=Bars-counted_bars;
   
   for(i=0; i<limit; i++)
   {
      Up=Open+target*iATR(NULL,0,AtrPeriod,i);
      Dn=Open-target*iATR(NULL,0,AtrPeriod,i);
    }
//----
   return(0);
}
//+------------------------------------------------------------------+


zx5zx 发表于 2017-8-22 16:02:23

ddddddddddddddddddddd

浙江金帆 发表于 2020-6-12 17:28:33

帮你顶下哈!!

cfxgroup 发表于 2020-7-10 22:02:42

谢谢楼主分享

zt1984639 发表于 2020-7-26 10:37:13

谢谢楼主分享

ozyamhct 发表于 2020-8-25 22:41:13

谢谢楼主分享

范文芳 发表于 2020-8-26 11:23:15

学习了,不错

我滴大哥哥 发表于 2020-9-5 22:15:35

谢谢楼主分享

不出 发表于 2023-12-30 19:26:54

{:1_180:}

苍月乱雪 发表于 2024-6-29 14:05:49

谢谢
页: [1]
查看完整版本: 在趋势中动态止损