Take into account the visibility of variables and arrays
I set them to global... Same error.
FAQ:
What kind of constants: MA_TALKING_LONG , MA_TALKING_SHORT ?
How do you declare them?
#define MA_TALKING_LONG 0// Машки расположены к покупке#define MA_TALKING_SHORT 1// Машки расположены к продаже#define MA_TALKING_FLAT -1// Машки указывают на флет
show the header (declaration) of this function GetStateMa() - the problem is there
Change it to GetStateMa(int signal){} should fix it
Well, here is the gist. One expert has corrected my Expert Advisor, it worked fine. My task was to open 1 order only for 4 different signals and each signal was generated and calculated separately. He fixed my Expert Advisor, but messed up its logic.
I started to analyze his code. His writing is brutal, I've been looking into it for the second day.
Before it went like this:
at the start:
int signal[4];
CalcSignals(signal);
if (!Trade(signal))
return (0);
And here are the functions to make it clear what's what:
//+-------------------------------------------------------------------------------------+//| Получение значений МА на двух соседних барах |//+-------------------------------------------------------------------------------------+double GetCurAndPrevMA(int maPeriod, double& prevMA)
{
prevMA = iMA(NULL, i_trading_TF, maPeriod, 0, MODE_EMA, MODE_CLOSE, 1);
return (iMA(NULL, i_trading_TF, maPeriod, 0, MODE_EMA, MODE_CLOSE, 0));
}
//+-------------------------------------------------------------------------------------+//| Получение положения машек между собой |//+-------------------------------------------------------------------------------------+void CalcSignals(int& signal[])
{
double ema365_1;
double ema365_0 = GetCurAndPrevMA(365, ema365_1);
for (int i = 0; i < 4; i++)
{
double ema1;
double ema0 = GetCurAndPrevMA(g_maPeriod[i], ema1);
signal[i] = SIGNAL_NO;
if (ema1 < ema365_1 && ema0 > ema365_0)
signal[i] = SIGNAL_BUY;
if (ema1 > ema365_1 && ema0 < ema365_0)
signal[i] = SIGNAL_SELL;
}
}
Generally speaking, it's a funny thing to see that a function as void should not return anything by definition but nevertheless it returns the value of an element of the arraysignal[i].
I wonder if experienced programmers often use this? Or is it too much?
Now I'm trying to write what I need seeing the tricks that are present in that Expert Advisor. Because we cannot do without arrays there.
Anyway, here's the gist. My Expert Advisor, which has been working fine for me, has been corrected by a pro. My task was to open only 1 order by 4 different signals and each signal was generated and calculated separately. He fixed my Expert Advisor, but messed up its logic.
I started to analyze his code. His writing is brutal, I've been looking into it for the second day.
Before it went like this:
at the start:
And here are the functions to make it clear what's what:
Generally speaking, it's a funny thing to see that a function as void should not return anything by definition but nevertheless it returns the value of an element of the array signal[i].
I wonder if experienced programmers often use this? Or is it too much?
Now I'm trying to write what I need seeing the tricks that are present in that Expert Advisor. Because we cannot do without arrays there.
Mislaid: It's often used, the secret inint& ,double&
I've already figured that out, but I think it's already a perversion. Why make a void function then? It is not logical. You need to return something... return it through a function of int, double type...
Here is my modify pending order function. When modifying, I set a new price and a new stoploss. The function works partially, but for some reason the tester is getting errors 1.
This function does not return anything, it operates on the elements of the array passed to it.
So if you pass elements to a function of the double orint type, it can also perform the same operations, but without any perversions. Why complicate your life?
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
What kind of constants: MA_TALKING_LONG , MA_TALKING_SHORT ?
How do you declare them ?
Take into account the visibility of variables and arrays
I set them to global... Same error.
What kind of constants: MA_TALKING_LONG , MA_TALKING_SHORT ?
How do you declare them?
show the header (declaration) of this function GetStateMa() - the problem is there
change it to GetStateMa(int signal){} should fix it
show the header (declaration) of this function GetStateMa() - the problem is there
Change it to GetStateMa(int signal){} should fix it
Well, here is the gist. One expert has corrected my Expert Advisor, it worked fine. My task was to open 1 order only for 4 different signals and each signal was generated and calculated separately. He fixed my Expert Advisor, but messed up its logic.
I started to analyze his code. His writing is brutal, I've been looking into it for the second day.
Before it went like this:
at the start:
And here are the functions to make it clear what's what:
Generally speaking, it's a funny thing to see that a function as void should not return anything by definition but nevertheless it returns the value of an element of the array signal[i].
I wonder if experienced programmers often use this? Or is it too much?
Now I'm trying to write what I need seeing the tricks that are present in that Expert Advisor. Because we cannot do without arrays there.
Anyway, here's the gist. My Expert Advisor, which has been working fine for me, has been corrected by a pro. My task was to open only 1 order by 4 different signals and each signal was generated and calculated separately. He fixed my Expert Advisor, but messed up its logic.
I started to analyze his code. His writing is brutal, I've been looking into it for the second day.
Before it went like this:
at the start:
And here are the functions to make it clear what's what:
Generally speaking, it's a funny thing to see that a function as void should not return anything by definition but nevertheless it returns the value of an element of the array signal[i].
I wonder if experienced programmers often use this? Or is it too much?
Now I'm trying to write what I need seeing the tricks that are present in that Expert Advisor. Because we cannot do without arrays there.
It's often used, the secret inint& ,double&
I've already figured that out, but I think it's already a perversion. Why make a void function then? It is not logical. You need to return something... return it through a function of int, double type...
What to do?
I've already figured that out, but I think it's already a perversion. Why make a void function then? It is not logical.
It is logical.
This function returns nothing, it performs operations on the elements of the array passed into it.
Here is my modify pending order function. When modifying, I set a new price and a new stoploss. The function works partially, but for some reason the tester is getting errors 1.
Is my function written correctly?
if((b_mod) && (priceB > Ask)) OrderModify(b_ticket,priceB,priceS,0,0,Brown);
if((s_mod) && (priceS < Bid)) OrderModify(s_ticket,priceS,priceB,0,0,Brown);
Here we should consider MarketInfo(Symbol(),MODE_STOPLEVEL) i.e.
priceB >= Ask+ MarketInfo(Symbol(),MODE_STOPLEVEL)*Point
priceS < =Bid- MarketInfo(Symbol(),MODE_STOPLEVEL)*Point
This makes sense.
This function does not return anything, it operates on the elements of the array passed to it.
So if you pass elements to a function of the double orint type, it can also perform the same operations, but without any perversions. Why complicate your life?