#property indicator_separate_window #property indicator_buffers 2
input int rsiPeriod = 14; // RSI Period
SetIndexBuffer(0,val,INDICATOR_DATA); SetIndexBuffer(1,rsiVal,INDICATOR_CALCULATIONS);
//ArraySetAsSeries(rsiVal, true); if(CopyBuffer(rsiHandle,0,0,rates_total,rsiVal)<0) { Alert("Error copying indicator Buffers - error:",GetLastError(),"!!"); } int i= prev_calculated-1; if (i<0) i=inpPeriod; for (; i<rates_total && !_StopFlag; i++) { //val[i] = iHull.calculate(getPrice(inpPrice,open,high,low,close,i),i,rates_total); val[i] = iHull.calculate(rsiVal[i],i,rates_total); //double x=val[i]; }It is not a good practice to copy everything every time.
Nagisa Unada #:
It is not a good practice to copy everything every time.
It is not a good practice to copy everything every time.
I know, its just I cannot wrap my head around OnCalculate() function. My code works, iHull.calculate with my parameters returns correct value. When debugging x is the Hull of RSI. I don't understand how to make indicator return this value
Files:
2.png
55 kb
"val" is a global variable, so it can be used as is within other functions.
double x=val[i];

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
What I am trying to do is to have an indicator that will calculate Hull MA of RSI to use in EA. I am very new to MQL5 and not a good programmer in general, so I found this Hull MA script in code library that calculates Hull MA and was trying to substitute price data for RSI values. Here is the original code https://www.mql5.com/en/code/25257.
What I've done with the code is added RSI handle and changed that line that calculates Hull MA value:
When debugging, val[i] returns correct Hull MA value, however if applied to chart its all wrong. Most of the times it equals 0. It doesn't plot the graph, but i dont need it to, I simply need the value.
I would really appreciate your help.