IBarShift finds the bar with the specified time. It doesn't matter what the prices are. I doubt you. Post the code.
Also if there are no ticks during a bar's duration there is no bar to find. No bars on the weekend, and M1 can frequently have missing bars.
Test that for exemple.
If like me you have on your chart for USDCHF 2 plate candle, you will get with print EURUSD : 229 and USDCHF : 227
//+------------------------------------------------------------------+ //| test2.mq4 | //| Copyright 2012, MetaQuotes Software Corp. | //| http://www.metaquotes.net | //+------------------------------------------------------------------+ #property copyright "Copyright 2012, MetaQuotes Software Corp." #property link "http://www.metaquotes.net" #property indicator_chart_window extern string BeginYear = "2012"; extern string BeginMonth = "10"; extern string BeginDay = "01"; extern string BeginHour = "00"; extern string BeginMinute = "00"; int ShiftBars1; int ShiftBars2; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { datetime TimeOfBegin = StrToTime(BeginYear+"."+BeginMonth+"."+BeginDay+" "+BeginHour+":"+BeginMinute); Comment(BeginYear+"/"+BeginMonth+"/"+BeginDay+" "+BeginHour+"H:"+BeginMinute+"Min"); ShiftBars1=iBarShift("EURUSD",PERIOD_M5,TimeOfBegin); Print("Bar de "+"EURUSD"+" : "+ ShiftBars1); ShiftBars2=iBarShift("USDCHF",PERIOD_M5,TimeOfBegin); Print("Bar de "+"USDCHF"+" : "+ ShiftBars2); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int counted_bars=IndicatorCounted(); //---- //---- return(0); } //+------------------------------------------------------------------+
Test that for exemple.
If like me you have on your chart for USDCHF 2 plate candle, you will get with print EURUSD : 229 and USDCHF : 227
<SNIP>
Test that for exemple.
If like me you have on your chart for USDCHF 2 plate candle, you will get with print EURUSD : 229 and USDCHF : 227
It is possible to have no ticks for 5 minutes and hence have missing bars.
Allright, there is no way to get it with iBarShift, can I divide like that : (the current time - time of the beginning for my indcator)/ the time frame
Allright, there is no way to get it with iBarShift, can I divide like that : (the current time - time of the beginning for my indcator)/ the time frame
/* extern string BeginYear = "2012"; extern string BeginMonth = "10"; extern string BeginDay = "01"; extern string BeginHour = "00"; extern string BeginMinute = "00"; */ extern datetime TimeOfBegin = D'2012.10.01 00:00';
.
Post the code AND the results. Our charts are not going to equal your charts, different broker, different ticks. Post the shift, the TimeToStr(Time[shift]), the OHLC of the shift. and TimeToStr(Time[shift+1) and shift-1. There are no mind readers here.
Do you have M5 history, are you running on the tester?
Stop saying that, you are wrong. Figure out why.
(currtime-beginning time)/time frame does not handle missing bars, weekends, etc.
Post the code AND the results. Our charts are not going to equal your charts, different broker, different ticks. Post the shift, the TimeToStr(Time[shift]), the OHLC of the shift. and TimeToStr(Time[shift+1) and shift-1. There are no mind readers here.
Do you have M5 history, are you running on the tester?
Stop saying that, you are wrong. Figure out why.
(currtime-beginning time)/time frame does not handle missing bars, weekends, etc.
Thank you, yes I'm wrong, with that logic.
I don't want to post all my code here, but the problem is : my indicator do not take in count the bar which are "plate", I mean the when OHLC are all the same on a candle..
My way to declare my variable datetime is good, because the indicator work well, but because of that problem, it doesn't return the good value on certain pairs on certains periods of time.
My broker is FxOpen ECN, on demo account, find some plate candle with your broker or download FxOpen and try the code I gave you and you will see, the print for the 2 variables ShiftBars1 and ShiftBars2 are not the same.
Give me what you have find please...
Thanks
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello,
When i use the function iBarShift, if a bar is "plate", I mean there is no price movement, open, close, low, and hight are all the same, this bar is not counted.
So the number of bar can be different, of what it is really.
Do you know a solution to rule this problem?
Thanks.