if (DayOfYear() == DayOfYear()) ... if ( X == X ) // Always true.Search new bar and substitute DayOfYear for Time[0]
I was having a tough time with understanding and figuring a way with the reco above. So with further effort I came up with this method: The problem is the count seems to take place (+1) then after a few seconds, returns to 0. Would anyone be able to guide me to understand what I am doing wrong?
int DB_Orders_Closed; int start() { if(Hour()==0&&Minute()<2){DB_Orders_Closed=0;};//to reset the value to 0 daily //code to close orders DB_Orders_Closed++;//to increment after the orders close
I was having a tough time with understanding and figuring a way with the reco above. So with further effort I came up with this method: The problem is the count seems to take place (+1) then after a few seconds, returns to 0. Would anyone be able to guide me to understand what I am doing wrong?
Still struggling with this one, would anyone know how to correct this?
What part of "Search new bar and substitute DayOfYear for Time[0]" was unclear?
The "Search new bar" part.
The "Search new bar" part.
static datetime bar_time=0; if(bar_time!=Time[0]) { bar_time=Time[0]; //Code to be executed once per bar }
Once per bar
static int day_of_year=0; if(day_of_year!=DayOfYear()) { day_of_year=DayOfYear(); //Code to be executed once per day }
Once per day
Note that if you change time frames or re-initialise an indicator for any reason, the static variable will be re-set.
In an EA it will only be reset if the EA is removed and re-Attached or the terminal is re-started

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi there I am trying to track an even that when true the count will increment 1 and provide totals for the day, then reset when the (server time) day ends.
I thought was pretty simple by placing the below code after the event proves true, but the counts are too high to be correct so the code is clearly flawed.
Any help would be appreciated. :)
if (DayOfYear()==DayOfYear())DB_Orders_Closed++;