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

Customize Moving Average Input Color - MetaTrader 5 Script | Trading Script Download - MT4/MT5 Resources

author EAcpu | 3 reads | 0 comments |

Custom Moving Average Input Color - indicator for MetaTrader 5

Custom Moving Average Input Color - indicator for MetaTrader 5

Custom Moving Average Input Color - indicator for MetaTrader 5

Custom Moving Average Input Color - indicator for MetaTrader 5

Added new input parameter "Line Color".

Custom Moving Average Input Color - 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 Input Color - indicator for MetaTrader 5

So distinguishing them is very difficult.

To solve the problem of visual display of moving averages, the "Line Color" parameter has been added to the Strategy Tester. Now, the Expert Advisor needs access to iCustom instead of iMA (example in the code is a cross between two iMAs ):

 //--- Create a handle to the iMA indicator Handle_iMA_First= Custom (m_symbol.Name(), Period (), "Customize moving average input color" ,
                            InpMAPeriodFirst, InpMAShiftFirst, InpMAMethodFirst, InpMAFirstColor, PRICE_CLOSE ); //handle_iMA_First=iMA(Symbol(),Period(),InpMAPeriodFirst,InpMAShiftFirst,InpMAMethodFirst,PRICE_CLOSE);
//--- if 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 );
    }

As in the cross EA of two iMAs , the moving averages are displayed in different colors in the visual strategy tester:

Custom Moving Average Input Color - indicator for MetaTrader 5


Attachment download

📎 custom_moving_average_input_color.mq5 (7.32 KB)

Source: MQL5 #19864

Verification code Refresh