Expert Advisors • Indicators • Scripts • Libraries

MQL.RobotFX.org is the biggest collection of MetaTrader expert advisors (MT5 & MT4), indicators, scripts and libraries that can be used to improve trading results, minimize risks or simply automate trading tasks

MetaTrader 5 Indicator | Custom Moving Average Inputs

Two settings have been added to input parameters: line color (Color) and line width (Width).

MetaTrader Experts, Indicators, Scripts and Libraries

You probably noticed that if an Expert Advisor uses the Moving Average indicator data, then this indicator is displayed ONLY in red in the visual tester mode. If such an EA uses data of three Moving Averages, all three indicators are shown in red.

MetaTrader Experts, Indicators, Scripts and Libraries

So it is very difficult to distinguish between them.

To solve the issue with the visual display of Moving Averages, two parameters were added in the strategy tester: line color and line width. Now, the Expert Advisor needs to access iCustom instead of iMA:

//--- create handle of the indicator iMA     handle_iMA_First=iCustom(m_symbol.Name(),Period(),"Custom Moving Average Inputst",                              InpMAPeriodFirst,InpMAShiftFirst,InpMAMethodFirst,InpMAFirstColor,InpMAFirstWith,PRICE_CLOSE);  //--- if the handle is not created      if(handle_iMA_First==INVALID_HANDLE)       {        //--- tell about the failure and output the error code         PrintFormat("Failed to create handle of the iMA indicator for the symbol %s/%s, error code %d",                    Symbol(),                    EnumToString(Period()),                    GetLastError());        //--- the indicator is stopped early         return(INIT_FAILED);       }  

Now, the indicator color and width can be managed directly from the Expert Advisor:

MetaTrader Experts, Indicators, Scripts and Libraries

21779