📅 财经日历 📊 实时波动 📈 大盘云图 📶 行情走势 🆚 投机情绪 🚀 今日热点

    在趋势中动态止损

    2017-08-22 · 3312 阅读
    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
    ""
    还没有人打赏,支持一下
    回复

    举报

     

    回答|共 8 个

    zx5zx LV3

    发表于 2017-8-22 16:02:23 | 显示全部楼层

    ddddddddddddddddddddd

    浙江金帆 LV3

    发表于 2020-6-12 17:28:33 | 显示全部楼层

    帮你顶下哈!!

    cfxgroup LV3

    发表于 2020-7-10 22:02:42 | 显示全部楼层

    谢谢楼主分享

    zt1984639 LV4

    发表于 2020-7-26 10:37:13 | 显示全部楼层

    谢谢楼主分享

    ozyamhct LV3

    发表于 2020-8-25 22:41:13 | 显示全部楼层

    谢谢楼主分享

    范文芳 LV6

    发表于 2020-8-26 11:23:15 | 显示全部楼层

    学习了,不错

    我滴大哥哥 LV3

    发表于 2020-9-5 22:15:35 | 显示全部楼层

    谢谢楼主分享

    苍月乱雪 LV3

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

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

    提醒: 禁止引战、谩骂、灌水内容

    微信二维码

    有问题联系客服