- You can only show one comment. The for is unnecessary.
int count; // number of elements to copy CopyOpen(_Symbol,_Period,0,count,Open);
Count has a random value.for(int i = 1 ; i <= Bars ; i++){ double open = Open[i];
When i equals Bars, Open[i] does not exist. If there are n things they are numbered [0 .. n-1]- You set Open to as series. Therefor the newest value is index zero.
moslemS:
I want to show the closing price of the previous bar when it comes to the new bar
And I'm using this code to do this, but it's a mistake
I think for() has a problem
But I do not know what that problem is
No need to loop if all you want is the close price of the prev bar.
{ double c; if(LastBarClose(c)) printf("The close of the last bar is %f",c); } bool LastBarClose(double &value) { value = 0.0; static datetime last_bar = 0; static double close[1] = {0.0}; datetime curr_bar = (datetime)SeriesInfoInteger(_Symbol,_Period,SERIES_LASTBAR_DATE); if(curr_bar == last_bar) { value = close[0]; if(value > 0.0) return true; } last_bar = curr_bar; ArraySetAsSeries(close,true); if(CopyClose(_Symbol,_Period,1,1,close) > 0) value = close[0]; return value > 0.0; }
Double and triple posts removed. Please don't do that again.

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I want to show the closing price of the previous bar when it comes to the new bar
And I'm using this code to do this, but it's a mistake
I think for() has a problem
But I do not know what that problem is