[ARCHIVE]Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Can't go anywhere without you - 5. - page 54

 

What kind of constants: MA_TALKING_LONG , MA_TALKING_SHORT ?

How do you declare them ?

 
Vinin:

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

 
FAQ:

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 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.

 
Тhoz:

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.

Used frequently, secret in int& , double&
 
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...

 
An error has occurred when debugging the printer:
2013.01.06 21:06:32     2011.11.28 00:20  Base150 EURUSD,M5: not enough stack for parameter

What to do?

 
hoz:

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.

 
hoz:

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

 
PapaYozh:

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?