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
functions
hi...
in MQL4 funtion can return array?
like
double *MyFunc()
{
double A[];
// make A calculationhere
return(A);
}
are my calculation is correct?
double yesterdayHigh = iHigh(NULL, 0, Current + 1);
double yesterdayLow = iLow(NULL, 0, Current + 1);
double yesterdayClose = iClose(NULL, 0, Current + 1);
double pivot = (yesterdayHigh + yesterdayLow + yesterdayClose) / 3;
double todayOpen = iOpen(NULL, 0, Current);
double todayGap = (todayOpen - pivot + pivot); <---it's correct?
TakeProfit = MathAbs(todayGap);
please help me?
hi...
in MQL4 funtion can return array?
like
double *MyFunc()
{
double A[];
// make A calculationhere
return(A);
}Yes of course.
Can calculate different arrays.
Something like:
MACDBuffer=iMA(NULL,0,FastMA,0,MA_Method,Applied_Price,i)-iMA(NULL,0,SlowMA,0,MA_Method,Applied_Price,i);
//---- signal line counted in the 2-nd buffer
for(i=0; i<limit; i++)
SignalBuffer=iMAOnArray(MACDBuffer,Bars,SignalEMA,0,MA_Method,i);double yesterdayHigh = iHigh(NULL, 0, Current + 1);
double yesterdayLow = iLow(NULL, 0, Current + 1);
double yesterdayClose = iClose(NULL, 0, Current + 1);
double pivot = (yesterdayHigh + yesterdayLow + yesterdayClose) / 3;
double todayOpen = iOpen(NULL, 0, Current);
double todayGap = (todayOpen - pivot + pivot); <---it's correct?
TakeProfit = MathAbs(todayGap);
please help me?My choice would be:
double todayGap = 2*pivot+todayOpen; <---it's correct?
do any source code is suitable on above calculations instead of mine?
please change anything inside the ea, please... i'm not a good programmer
thanks
here's the eaSorry, EA code? maybe here.
https://www.mql5.com/en/forum/177365
Find Trend based on last 2 bars
Hi all,
I'm just learning MQL and would like to know the easiest way to find out if a trend is going long or short based on the last 2 bars.
For example, if the close price is 1.2345 for Close[2] and the close price is 1.2350 for Close[1], and the current Close price is 1.2360 for Close[0].
Would I do something like
if(Close[2] < Close[1] && Close[1] < Close[0]) {
}
and do the same for a down trend but reversed
Or is there a more professional way to do it.
Thanks for your help
Nudge
Hi all,
I'm just learning MQL and would like to know the easiest way to find out if a trend is going long or short based on the last 2 bars.
For example, if the close price is 1.2345 for Close[2] and the close price is 1.2350 for Close[1], and the current Close price is 1.2360 for Close[0].
Would I do something like
if(Close[2] < Close[1] && Close[1] < Close[0]) {
}
and do the same for a down trend but reversed
Or is there a more professional way to do it.
Thanks for your help
NudgeWhat do you mean by "professional way"?
Every coder has a different logic and different way to code their ideas.
And the simpler is better! I think your code is quiet simple, I don't know how to make it simpler.
Yes of course.
Can calculate different arrays.
Something like:well Linuxser... i have this idea for code
int start()
{
double A = iMAOnArray(GetArray(1),10,5,0,MODE_EMA,0);
double B = iMAOnArray(GetArray(2),10,5,0,MODE_EMA,1);
Print("A= ",A," B=",B);
return(0);
}
double *GetArray(double Factor) // how to define a funcion return as array
{
double Arr[10];
for(int i=0;i<10;i++) Arr = i*Factor;
return(Arr);
}
this code is possible?
if yes, think, a lot of way for systems....
regards
Hi all,
I'm just learning MQL and would like to know the easiest way to find out if a trend is going long or short based on the last 2 bars.
For example, if the close price is 1.2345 for Close[2] and the close price is 1.2350 for Close[1], and the current Close price is 1.2360 for Close[0].
Would I do something like
if(Close[2] < Close[1] && Close[1] < Close[0]) {
}
and do the same for a down trend but reversed
Or is there a more professional way to do it.
Thanks for your help
NudgeWhat do you mean by "professional way"?
Every coder has a different logic and different way to code their ideas.
And the simpler is better! I think your code is quiet simple, I don't know how to make it simpler.I thought there may be a function already in MQL that does this and I have not found it yet.
Thanks for your reply, much appreciated.