设为首页 收藏本站 切换语言

费雪变换_MT5(懂C++的进)  

| 发表于 2020-8-3 10:01:25 | 显示全部楼层 |复制链接
  1. #property indicator_separate_window
  2. #property indicator_buffers 7
  3. #property indicator_plots   5
  4. #property indicator_label1  "ift OB/OS zone"
  5. #property indicator_type1   DRAW_FILLING
  6. #property indicator_color1  C'209,243,209',C'255,230,183'
  7. #property indicator_label2  "ift up level"
  8. #property indicator_type2   DRAW_LINE
  9. #property indicator_color2  clrLimeGreen
  10. #property indicator_style2  STYLE_DOT
  11. #property indicator_label3  "ift middle level"
  12. #property indicator_type3   DRAW_LINE
  13. #property indicator_color3  clrSilver
  14. #property indicator_style3  STYLE_DOT
  15. #property indicator_label4  "ift down level"
  16. #property indicator_type4   DRAW_LINE
  17. #property indicator_color4  clrOrange
  18. #property indicator_style4  STYLE_DOT
  19. #property indicator_label5  "ift"
  20. #property indicator_type5   DRAW_COLOR_LINE
  21. #property indicator_color5  clrSilver,clrLimeGreen,clrOrange
  22. #property indicator_width5  2
  23. enum enColorOn
  24. {
  25.    cc_onSlope,   // Change color on slope change
  26.    cc_onMiddle,  // Change color on middle line cross
  27.    cc_onLevels   // Change color on outer levels cross
  28. };
  29. input int                inpRsiPeriod     =  32;         // RSI period
  30. input int                inpMaPeriod      =   9;         // Average period (<=1 for no average)
  31. input ENUM_MA_METHOD     inpMaMethod      = MODE_EMA;    // Average method
  32. input ENUM_APPLIED_PRICE inpPrice         = PRICE_CLOSE; // Price
  33. input enColorOn          inpColorOn       = cc_onLevels; // Color change :
  34. input int                inpMinMaxPeriod  = 50;          // Floating levels period (<= 1 for fixed levels)
  35. input double             inpLevelUp       = 80.0;        // Up level %
  36. input double             inpLevelDown     = 20.0;        // Down level %
  37. double rsi[],rsic[],fill1[],fill2[],levelUp[],levelMi[],levelDn[];
  38. int _maHandle,_rsiHandle,_maPeriod;
  39. int OnInit()
  40. {
  41. SetIndexBuffer(0,fill1  ,INDICATOR_DATA);
  42.    SetIndexBuffer(1,fill2  ,INDICATOR_DATA);
  43.    SetIndexBuffer(2,levelUp,INDICATOR_DATA);
  44.    SetIndexBuffer(3,levelMi,INDICATOR_DATA);
  45.    SetIndexBuffer(4,levelDn,INDICATOR_DATA);
  46.    SetIndexBuffer(5,rsi    ,INDICATOR_DATA);
  47.    SetIndexBuffer(6,rsic   ,INDICATOR_COLOR_INDEX);
  48.          for (int i=0; i<4; i++) PlotIndexSetInteger(i,PLOT_SHOW_DATA,false);
  49.          _maPeriod  = MathMax(inpMaPeriod,1);
  50.          _rsiHandle = iRSI(_Symbol,0,inpRsiPeriod,inpPrice);             if (!_checkHandle(_rsiHandle)) return(INIT_FAILED);
  51.          _maHandle  = iMA(_Symbol,0,_maPeriod,0,inpMaMethod,_rsiHandle); if (!_checkHandle(_maHandle))  return(INIT_FAILED);
  52.          IndicatorSetString(INDICATOR_SHORTNAME,"Ehlers ift of smoothed RSI ("+(string)inpRsiPeriod+","+(string)_maPeriod+")");
  53.    return(0);
  54. }
  55. int OnCalculate(const int rates_total,
  56.                 const int prev_calculated,
  57.                 const datetime& time[],
  58.                 const double& open[],
  59.                 const double& high[],
  60.                 const double& low[],
  61.                 const double& close[],
  62.                 const long& tick_volume[],
  63.                 const long& volume[],
  64.                 const int& spread[])
  65. {
  66.    if(BarsCalculated(_rsiHandle)<rates_total) return(prev_calculated);
  67.    if(BarsCalculated(_maHandle)<rates_total)  return(prev_calculated);
  68.       
  69.       int _copyCount = MathMin(rates_total-prev_calculated+1,rates_total);
  70.             if (CopyBuffer(_maHandle,0,0,_copyCount,rsi)!=_copyCount) return(prev_calculated);
  71.    int i=(int)MathMax(prev_calculated-1,0); for (; i<rates_total && !_StopFlag; i++)
  72.    {
  73.       double trss = (rsi[i]-50.0)*0.1;        
  74.             rsi[i] = (MathExp(2.0*trss)-1.0)/(MathExp(2.0*trss)+1.0);
  75.             if (inpMinMaxPeriod<=1)
  76.             {                    
  77.                levelUp[i] = 2.0*inpLevelUp  /100.0-1.0;
  78.                levelDn[i] = 2.0*inpLevelDown/100.0-1.0;
  79.                levelMi[i] = (levelUp[i]+levelDn[i])/2;
  80.             }
  81.             else
  82.             {              
  83.                int    start = MathMax(i-inpMinMaxPeriod+1,0);
  84.                double max   = rsi[ArrayMaximum(rsi,start,inpMinMaxPeriod)];            
  85.                double min   = rsi[ArrayMinimum(rsi,start,inpMinMaxPeriod)];            
  86.                double range  = (max-min)/100.0;
  87.                   levelUp[i] = min+inpLevelUp  *range;
  88.                   levelDn[i] = min+inpLevelDown*range;
  89.                   levelMi[i] = min+50.0        *range;
  90.             }              
  91.             switch(inpColorOn)
  92.             {
  93.                case cc_onLevels: rsic[i] = (rsi[i]>levelUp[i])  ? 1 : (rsi[i]<levelDn[i])  ? 2 : (i>0) ? (rsi[i]==rsi[i-1]) ? rsic[i-1] : 0 : 0; break;
  94.                case cc_onMiddle: rsic[i] = (rsi[i]>levelMi[i])  ? 1 : (rsi[i]<levelMi[i])  ? 2 : 0; break;
  95.                default :         rsic[i] = (i>0) ? (rsi[i]>rsi[i-1]) ? 1 : (rsi[i]<rsi[i-1]) ? 2 : (i>0) ? (rsi[i]==rsi[i-1]) ? rsic[i-1] : 0 : 0 : 0;
  96.             }                  
  97.             fill1[i] = rsi[i];
  98.             fill2[i] = (rsi[i]>levelUp[i]) ? levelUp[i] : (rsi[i]<levelDn[i]) ? levelDn[i] : rsi[i];
  99.    }
  100.    return(i);
  101. }
  102. bool _checkHandle(int _handle)
  103. {
  104.    static int  _handles[];
  105.           int  _size   = ArraySize(_handles);
  106.           bool _answer = (_handle!=INVALID_HANDLE);
  107.           if  (_answer)
  108.                { ArrayResize(_handles,_size+1); _handles[_size]=_handle; }
  109.           else { for (int i=_size-1; i>=0; i--) IndicatorRelease(_handles[i]); ArrayResize(_handles,0); }
  110.    return(_answer);
  111. }  
复制代码
举报

评论 使用道具

精彩评论43

latage
未及格
| 发表于 2021-5-19 13:17:17 | 显示全部楼层
谢谢分享
举报

点赞 评论 使用道具

升龙
DD
| 发表于 2021-5-19 14:18:19 | 显示全部楼层
感谢分享
举报

点赞 评论 使用道具

daerbushen
DD
| 发表于 2021-5-19 14:40:32 | 显示全部楼层
谢谢分享
举报

点赞 评论 使用道具

qwe11
CCC
| 发表于 2021-5-19 16:52:58 | 显示全部楼层
感谢分享
举报

点赞 评论 使用道具

yzsx2000
未及格
| 发表于 2021-5-19 17:45:55 | 显示全部楼层
感谢分享
举报

点赞 评论 使用道具

ajax9999
未及格
| 发表于 2021-5-19 18:00:14 | 显示全部楼层
感谢分享
举报

点赞 评论 使用道具

tianping
DDD
| 发表于 2021-11-4 21:35:09 | 显示全部楼层
感谢分享
举报

点赞 评论 使用道具

EA6666
D
| 发表于 2021-11-6 13:52:59 | 显示全部楼层
谢谢分享
举报

点赞 评论 使用道具

daerwushen
DD
| 发表于 2021-11-6 15:27:24 | 显示全部楼层
感謝分享
举报

点赞 评论 使用道具

jrml
未及格
| 发表于 2021-11-7 13:23:12 | 显示全部楼层
路过。。看看先。。。
举报

点赞 评论 使用道具

YHX
D
| 发表于 2021-11-7 15:23:30 来自手机 | 显示全部楼层
谢谢分享
举报

点赞 评论 使用道具

wenchao
C
| 发表于 2021-11-21 17:16:28 | 显示全部楼层
谢谢分享学习了
举报

点赞 评论 使用道具

668
DDD
| 发表于 2021-11-26 09:44:31 | 显示全部楼层
感謝分享
举报

点赞 评论 使用道具

交易者
DDD
| 发表于 2022-1-8 21:00:47 | 显示全部楼层
感谢分享
举报

点赞 评论 使用道具

jrml
未及格
| 发表于 2022-2-2 18:26:29 | 显示全部楼层
谢谢分享!
举报

点赞 评论 使用道具

liguangxing2007
DDD
| 发表于 2022-2-2 18:29:19 | 显示全部楼层
看不懂
举报

点赞 评论 使用道具

zhy2505000
DD
| 发表于 2022-2-2 18:33:09 | 显示全部楼层
路过。。看看先。。。。
举报

点赞 评论 使用道具

liguangxing2007
DDD
| 发表于 2022-2-2 22:39:45 | 显示全部楼层
雪啊
举报

点赞 评论 使用道具

hqin212
CCC
| 发表于 2022-2-2 23:00:39 来自手机 | 显示全部楼层
感谢分享
举报

点赞 评论 使用道具

123下一页
发新帖
EA交易
您需要登录后才可以评论 登录 | 立即注册

简体中文
繁體中文
English(英语)
日本語(日语)
Deutsch(德语)
Русский язык(俄语)
بالعربية(阿拉伯语)
Türkçe(土耳其语)
Português(葡萄牙语)
ภาษาไทย(泰国语)
한어(朝鲜语/韩语)
Français(法语)