/** iForce, supplied by MetaQuotes, uses SMA. It's supposed to use EMA, and only after the FI is calculated. https://www.mql5.com/en/forum/266744 */ #property copyright "2018 Anthony J. Garot" #property link "http://www.garot.com/trading/" #property version "1.05" #property description "This indicator uses Elder's original formula for Force Index." #property description " " #property description "MQL5 Profile: https://www.mql5.com/en/users/tonegarot" #property description "My Website: http://www.garot.com/trading/" #property strict // indicator settings #property indicator_separate_window #property indicator_buffers 1 #property indicator_plots 1 #property indicator_type1 DRAW_LINE #property indicator_color1 DodgerBlue // P == Previous EMA value, i.e. EMA of previous day's price // C == Current value (e.g. close price) // L == Time period, e.g. a 10 day moving average // Example: ExtEFI[i]=EMA(ExtEFI[i-1], FI, InpForcePeriod); #define EMA(P, C, L) ((P) + (2.0/((L)+1.0))*((C)-(P))) // input parameters input int InpForcePeriod=13; // Period input ENUM_APPLIED_VOLUME InpAppliedVolume=VOLUME_TICK; // Volumes // indicator buffers double ExtEFI[]; void OnInit() { // indicator buffers mapping SetIndexBuffer(0,ExtEFI,INDICATOR_DATA); // sets first bar from what index will be drawn PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,InpForcePeriod); // name for DataWindow and indicator subwindow label IndicatorSetString(INDICATOR_SHORTNAME,"FI("+string(InpForcePeriod)+")"); // initialization done } 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[]) { int limit; // check for rates total if(rates_total