Try adding top indicator
#property indicator_buffers 2 #property indicator_plots 2
Thanks for the response, ive added it, and chart_window, label1, like in the code above. But the results did not change..
The code fills 10 cells in the buffers - 0..10 but as the buffer is not defined AsSeries, those are the left bars, not the most recent ones.
Add in OnInit
ArraySetAsSeries(Support,true);
ArraySetAsSeries(Resistance,true);
And OnCalculate
ArraySetAsSeries(price,true);
The code fills 10 cells in the buffers - 0..10 but as the buffer is not defined AsSeries, those are the left bars, not the most recent ones.
Add in OnInit
And OnCalculate
@Amir Yacoby Thanks for the idea's..
I already added setindexbuffer inside OnInit.
I am not using the price array to get the bids. I'm using symbolinfodouble to get the bid. I now tried setting bid = price[1], whilst ArraySetAsSeries(price,true).
The above did not fix the issue...
I dont think that it has anything to do with time series, as when printing the buffers inside the indicator i do get the correct values. But when using copybuffer inside EA it returns 0.0. Please correct me if im wrong.
@Amir Yacoby Thanks for the idea's..
I already added setindexbuffer inside OnInit.
I am not using the price array to get the bids. I'm using symbolinfodouble to get the bid. I now tried setting bid = price[1], whilst ArraySetAsSeries(price,true).
The above did not fix the issue...
I dont think that it has anything to do with time series, as when printing the buffers inside the indicator i do get the correct values. But when using copybuffer inside EA it returns 0.0. Please correct me if im wrong.
ArraySetAsSeries(Support,true);
ArraySetAsSeries(Resistance,true);
I dont think that it has anything to do with time series, as when printing the buffers inside the indicator i do get the correct values. But when using copybuffer inside EA it returns 0.0. Please correct me if im wrong.
Of course it has anything to do with the time series.
You see it in the indicator, but how does the EA copying the data array should know which side is the current prices and which side is the former.
Your original code was filling the 0..10 indexes(when the timeseries was false it means that for the EA those were indexes rates_total-1 until the rates_total-11 data - those are the far left prices on the chart)- which can be many years back.
Your indicator printed it correctly, but it didn't care the prices are so old.
Your EA tries to read the current prices(from the right side of the chart)- indexed 0..2 but those were not filled.
Another thing, you create 10 OBJ_HLINE objects on each tick, I don't know what you are trying to do here but you will do the work only on the first tick, and all the next ones will be trying to create duplicate objects.
* Also you can unite the two loops to one, having the same from-to-end condition:
for(int i=1; i<MaxLines; i++){ RoundedNumberResistance += Precision; RoundedNumberSupport -= Precision; Resistance[i] = RoundedNumberResistance; Support[i] = RoundedNumberSupport; ObjectCreate(0,"Resistance"+i,OBJ_HLINE,0,0,Resistance[i]); ObjectSetInteger(0,"Resistance"+i,OBJPROP_COLOR,ResistanceCLR); ObjectCreate(0,"Support"+i,OBJ_HLINE,0,0,Support[i]); ObjectSetInteger(0,"Support"+i,OBJPROP_COLOR,SupportCLR); //Print(i, " ",Resistance[i]," ", Support[i]); }
int OnInit(){ SetIndexBuffer(0,Support,INDICATOR_DATA); SetIndexBuffer(1,Resistance,INDICATOR_DATA); PlotIndexSetString(0,PLOT_LABEL,"Support"); PlotIndexSetString(1,PLOT_LABEL,"Resistance"); ArraySetAsSeries(Support,true); ArraySetAsSeries(Resistance,true); return(INIT_SUCCEEDED); }
Stupid mistake.
int OnCalculate( const int rates_total, // price[] array size const int prev_calculated, // number of handled bars at the previous call const int begin, // index number in the price[] array meaningful data starts from const double& price[]){ // array of values for calculation ArraySetAsSeries(price,true); double bid = price[0]; //SymbolInfoDouble(_Symbol,SYMBOL_BID); double NumberToRound = bid;
@Amir Yacoby thank you for your time.

- 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, I made an indicator that shows the round number s/r levels on a chart.
I wanted to use it inside an EA, but when i tried to use copybuffer the array thats copied to, returned 0.0.
I checked the indicator arrays, they return correct value.
I tried setting the size of the array, inside EA and indi, no luck.
I checked if copybuffer returned a bool which would equal that it copied correctly, it returns the amount copied.
I checked the EA arrays, which return 0.0 after it copied correctly.
I tried looping over the objects and writing their price values into a separate array, it returned 0.0 again.
I checked if EA and Indi return any error, by printing, there are none.
this is the EA code:
this is the indicator code:
If someone could help me, its much appreciated. Thank you for your time.