i have this indicator, and i want to add it as a function to the EA. With the EA, my CPU is always at 100%, accessing this indicator from multi time frames, and multi pairs. I was thinking of including the indicator into the EA, so that the CPU usage is lower.
Below is the function i have written in the EA, from the indicator. The problem is returning one of three arrays, LR_Line, Sup_line and Res_line. How would the function return the values for all three arrays?
declare the array for parameter passing
double indicator(string line, bool UseClose, int barsToCount, double& LR_line[], double& Sup_line[],double& Res_line[])
declare the array for parameter passing
double indicator(string line, bool UseClose, int barsToCount, double& LR_line[], double& Sup_line[],double& Res_line[])
Would it be possible to return all three arrays?
yes, but on hindsight, u dont need the ampersand ie & since the passing is unidirection;
double indicator(string line, bool UseClose, int barsToCount, double LR_line[], double Sup_line[],double Res_line[])
what u need to take care is the arrayresizing
yes, but on hindsight, u dont need the ampersand ie & since the passing is unidirection;
double indicator(string line, bool UseClose, int barsToCount, double LR_line[], double Sup_line[],double Res_line[])
what u need to take care is the arrayresizing
sorry, i woke up early this morning and was stoned ; u do need the "&" as it is bi-direction ; the main module will call the indicator module and the & is needed to have the indicator module return the values of the arrays; so my first post is correct
sorry, i woke up early this morning and was stoned ; u do need the "&" as it is bi-direction ; the main module will call the indicator module and the & is needed to have the indicator module return the values of the arrays; so my first post is correct
lol, i got it working!
But now, when i compare the last value in any of the (3) arrays, to the value in the indicator, they are off. The calculations are the same, but for some reason the current value in the arrays is different. It is close when the time frame is lower, the higher the time frame, the higher the difference between the indicator values, and the values in the EA. Any ideas?
lol, i got it working!
But now, when i compare the last value in any of the (3) arrays, to the value in the indicator, they are off. The calculations are the same, but for some reason the current value in the arrays is different. It is close when the time frame is lower, the higher the time frame, the higher the difference between the indicator values, and the values in the EA. Any ideas?
did u do arrayresize?
did u do arrayresize?
no, i just declera arraysize of [200], that is it.
double LR_line[200]; double Sup_line[200]; double Res_line[200];
do this
extern int bars = 50;
double LR_line[];
double Sup_line[];
double Res_line[];
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
ArrayResize(LR_line,bars);
ArrayResize(Sup_line,bars);
ArrayResize(Res_line,bars);
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//----
indicator("xx",true,bars,LR_line,Sup_line,Res_line);
Comment(DoubleToStr(LR_line[0],Digits)+" "+DoubleToStr(Sup_line[0],
Digits)+" "+DoubleToStr(Res_line[0],Digits));
//----
return(0);
}
strongly suggest you read/digest this article series, the last article of which is here Transferring an Indicator Code into an Expert Advisor Code. Conclusion
The conclusion makes for pertinent reading regards your quest for speed...
hth
do this
extern int bars = 50;
double LR_line[];
double Sup_line[];
double Res_line[];
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
ArrayResize(LR_line,bars);
ArrayResize(Sup_line,bars);
ArrayResize(Res_line,bars);
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//----
indicator("xx",true,bars,LR_line,Sup_line,Res_line);
Comment(DoubleToStr(LR_line[0],Digits)+" "+DoubleToStr(Sup_line[0],
Digits)+" "+DoubleToStr(Res_line[0],Digits));
//----
return(0);
}
thx, bro, works like a charm, apreciate the help!
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
i have this indicator, and i want to add it as a function to the EA. With the EA, my CPU is always at 100%, accessing this indicator from multi time frames, and multi pairs. I was thinking of including the indicator into the EA, so that the CPU usage is lower.
Below is the function i have written in the EA, from the indicator. The problem is returning one of three arrays, LR_Line, Sup_line and Res_line. How would the function return the values for all three arrays?