EMA crossover signal arrow on the current candle

 
Hey guys, have been working on a simple EMA crossover indicator and was assisted by Keith some time back. Recently I tried to edit the signal arrow to occur on the current candle and not after it is closed. Can anyone please help out.
//+------------------------------------------------------------------+
//|                                         EMA-Crossover_Signal.mq4 |
//|                            |
//+------------------------------------------------------------------+

/*
  +------------------------------------------------------------------+
  | Allows you to enter two ema periods and it will then show you at |
  | Which point they crossed over. It is more useful on the shorter   |
  | periods that get obscured by the bars / candlesticks and when    |
  | the zoom level is out. Also allows you then to remove the emas   |
  | from the chart. (emas are initially set at 9 and 20)              |
  +------------------------------------------------------------------+
*/
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 DarkGreen
#property indicator_color2 FireBrick

double CrossUp[];
double CrossDown[];
extern int FasterEMA = 9;
extern int SlowerEMA = 20;
extern bool SoundON=true;
extern bool Notify = true;
double alertTag;
double Notifier;
double control=2147483647;
 
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0, DRAW_ARROW, EMPTY,1);
   SetIndexArrow(0, 233);
   SetIndexBuffer(0, CrossUp);
   SetIndexStyle(1, DRAW_ARROW, EMPTY,1);
   SetIndexArrow(1, 234);
   SetIndexBuffer(1, CrossDown);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start() {
   int limit, i, counter;
   double fasterEMAnow, slowerEMAnow, fasterEMAprevious, slowerEMAprevious, fasterEMAafter, slowerEMAafter;
   double Range, AvgRange;
   int counted_bars=IndicatorCounted();
//---- check for possible errors
   if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;

   limit=Bars-counted_bars;
   
   for(i = 0; i <= limit; i++) {
   
      counter=i;
      Range=0;
      AvgRange=0;
      for (counter=i ;counter<=i+9;counter++)
      {
         AvgRange=AvgRange+MathAbs(High[counter]-Low[counter]);
      }
      Range=AvgRange/10;
       
      fasterEMAnow = iMA(NULL, 0, FasterEMA, 0, MODE_EMA, PRICE_CLOSE, i);
      fasterEMAprevious = iMA(NULL, 0, FasterEMA, 0, MODE_EMA, PRICE_CLOSE, i+1);
      fasterEMAafter = iMA(NULL, 0, FasterEMA, 0, MODE_EMA, PRICE_CLOSE, i-1);

      slowerEMAnow = iMA(NULL, 0, SlowerEMA, 0, MODE_EMA, PRICE_CLOSE, i);
      slowerEMAprevious = iMA(NULL, 0, SlowerEMA, 0, MODE_EMA, PRICE_CLOSE, i+1);
      slowerEMAafter = iMA(NULL, 0, SlowerEMA, 0, MODE_EMA, PRICE_CLOSE, i-1);
      
      if ((fasterEMAnow > slowerEMAnow) && (fasterEMAprevious < slowerEMAprevious) && (fasterEMAafter > slowerEMAafter)) {
         CrossUp[i] = Low[i] - Range*0.5;
      }
      else if ((fasterEMAnow < slowerEMAnow) && (fasterEMAprevious > slowerEMAprevious) && (fasterEMAafter < slowerEMAafter)) {
          CrossDown[i] = High[i] + Range*0.5;
      }
        if (SoundON==true && i==1 && CrossUp[i] > CrossDown[i] && alertTag!=Time[0]){
         Alert("EMA Cross Trend going Down on ",Symbol()," "+EnumToString((ENUM_TIMEFRAMES)Period()));
         alertTag = Time[0];
      }
        if (SoundON==true && i==1 && CrossUp[i] < CrossDown[i] && alertTag!=Time[0]){
         Alert("EMA Cross Trend going Up on ",Symbol()," "+EnumToString((ENUM_TIMEFRAMES)Period()));
         alertTag = Time[0];
        } 
       

        if (Notify==true && i==1 && CrossUp[i] > CrossDown[i] && Notifier!=Time[0]){
          SendNotification("EMA Cross Trend going Down on "+Symbol()+" , "+EnumToString((ENUM_TIMEFRAMES)Period()));
          Notifier = Time[0];
        }
        if (Notify==true && i==1 && CrossUp[i] < CrossDown[i] && Notifier!=Time[0]){
          SendNotification("EMA Cross Trend going Up on "+Symbol()+", "+EnumToString((ENUM_TIMEFRAMES)Period()));   
          Notifier = Time[0];             
        } 
      
  }
   return(0);
}
Thanks in advance here is the code. 
 
  1.    if(counted_bars>0) counted_bars--;
    
       limit=Bars-counted_bars;
       
       for(i = 0; i <= limit; i++) {

    No need for the decrement. Contradictory information on IndicatorCounted() - MQL4 programming forum

  2. First run counted_bars is zero, but you run up to Bars, which does not exist, array exceeded, indicator stops, if you used strict. Always use strict. Fixing the warnings will save you hours of debugging, but you must understand the differences.

  3. You should stop using the old event handlers (init, start, deinit) and IndicatorCounted() and start using new event handlers (OnInit, OnTick/OnCalculate, OnDeinit).
              Event Handling Functions - MQL4 Reference
              How to do your lookbacks correctly - MQL4 programming forum #9-14 & #19 (2016)

  4. Ismail Lemin: I tried to edit the signal arrow to occur on the current candle a
         fasterEMAafter = iMA(NULL, 0, FasterEMA, 0, MODE_EMA, PRICE_CLOSE, i-1);
    So why are you trying to read the future?
 
Ismail Lemin:

Topics concerning MT4 and MQL4 have their own section.

In future please post in the correct section.

I have moved your topic to the MQL4 and Metatrader 4 section.

 
William Roeder #:
  1. No need for the decrement. Contradictory information on IndicatorCounted() - MQL4 programming forum

  2. First run counted_bars is zero, but you run up to Bars, which does not exist, array exceeded, indicator stops, if you used strict. Always use strict. Fixing the warnings will save you hours of debugging, but you must understand the differences.

  3. You should stop using the old event handlers (init, start, deinit) and IndicatorCounted() and start using new event handlers (OnInit, OnTick/OnCalculate, OnDeinit).
              Event Handling Functions - MQL4 Reference
              How to do your lookbacks correctly - MQL4 programming forum #9-14 & #19 (2016)

  4. So why are you trying to read the future?

Hello William, I removed the decrement and also edited the event handlers to the latest mql4 strict standards. I still can't figure out the what will have signal arrow to occur on the current candle before it closes. I have tried to change the PRICE CONSTANT (PRICE_CLOSE), removed the decrement

 fasterEMAnow = iMA(NULL, 0, FasterEMA, 0, MODE_EMA, PRICE_CLOSE, i);
      fasterEMAprevious = iMA(NULL, 0, FasterEMA, 0, MODE_EMA, PRICE_CLOSE, i+1);
      fasterEMAafter = iMA(NULL, 0, FasterEMA, 0, MODE_EMA, PRICE_CLOSE, i-1); // tried to change PRICE_MEDIAN

      slowerEMAnow = iMA(NULL, 0, SlowerEMA, 0, MODE_EMA, PRICE_CLOSE, i);
      slowerEMAprevious = iMA(NULL, 0, SlowerEMA, 0, MODE_EMA, PRICE_CLOSE, i+1);
      slowerEMAafter = iMA(NULL, 0, SlowerEMA, 0, MODE_EMA, PRICE_CLOSE, i-1); // tried to remove the i-1 

but still failed. Please help out to get this to work. Please help me, my coding knowledge is little, and I struggle to get it right sometimes.

 
William Roeder #:
  1. No need for the decrement. Contradictory information on IndicatorCounted() - MQL4 programming forum

  2. First run counted_bars is zero, but you run up to Bars, which does not exist, array exceeded, indicator stops, if you used strict. Always use strict. Fixing the warnings will save you hours of debugging, but you must understand the differences.

  3. You should stop using the old event handlers (init, start, deinit) and IndicatorCounted() and start using new event handlers (OnInit, OnTick/OnCalculate, OnDeinit).
              Event Handling Functions - MQL4 Reference
              How to do your lookbacks correctly - MQL4 programming forum #9-14 & #19 (2016)

  4. So why are you trying to read the future?

Hello there William, please assist me I have tried with my little programming knowledge but came short. I also left my response on what I tried to change on the source code. 
 
Keith Watford #:

Topics concerning MT4 and MQL4 have their own section.

In future please post in the correct section.

I have moved your topic to the MQL4 and Metatrader 4 section.

Hello Keith hope you are doing fine. Please help me edit the source code to get the signal bar on the current candle. 
 
William Roeder #:
  1. No need for the decrement. Contradictory information on IndicatorCounted() - MQL4 programming forum

  2. First run counted_bars is zero, but you run up to Bars, which does not exist, array exceeded, indicator stops, if you used strict. Always use strict. Fixing the warnings will save you hours of debugging, but you must understand the differences.

  3. You should stop using the old event handlers (init, start, deinit) and IndicatorCounted() and start using new event handlers (OnInit, OnTick/OnCalculate, OnDeinit).
              Event Handling Functions - MQL4 Reference
              How to do your lookbacks correctly - MQL4 programming forum #9-14 & #19 (2016)

  4. So why are you trying to read the future?
Hey guys I have no bad intentions, I only need help. Please if you can help me am asking kindly for your help. 
 
Ismail Lemin # I only need help. Please if you can help me am asking kindly for your help. 

Help you with what? You were given several problems but have not shown your fix (using the CODE button) nor stated the nature of your difficulty.
          No free help (2017)

Or pay someone. Top of every page is the link Freelance.
          Hiring to write script - General - MQL5 programming forum (2018)

We're not going to code it for you (although it could happen if you are lucky or the issue is interesting).
          No free help (2017)

 
William Roeder #:

Help you with what? You were given several problems but have not shown your fix (using the CODE button) nor stated the nature of your difficulty.
          No free help (2017)

Or pay someone. Top of every page is the link Freelance.
          Hiring to write script - General - MQL5 programming forum (2018)

We're not going to code it for you (although it could happen if you are lucky or the issue is interesting).
          No free help (2017)

Hello William I did change the PRICE CONSTANT as shown in my previous reply. I showed my fix and used the code button and even attached the code with commented part to the end. Please check on it it's there. 
Reason: