Edit: Nevermind, got it figured out.
I have an indicator I made for a strategy I found here on forexfactory. I am not a programmer by trade, so am slowly learning. The indicator looks correct when put on chart, but doesn't update once put on chart. I figure the problem has to do with arrays or functions, which I have tried to understand but have not been able to grasp.
The way the indicator was built:
1. I needed to find when NFP was released. It's the first Friday of the month usually, at 8:30 AM Eastern Time/7:30 AM Central Time (my time zone). I am using FXDD, so the hour and minutes in the indicator are set for Central time zone and FXDD platform (GMT + 2). Explanation: 4PM Central time is when the Forex day begins (Friday actually begins on Thursday evening in US). 8:30 AM Eastern is 7:30 AM Central, which is 15:30 FXDD server time. This is the start time I have set.
2. I needed to have a waiting of time to not start trading until Monday at midnight/Sunday 11PM Central, a "cooling-off" period from Friday at 7:30 AM Central time, through Friday to 4PM Central (8.5 hours), including the weekend (two days), plus from 4PM to 11PM Central Sunday night (7 hours). This waiting period will always be the same after the Start of NFP "cooling-off" period until the end of it.
3. I needed to get highest high and lowest low between the bars that these times referred to. I had to shift a bar to the right or left most of the time, to make sure I had the correct time as well as the correct bar chosen.
4. I drew vertical and horizontal lines and rectangles around the area.
5. I had to have the highest high and lowest low for the previous and current week, and found I needed to break out the last bar when counting the current week's high and low, because the current bar on the current chart would always be in within the weekly high and low when the current bar closed, so it would never be seen as a breakout. So I had to separate the current bar from the rest of the week for comparison, using iBarShift and High[iHighest] and Low[iLowest] functions from MQL documentation, to hopefully use this indicator in an EA (either by building it into the EA, or using iCustom function to access the indicator from the EA).
I have attached the indicator, and if you put it on a chart in MT4, it should look like the attached screenshot (or similar, the rectangles and lines will be different on different pairs, because the indicator uses the individual pair's qualities to form the lines and rectangles).
When NFP is released a week later than usual, I just put an external input that the user can make true to shift the NFP start one week to the right.
The only problem I'm having is I don't know enough about programming to get the indicator to update after it's placed on the chart, and until it's fixed, it's not even suitable for manual trading (unless the person wanted to manually update the indicator, which they wouldn't want to).
The attachments:
One gif that shows the way the indicator looks when I just placed it on EURUSD M30 chart in FXDD MT4, when zoomed all the way out on the chart.
One gif that shows zoomed in on the chart, where you can notice the way the current bar is not included in the magenta current week high/low rectangle, so that it can be compared.
The indicator that needs fixed.
Thank you for your help in advance.
BTW, the indicator's comments on chart do update correctly. It's the objects that are using the variables (that were also used to make the comments) that don't update correctly on chart for manual backtesting, or for automated trading.
Don
I have an indicator I made for a strategy I found here on forexfactory. I am not a programmer by trade, so am slowly learning. The indicator looks correct when put on chart, but doesn't update once put on chart. I figure the problem has to do with arrays or functions, which I have tried to understand but have not been able to grasp.
The way the indicator was built:
1. I needed to find when NFP was released. It's the first Friday of the month usually, at 8:30 AM Eastern Time/7:30 AM Central Time (my time zone). I am using FXDD, so the hour and minutes in the indicator are set for Central time zone and FXDD platform (GMT + 2). Explanation: 4PM Central time is when the Forex day begins (Friday actually begins on Thursday evening in US). 8:30 AM Eastern is 7:30 AM Central, which is 15:30 FXDD server time. This is the start time I have set.
2. I needed to have a waiting of time to not start trading until Monday at midnight/Sunday 11PM Central, a "cooling-off" period from Friday at 7:30 AM Central time, through Friday to 4PM Central (8.5 hours), including the weekend (two days), plus from 4PM to 11PM Central Sunday night (7 hours). This waiting period will always be the same after the Start of NFP "cooling-off" period until the end of it.
3. I needed to get highest high and lowest low between the bars that these times referred to. I had to shift a bar to the right or left most of the time, to make sure I had the correct time as well as the correct bar chosen.
4. I drew vertical and horizontal lines and rectangles around the area.
5. I had to have the highest high and lowest low for the previous and current week, and found I needed to break out the last bar when counting the current week's high and low, because the current bar on the current chart would always be in within the weekly high and low when the current bar closed, so it would never be seen as a breakout. So I had to separate the current bar from the rest of the week for comparison, using iBarShift and High[iHighest] and Low[iLowest] functions from MQL documentation, to hopefully use this indicator in an EA (either by building it into the EA, or using iCustom function to access the indicator from the EA).
I have attached the indicator, and if you put it on a chart in MT4, it should look like the attached screenshot (or similar, the rectangles and lines will be different on different pairs, because the indicator uses the individual pair's qualities to form the lines and rectangles).
When NFP is released a week later than usual, I just put an external input that the user can make true to shift the NFP start one week to the right.
The only problem I'm having is I don't know enough about programming to get the indicator to update after it's placed on the chart, and until it's fixed, it's not even suitable for manual trading (unless the person wanted to manually update the indicator, which they wouldn't want to).
The attachments:
One gif that shows the way the indicator looks when I just placed it on EURUSD M30 chart in FXDD MT4, when zoomed all the way out on the chart.
One gif that shows zoomed in on the chart, where you can notice the way the current bar is not included in the magenta current week high/low rectangle, so that it can be compared.
The indicator that needs fixed.
Thank you for your help in advance.
BTW, the indicator's comments on chart do update correctly. It's the objects that are using the variables (that were also used to make the comments) that don't update correctly on chart for manual backtesting, or for automated trading.
Don
Attached File(s)
NFP_indi_Don4.mq4
23 KB
|
263 downloads