i am trying to get the period separator on h4 , but there seems to be something wrong with my logic , i keep getting Array out of range error.
This is my code :
Any suggestions , what i am doing wrong ?
I have no idea what you are trying to achieve, but try
if(bari>-1) { ObjectCreate(0,"zxc",OBJ_VLINE,0,Time[bari],0); ObjectSetInteger(0,"zxc",OBJPROP_COLOR,clrRed); ObjectSetInteger(0,"zxc",OBJPROP_STYLE,STYLE_SOLID); }
- Arad_1: i am trying to get the period separator on h4
The separator on the H4 is the beginning of the week.
int OnCalculate(…){ if( !download_history(PERIOD_W1) ) return prev_calculated; datetime BOW = iTime(_Symbol, PERIOD_W1, 0); // Beginning of the Week ObjectCreate(0,"zxc",OBJ_VLINE,0,BOW,0);
-
Why are you creating a VLine instead of just turning on the separator?
On MT4: Unless the current chart is that specific symbol(s)/TF(s) referenced, you must handle 4066/4073 errors before accessing candle/indicator values.
Download history in MQL4 EA - Forex Calendar - MQL4 programming forum - Page 3 #26.4 2019.05.20
I have no idea what you are trying to achieve, but try
you were spot on .... it seems like the loop was running 4000 times instead of running only 50 times , because it wrapped into another for loop (my mistake) making the variable value more then there were candles on the chart
thanks
-
The separator on the H4 is the beginning of the week.
-
Why are you creating a VLine instead of just turning on the separator?
On MT4: Unless the current chart is that specific symbol(s)/TF(s) referenced, you must handle 4066/4073 errors before accessing candle/indicator values.
Download history in MQL4 EA - Forex Calendar - MQL4 programming - Page 3 #26.4 2019.05.20
Thanks William Roeder , This line of code saved me a lot of headache :
datetime BOW = iTime(_Symbol, PERIOD_W1, 0); // Beginning of the Week
i dont know what i was smoking that i didnt think of this , i was making it needlessly longer then it needed to be , i wrote 5 conditions to first calculate which week it is by getting the day() and then runnig one for loop per condition making it needlessly long when all of that could be replaced by one line above
as for " Why are you creating a VLine instead of just turning on the separator?" the vline is only for the visuals , and its just the tip of the iceberg , my main motive is to calculate keep indicator calculations and indicator's signals with in one period, so i am using this "bari" variable as the limit in another for loop where the indicator is calculating some conditions , i had got it to work on other timeframes , but weekly period for h4 was giving me a bit of a hard time since there isnt any function like TimeMonth(Time[i]) for the week
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
i am trying to get the period separator on h4 , but there seems to be something wrong with my logic , i keep getting Array out of range error.
This is my code :
Any suggestions , what i am doing wrong ?