Help with EA color conditional

To add comments, please log in or register
piersonrazzi
7
piersonrazzi  

I am writing to code so that when my custom indicator which is the hull moving average changes from green to red or red to green It will execute the proper order. 

This is my pseudo code:

if the current color of the hull is green and the previous color of it was red:
        buy
if the current color is red and the previous one was green
        sell

this is all I have done so far:

//+------------------------------------------------------------------+
//|                                                       hullea.mq4 |
//|                        Copyright 2020, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |

input int length=12;
double hull=iCustom(NULL,0,"Hull moving average",12,4,0);
color downcolor=StringToColor(clrOrangeRed);
color upColor=StringToColor(clrMediumSeaGreen);

void OnTick()
  {
   
   
 

   
  }
//+------------------------------------------------------------------+

The code is easy once I can obtain the color of the moving average which I have defined as "hull"

im assuming the code would sort of be:

if hullcolor[1]==downcolor and hullcolor==upcolor 

orderSend(buy etc)

William Roeder
21815
William Roeder  
piersonrazzi: The code is easy once I can obtain the color of the moving average which I have defined as "hull"
  1. Why did you post your MT4 question in the Root / MT5 General section instead of the MQL4 section, (bottom of the Root page?)
              General rules and best pratices of the Forum. - General - MQL5 programming forum
    Next time post in the correct place. The moderators will likely move this thread there soon.

  2. There are no colors; EAs have no eyes. One buffer shows one color, the other for another; you find out which is which. You assign to one color buffer, make the other color buffer EMPTY_VALUE. Also remember, at the bar where the color changes, both buffers will have the same value.
              HOW CAN I hide CONNECTION lines of plots? (ttt) - MQL4 programming forum
To add comments, please log in or register