Custom Indicator not displaying correctly

ogwedhi

Trader
Apr 8, 2021
12
1
6
39
A custom indicator I have plots the correct entry arrow on the screen but plots random arrows in the rest of the chart where I do not expect it to plot any thing.
How can this be fixed? Also how can I move the arrow next to the entry candle its way too far ontop. Any help will be much appreciate

Regrads,error.png
 

Attachments

Enivid

Administrator
Staff member
Nov 30, 2008
15,991
803
144
Odessa
www.earnforex.com
You can remove those "random" arrows by adding the following lines right before the line 266:
MQL5:
ExtMapBufferDown1[bar] = EMPTY_VALUE;
ExtMapBufferUp1[bar] = EMPTY_VALUE;
As for the distance, it is currently determined by the moving average values. Of course, you could replace the lowMoving0 for the up arrows to something like iLow(NULL, 0, bar) - 10 * _Point, but that would hardly be a better solution.
 
  • Like
Reactions: ogwedhi

ogwedhi

Trader
Apr 8, 2021
12
1
6
39
You can remove those "random" arrows by adding the following lines right before the line 266:
MQL5:
ExtMapBufferDown1[bar] = EMPTY_VALUE;
ExtMapBufferUp1[bar] = EMPTY_VALUE;
As for the distance, it is currently determined by the moving average values. Of course, you could replace the lowMoving0 for the up arrows to something like iLow(NULL, 0, bar) - 10 * _Point, but that would hardly be a better solution.
Thank you so much. The two lines of Code fixed the problem. I really appreciate your help
 

ogwedhi

Trader
Apr 8, 2021
12
1
6
39
I opted to add an alert but the problem is that it displays sell on all even on a buy indication. I do not know where im going wrong
 

Attachments

Enivid

Administrator
Staff member
Nov 30, 2008
15,991
803
144
Odessa
www.earnforex.com
That's because you are comparing the buffer value to zero. They are EMPTY_VALUE when empty.
Also, you are accessing the buffer values as if they are not timeseries, the code explicitly calls ArraySetTimeseries on the buffers earlier, so you should be accessing the values like in MT4.
 

ogwedhi

Trader
Apr 8, 2021
12
1
6
39
That's because you are comparing the buffer value to zero. They are EMPTY_VALUE when empty.
Also, you are accessing the buffer values as if they are not timeseries, the code explicitly calls ArraySetTimeseries on the buffers earlier, so you should be accessing the values like in MT4.
Thank you. I change it to he code below and it still does not work. Where im I going wrong?
MQL5:
   if (((TriggerCandle > 0) && (time[0] > LastAlertTime)) || (TriggerCandle == 0))
   {
 
 
        string Text;
        // Up Arrow Alert
        if ((ExtMapBufferUp1[TriggerCandle] != EMPTY_VALUE) && ((TriggerCandle > 0) || ((TriggerCandle == 0) && (LastAlertDirection != 1))))
 
 
        {
                Text = AlertText + "Fm_Gain: " + Symbol() + " - " + EnumToString(Period()) + " - Buy.";
                if (EnableNativeAlerts) Alert(Text);
                if (EnableEmailAlerts) SendMail(AlertEmailSubject + "FM_Gain", Text);
                if (EnableSoundAlerts) PlaySound(SoundFileName);
                if (EnablePushAlerts) SendNotification(Text);
                LastAlertTime = time[0];
 
                LastAlertDirection = 1;
        }
 
        // Down Arrow Alert
        if ((ExtMapBufferDown1[TriggerCandle] != EMPTY_VALUE) && ((TriggerCandle > 0) || ((TriggerCandle == 0) && (LastAlertDirection != -1))))
 
        {
                Text = AlertText + "FM_Gain: " + Symbol() + " - " + EnumToString(Period()) + " - Sell.";
                if (EnableNativeAlerts) Alert(Text);
                if (EnableEmailAlerts) SendMail(AlertEmailSubject + "FM_Gain Alert", Text);
                if (EnableSoundAlerts) PlaySound(SoundFileName);
                if (EnablePushAlerts) SendNotification(Text);
                LastAlertTime = time[0];
 
                LastAlertDirection = -1;
        }
 
        }
   return(rates_total);
 
Last edited by a moderator: