Just use the buffer values. FirstBuffer[index]=value; SecondBuffer[index]=FirstBuffer[index]*2;
Show us your code.
int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { //--- if(rates_total<2) return(0); int start; //--- clean up arrays if(prev_calculated<3) { start=1; ArrayInitialize(highsBuffer,EMPTY_VALUE); ArrayInitialize(HhighsBuffer,EMPTY_VALUE); ArrayInitialize(exbuffer,EMPTY_VALUE); } else start=rates_total-1; for(int i=start ; i<rates_total-1 && !IsStopped(); i++) { if (high[i]>high[i+1] && high[i]>=high[i-1]) highsBuffer[i]=high[i]; else highsBuffer[i]=EMPTY_VALUE; } for(int m=start,j=m,g=m ; m<rates_total-1 && !IsStopped(); ++m) { while (highsBuffer[m]!=EMPTY_VALUE) m++; if (m>rates_total) break; return(m); j=m+1; while (highsBuffer[j]!=EMPTY_VALUE) j++; return(j); g=j+1; while (highsBuffer[g]!=EMPTY_VALUE) g++; return(g); if(highsBuffer[j]>highsBuffer[m] && highsBuffer[j]>=highsBuffer[m]) //{ HhighsBuffer[j]=highsBuffer[j]; else HhighsBuffer[j]=EMPTY_VALUE; } //--- return value of prev_calculated for next call return(rates_total); }
Please, insert the code correctly: when editing a message, press the button and paste your code into the pop-up window
You can always attach a code using the button
Just use the buffer values. FirstBuffer[index]=value; SecondBuffer[index]=FirstBuffer[index]*2;
Show us your code.
maybe it would work with 2 dimension array. i give it a try meanwhile any worthy comment would be appreciated.
LIVE LONG AND PROSPER V
-
highsBuffer[i]=high[i];
You never set your arrays to as-series to match your buffers. ArraySetAsSeries
-
Arrays must be manually sized. They have no direction. You must move elements if you want a stack/as-series (set non-series, enlarge the array, set as-series).
-
Buffers are automatically size, are as-series, and elements are moved for you, new elements are set to EMPTY_VALUE (or your designated. They can also draw on the chart automatically.
-
In MT4, buffers and the predefined arrays are all ordered AsSeries. There is a difference between the arrays passed to OnCalculate (e.g. low[]) and the MT4 predefined variables (e.g. Low[].) The passed arrays have no default direction, just like MT5.
To determine the indexing direction of time[], open[], high[], low[], close[], tick_volume[], volume[] and spread[], call ArrayGetAsSeries(). In order not to depend on default values, you should unconditionally call the ArraySetAsSeries() function for those arrays, which are expected to work with.predefined variables (e.g. Low[].) The passed arrays have no default direction, just like MT5.
Event Handling Functions - Functions - Language Basics - MQL4 Reference -
In MT5, you must set the direction.
To define the indexing direction in the time[], open[], high[], low[], close[], tick_volume[], volume[] and spread[] arrays, call the ArrayGetAsSeries() function. In order not to depend on defaults, call the ArraySetAsSeries() function for the arrays to work with.
Event Handling / OnCalculate - Reference on algorithmic/automated trading language for MetaTrader 5
-
-
for(int m=start,j=m,g=m ; m<rates_total-1 && !IsStopped(); ++m) { while (highsBuffer[m]!=EMPTY_VALUE)
You are accessing your buffer as non-series, just don't set that.
-
for(int m=start,j=m,g=m ; m<rates_total-1 && !IsStopped(); ++m) { while (highsBuffer[m]!=EMPTY_VALUE) m++; if (m>rates_total) break; return(m); j=m+1; while (highsBuffer[j]!=EMPTY_VALUE) j++; return(j); g=j+1; while (highsBuffer[g]!=EMPTY_VALUE) g++; return(g); if(highsBuffer[j]>highsBuffer[m] && highsBuffer[j]>=highsBuffer[m]) //{ HhighsBuffer[j]=highsBuffer[j]; else HhighsBuffer[j]=EMPTY_VALUE; } //--- return value of prev_calculated for next call return(rates_total);
everything after the first return are irrelevant.
- 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 guys,
wish you are well and prosper.
i would like to use a calculated buffer values to calculate another buffer in same indicator how should i do that, i try iCustom function but it didn't work. it would be great if anyone has an idea.