date bartime=0

 

Hi,

I'm trying to creat a new ea but I would like to have an advice.

in the input parameters (just before the expert initialization function) I want to put : date bartime=0

Does someone could confirm me that this line of code means that when the program is starting, it starts at the actual bar? If I'm wrong could you please tell me what date bartime=0 stand for?

Many thanks

Joe

/---- input parameters
extern int RSI_Period = 14;
extern int SMA_Period = 10;
extern double Lots = 1;
extern int SL = 50;
extern int TP = 100;
extern int MagicNumber = 2975;
extern int Slippage = 3;

datetime bartime = 0;

//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+

 

That line will create a variable of datetime type with a value of 0 (which is actually midnight 1st Jan 1970). If you want the current chart time bartime=Time[0]; but you will need to put that inside init() or start() as you can't have an expression on the global scope.

https://book.mql4.com/basics/types#14

hth

V

 

Hi Viffer,

Thanks for you fast answer.

 

Viffer,

My ea buy when close is above sma 10 and when rsi(14)> 60.

Could you please help me to translate the lines of code I put in bold made by a developper about my system ? I can't understand why the value are 0, -1 .

I tried to finbd something on the book but I found anything related to this case.

Thanks

//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
double dRSI;
double dSMA;
int nOrderTicket = 0;
int nOrderType = -1;
int nTradesNumber = 0;
int nLongs = 0;
int nShorts = 0;
int iTicket = 0;
double sl = 0, tp = 0;

nLongs = GetLongsNumber();
nShorts = GetShortsNumber();
nTradesNumber = nLongs + nShorts;

 

These are just variables being declared in the code. I assume they are being populated later in your code. Assuming nOrderType is going to be populated with OrderType(), order types start at 0 so -1 is in effect no value...

https://book.mql4.com/appendix/trading

V

Reason: