Moving Speed Normalized

Author: Copyright 2021, Roman Kiverin
Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
Moving Speed Normalized
ÿþ//+------------------------------------------------------------------+

//|                                                      ProjectName |

//|                                      Copyright 2018, CompanyName |

//|                                       http://www.companyname.net |

//+------------------------------------------------------------------+

#property version     "1.0"

#property copyright   "Copyright 2021, Roman Kiverin"

#property link        "https://www.mql5.com/ru/users/romankiverin/publications"

#property description "Moving Averages Speed"

#property strict



#include <MovingAverages.mqh>



//--- indicator settings

#property  indicator_separate_window

#property  indicator_buffers 1

#property  indicator_color1  Blue

#property  indicator_width1  2



#property  indicator_level1 0.000200

#property  indicator_level2 0

#property  indicator_level3 -0.000200

#property  indicator_levelcolor Red





//--- indicator parameters

input int MaPeriod = 10;                     // Moving Average Period

input int CBar = 1000;                 // Maximum Bar Calculate



input ENUM_MA_METHOD Method = MODE_SMA;      // Moving Average Method

input ENUM_APPLIED_PRICE App = PRICE_CLOSE;  // Applied to



#define iMa(index) iMA(NULL,PERIOD_CURRENT,MaPeriod,index,Method,App,0)

#define !83<0_$C=:F8O(i) (-1+2.0/(1.0+MathExp(-(i)))) //>@<8@>20=85 <>6=> A45;0BL A ?><>ILN A83<0-DC=:F88 2840: y[i] = 2/1+exp(-x[i]) .



double    Map[], tmp;

//+------------------------------------------------------------------+

//| Custom indicator initialization function                         |

//+------------------------------------------------------------------+

int OnInit(void)

  {

   IndicatorDigits(Digits+1);

//--- drawing settings

   SetIndexStyle(0, DRAW_LINE);

//--- indicator buffers mapping

   SetIndexBuffer(0, Map);

   IndicatorShortName("MA Speed Normalized");

   return(INIT_SUCCEEDED);

  }

//+------------------------------------------------------------------+

//| Ma Speed Main Draw                                               |

//+------------------------------------------------------------------+

int OnCalculate(const int rates_total,

                const int prev_calculated,

                const datetime& time[],

                const double& open[],

                const double& high[],

                const double& low[],

                const double& close[],

                const long& tick_volume[],

                const long& volume[],

                const int& spread[])

  {

   if(prev_calculated > 0)

      Map[0] = !83<0_$C=:F8O(iMa(0) - iMa(1));

   else

      for(double i = (tmp = rates_total - prev_calculated - 2), prev = iMa(1 + (int(tmp = tmp > CBar? CBar: tmp)));

          i >= 1; i--, Map[(int)i] = - prev, Map[(int)i] += prev = iMa((int)i), Map[int(i)] = !83<0_$C=:F8O(Map[int(i)]));

   return (rates_total);

  }

//+------------------------------------------------------------------+

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---