9评论

0收藏

在趋势中动态止损

avatar 伊方兰朵 | 2961 人阅读 | 9 人评论 | 2017-08-22

  1. #property indicator_chart_window
  2. #property indicator_buffers 2
  3. #property indicator_color1 DodgerBlue
  4. #property indicator_color2 DodgerBlue
  5. //---- input parameters
  6. extern   double target=2;
  7. extern int AtrPeriod=20;
  8. //---- buffers
  9. double Up[],Dn[];

  10. //+------------------------------------------------------------------+
  11. //| Custom indicator initialization function                         |
  12. //+------------------------------------------------------------------+
  13. int init()
  14.   {
  15.    string short_name;
  16.    IndicatorBuffers(2);
  17. //---- indicator line
  18.    SetIndexStyle(0,DRAW_LINE);
  19.    SetIndexStyle(1,DRAW_LINE);
  20.    SetIndexBuffer(0,Up);
  21.    SetIndexBuffer(1,Dn);
  22. //---- name for DataWindow and indicator subwindow label
  23.    short_name="ATR("+AtrPeriod+")";
  24.    IndicatorShortName(short_name);
  25.    SetIndexLabel(0,short_name);
  26.    SetIndexLabel(1,short_name);
  27. //----
  28.    SetIndexDrawBegin(0,AtrPeriod);
  29.    SetIndexDrawBegin(1,AtrPeriod);
  30. //----
  31.    return(0);
  32.   }
  33. //+------------------------------------------------------------------+
  34. //| Average True Range                                               |
  35. //+------------------------------------------------------------------+
  36. int start()
  37.   {
  38.    int i,counted_bars=IndicatorCounted();
  39. //----
  40.    if(counted_bars>0) counted_bars--;
  41.    int limit=Bars-counted_bars;
  42.    
  43.    for(i=0; i<limit; i++)
  44.    {
  45.       Up[i]=Open[i]+target*iATR(NULL,0,AtrPeriod,i);
  46.       Dn[i]=Open[i]-target*iATR(NULL,0,AtrPeriod,i);
  47.     }
  48. //----
  49.    return(0);
  50.   }
  51. //+------------------------------------------------------------------+
复制代码


趋势.mq4
""
还没有人打赏,支持一下

评论|共 9 个

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 | 显示全部楼层

苍月乱雪

发表于 2024-6-29 14:05:49 | 显示全部楼层

谢谢

您需要登录后才可以回帖 登录 | 注册 微信登录

EA之家评论守则