Welcome Forex EA downloads & MT4/MT5 auto-trading resources — EAs, Gold EAs, quant tools and real-world automation.
Sign In Sign Up

Custom Moving Average Input - MetaTrader 5 Script | Forex Indicator Download - MT4/MT5 Resources

author EAcpu | 2 reads | 0 comments |

Custom Moving Average Inputs - indicator for MetaTrader 5

Custom Moving Average Inputs - indicator for MetaTrader 5

Custom Moving Average Inputs - indicator for MetaTrader 5

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

Custom Moving Average Inputs - indicator for MetaTrader 5

You may notice that if the Expert Advisor uses Moving Average indicator data, this indicator only appears in red color in the visual tester mode. If such an EA uses data from three moving averages, all three indicators will appear in red.

Custom Moving Average Inputs - indicator for MetaTrader 5

So distinguishing them is very difficult.

To solve the problem of visual display of moving averages, two parameters have been added to the strategy tester: line color and line width . Now, Expert Advisors require access to iCustom instead of iMA:

 //--- Create a handle to the iMA indicator Handle_iMA_First= Custom (m_symbol.Name(), Period (), "Customized moving average input" ,
                            InpMAPeriodFirst, InpMAShiftFirst, InpMAMethodFirst, InpMAFirstColor , InpMAFirstWith , PRICE_CLOSE ); //--- If the handle is not created if (handle_iMA_First== INVALID_HANDLE )
    {
//--- Inform of failure and output error code print format ( "Unable to create iMA indicator handle for symbol %s/%s, error code %d" ,
symbol (),
Enumeration to string ( period ()),
getLastError ());
//--- The indicator stops returning early ( initialization failed );
    }

Indicator color and width can now be managed directly from Expert Advisor:

Custom Moving Average Inputs - indicator for MetaTrader 5


Attachment download

📎 custom_moving_average_inputs.mq5 (14.88 KB)

Source: MQL5 #21779

Verification code Refresh