Questions from Beginners MQL5 MT5 MetaTrader 5 - page 439

 
Leanid Aladzyeu:
...
How can I get the values of the arrays without calling the function? Or how to make an array remember the last values that were written?
...


In order to retrieve something from an array, you must first write this "something" to the array.

Leanid Aladzyeu:
...
Or how to make an array remember the last values that were written?
...
For which conditions: Should the array be saved when the timeframe is switched or after reloading of the terminal?
 
Karputov Vladimir:


If I want to take something from an array, I first have to write it into the array.

For which conditions: should the array be saved when switching the timeframe of the chart or after reloading the terminal?

not during the work of the EA

If I set returnee in the function, when there is an order in the market, it gives me null arrays (I set returnee before nulling arrays),

 
Leanid Aladzyeu:

If an order is on the market it gives me zero arrays (I set the returnee before the arrays are zeroed),

What are the arrays the order "gives"? Where are they declared and where are they filled in? Also, please insert the code correctly.
 
Karputov Vladimir:

The function parameters must be reverted back to the original version, otherwise they simply won't be called:

Here is the code of the standard SignalAC file

//+------------------------------------------------------------------+

//| "Voting" that price will grow. |

//+------------------------------------------------------------------+

int CSignalAC::LongCondition(void)

I understand it this way: the code sends a signal and the parametersdouble& price,double& sl,double& tp,datetime& expiration are needed to place an order,

this is handled by another EA block?

 

corrected the code to a variant:

int CSampleSignal::ShortCondition(void)

The expert started to do something, thanks for the tip!

 
pr0gre5:

corrected the code to a variant:

int CSampleSignal::ShortCondition(void)

The expert started to do something, thanks for the tip!

You are welcome. Ask, ask when and where you need it :)
 

Such a question does this code serve to limit the calculation - counting only once on a new bar?

static datetime TimeN=0;
   datetime TimeC=iTime(NULL,TF,0);
   if(TimeN==0)TimeN=TimeC;
   if(TimeN==TimeC) return(0);

 
-Aleks-:

Such a question is this code used to limit the calculation - only count once on a new bar?

static datetime TimeN=0;
   datetime TimeC=iTime(NULL,TF,0);
   if(TimeN==0)TimeN=TimeC;
   if(TimeN==TimeC) return(0);

If the new bar is on an M1 timeframe, then we print a message:

//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   static datetime TimeN;
   datetime TimeC=iTime(NULL,PERIOD_M1,0);
   if(TimeN==TimeC)
      return;
   TimeN=TimeC;
// новый бар, выполняем код
   Print("New bar");
   return;
  }
 
Karputov Vladimir:

If the new bar is on the M1 timeframe, print a message:

So I'm right, this is a check for a new bar?
 
-Aleks-:
So I'm right, it's a new bar check?
If you mean my code - then yes, my code is a new bar check.