I'm having issues with the iCustom command. Basically it's working sometimes and not others, which I find a little bizarre. Here is my code.
i = 1;
while (i <= 6)
if (i != 0)
Value1[i] = NormalizeDouble(iCustom(NULL,0,"Super Trend","",44,3,3000,"",false,0,i),Digits);
Value2[i] = NormalizeDouble(iCustom(NULL,0,"Super Trend","",44,3,3000,"",false,1,i),Digits);
if ((Value1[i] < 200) && (Value2[i] < 200))
SuperTrend[i] = Value1[i];
STDirection[i] = "Switching";
else if (Value1[i] < 200)
SuperTrend[i] = Value1[i];
STDirection[i] = "Bullish";
else if (Value2[i] < 200)
SuperTrend[i] = Value2[i];
STDirection[i] = "Bearish";
SuperTrend[i] = 666;
STDirection[i] = "Failed";
Print("Value1[",i,"] = ",Value1[i]);
Print("Value2[",i,"] = ",Value2[i]);
Print("STDirection = ",STDirection," (",STDirection,")");
Print("SuperTrend = ",SuperTrend);
Print("Value1 = ",Value1);
Print("Value2 = ",Value2);
/*if (STDirection == "Switching")
If its not important , or the indicator does not repaint , do you need to scan the latest 6 bars constantly?
From looking at the code i will assume you have a "new bar" filtering system in "OnTick"
I'm not expert in MT4, but, just my observations...
The problem is with the iCustom call, and I'm pretty sure I now know WHAT the problem is, I just don't know how to fix it. When I run the indicator on a chart is draws a line from it's buffers. But occasionally it will fail and stop keeping up with the chart, meaning that I have to reinitialise the indicator to see the line. I'm wondering if there's some problem with the actual indicator (I don't have the source code for it) that makes it stop working after a certain amount of time and this is why the code I've written works for a few hours then suddenly just stops and only reads as an empty buffer value, and also that it starts working again when I recompile it.
The assumptions I am making are that my use of the iCustom command is essentially correct, and that when iCustom is used in a script the indicator it is reading from is initialised ONLY when the script is initialised, and not every time the iCustom function is called within the script.
If the second of those assumptions is correct, is there a way to make it reinitialise the indicator every time iCustom is called?
Don't mix your terminology. Are you using a script? How can you recompile if you don't have the source code?
It may be that your Super Trend indicator has problems.
This may suit you and will not need constantly re-initializing.
Check if the output is the same.
I reinitialise the indicator, and recompile my EA. Correct terminology used (I believe) in each case, sorry if it was confusing.