Home Technical Indicator Post

Customize Your Moving Average Colors in MetaTrader 5

Attachments
19864.zip (1.7 KB, Download 0 times)

Hey there, fellow traders! If you're using the Moving Average indicator in your trading strategies, I've got some great news for you. A new input parameter called "line color" has just been added to enhance your experience.

Custom Moving Average Input Color

You may have noticed that when an Expert Advisor (EA) relies on the Moving Average data, it typically displays only in red during visual testing. This means if your EA is using data from three Moving Averages, they all show up in the same color. Talk about a headache!

Three MA in one color

It’s quite a challenge to differentiate between them, right? But don’t worry, we’ve got the solution! The new "line color" parameter in the strategy tester allows for better visual distinction of your Moving Averages.

Now, instead of using the traditional iMA function, your EA can access the Moving Average with the iCustom function. Here’s a quick example of how to set it up:

//--- create handle of the indicator iMA
   handle_iMA_First=iCustom(m_symbol.Name(),Period(),"Custom Moving Average Input Color",
                            InpMAPeriodFirst,InpMAShiftFirst,InpMAMethodFirst,InpMAFirstColor,PRICE_CLOSE);
//handle_iMA_First=iMA(Symbol(),Period(),InpMAPeriodFirst,InpMAShiftFirst,InpMAMethodFirst,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);
     }

With this change, you’ll see that your Moving Averages can now be displayed in different colors in the visual strategy tester.

Crossing of two iMA

So, give it a whirl and make your trading visuals much clearer and more effective!

Related Posts

Comments (0)