EA that places historical arrows on chart

Back to topics list To post a new topic, please log in or register
avatar
16
texcan 2016.07.07 05:42
 

Hi group.

I am trying to develop an MQL4 EA that places arrows on chart. When initiated, the EA will place arrows on past candles. To make it simple, the EA can be designed to place an up-arrow when the previous candle has had a 10 point move (or more) up (Close-Open>10).

I am not a coder, but I am trying. I would appreciate if someone could point out my mistake or correct the code.

Thanks.

//+------------------------------------------------------------------+
//|                                              MY IF STATEMENT.mq4 |
//|                                                              TEX |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "TEX"
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict


extern int Range=10;


int counted_bars=IndicatorCounted(),
    i,
    limit;


//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
  
    if(counted_bars<0)
      if(counted_bars>0)
         counted_bars--;
   limit= Bars-counted_bars; 
   
for(i=0; i<limit; i++)

{   
   if(Close[i] > (Close[i+1] + (Range*Point)))     
     {
     ObjectCreate ("Arrow",OBJ_ARROW_UP,0,TimeCurrent(),Bid);
     ObjectSet ("Arrow",OBJPROP_COLOR,White);
     }
  
}
  
    
   
//---
   return(INIT_SUCCEEDED);
  }
avatar
1202
FMIC 2016.07.07 05:57 #
 

You will have to read the documentation again so that you know the difference between an EA (Expert Advisor), an CI (Custom Indicator) and a Script. What you want, is an "Indicator" and not an EA. I suggest you look at some of the example Indicators that MetaQuotes provides as a basis and then build from there.

Also, instead of creating Chart Objects, use buffers instead to display the arrows, so study for example, the "parabolic.mq4" as a basis for your Custom Indicator because it places a dot symbol (equivalent to an arrow) using buffers instead of Chart objects.

avatar
16
texcan 2016.07.07 18:28 #
 

Hi FMIC.

Thanks for your suggestion. Is a CI able to send emails when events are triggered?

avatar
1202
FMIC 2016.07.07 20:39 #
 
texcan:

Thanks for your suggestion. Is a CI able to send emails when events are triggered?

Yes, it can send emails, it can sent notifications to mobile MetaTrader apps and can also place alerts on the screen.
Back to topics list  

To add comments, please log in or register