Hello.
So I am still a newb, and have obviously screwed something up with my script, but I am not sure what?
My main program is a bit more complicated, but I've stripped this down as much as I can, to replicate the problem, and created a similar logic(just for the purposes of this question).
This program simply takes a 14 and 1 period SMA based on the lows, and when the 1-period, breaks below the 14-period, it records the lowest price achieved before the 1-period breaks back above the 14-period. Once I have this information, I store the Time and price of this lowest occurrence(this point is drawn on the chart with the yellow circles) into an array.
Next, once that infomation is stored, I simply wait for price to CLOSE below that previously recorded time and price which can happen anytime in the future, and then subsequently wait for price to CLOSE back above that level. Once this happens, I draw a line from the yellow circle, to the point where price closes back above it.
You can see this in the image labeled "1."
THe issue I am having, is that when I open my MT4 platform and have this indie on a chart, sometimes it draws erroneous lines. You can see this in the image labeled "2."
However, if I recompile the indie, or switch Timeframes back and fourth, it works perfectly. In real time, as long as the indicator has been added to the chart, it works perfectly. If the chart is blank, and I add the indie, it works perfectly. After switching Timeframes and reloading the chart, you should see how this chart SHOULD look, in the image labeled "3." In the third image, you can see the erroneous lines are gone.
The issue is just after I reopen MT4 with the indicator previously having been on the chart.
Just a few notes... my indicator is calculated onBarClose... I.e., I am only performing calculations once a brand new bar opens, once per bar.
So I am wondering, if there is a convention I am missing to deal with this type of situation? Should I add something to make the chart reload automatically every time MT4 is opened?
As mentioned, I've added a simplified, stripped down version of my script that reproduces this problem. Is there something I'm missing?
So I am still a newb, and have obviously screwed something up with my script, but I am not sure what?
My main program is a bit more complicated, but I've stripped this down as much as I can, to replicate the problem, and created a similar logic(just for the purposes of this question).
This program simply takes a 14 and 1 period SMA based on the lows, and when the 1-period, breaks below the 14-period, it records the lowest price achieved before the 1-period breaks back above the 14-period. Once I have this information, I store the Time and price of this lowest occurrence(this point is drawn on the chart with the yellow circles) into an array.
Next, once that infomation is stored, I simply wait for price to CLOSE below that previously recorded time and price which can happen anytime in the future, and then subsequently wait for price to CLOSE back above that level. Once this happens, I draw a line from the yellow circle, to the point where price closes back above it.
You can see this in the image labeled "1."
THe issue I am having, is that when I open my MT4 platform and have this indie on a chart, sometimes it draws erroneous lines. You can see this in the image labeled "2."
However, if I recompile the indie, or switch Timeframes back and fourth, it works perfectly. In real time, as long as the indicator has been added to the chart, it works perfectly. If the chart is blank, and I add the indie, it works perfectly. After switching Timeframes and reloading the chart, you should see how this chart SHOULD look, in the image labeled "3." In the third image, you can see the erroneous lines are gone.
The issue is just after I reopen MT4 with the indicator previously having been on the chart.
Just a few notes... my indicator is calculated onBarClose... I.e., I am only performing calculations once a brand new bar opens, once per bar.
So I am wondering, if there is a convention I am missing to deal with this type of situation? Should I add something to make the chart reload automatically every time MT4 is opened?
As mentioned, I've added a simplified, stripped down version of my script that reproduces this problem. Is there something I'm missing?
Attached File(s)
FF_ScriptHelp.mq4
12 KB
|
175 downloads