Questions from Beginners MQL4 MT4 MetaTrader 4 - page 59

 
Vitalie Postolache:
It's the quotes, they are of poor quality.

The standard Expert Advisor goes well with them. And on a demo account, trading does not work either. My trades do not open. Although they should.

 
Michail_David:

The standard examiner is fine with them

Compare the Standard Expert Advisor and your own Expert Advisor, find differences and draw conclusions. But the wording of the error indicates poor quality quotes, when the values from one TF do not coincide with the values from the other TF.

If this code is written for trading in mode " open prices only", then this trouble may be avoided.

Added. You are exactly trying to make a code by open prices, it's not clear why it should be tested by all ticks...
 
Vitalie Postolache:
Compare the standard and your own, find the differences and draw conclusions. You can get away from such misfortune if the code is written for trading in " open prices only" mode.
The standard one also uses closing prices, just like mine
 
Michail_David:
The standard code also uses closing prices, like mine

Which EA do you call standard? I haven't seen an EA "atclose prices" in the terminal's delivery.

And by open prices, you must either have the entire trading code working in this mode, or not to do it at all. Only part of the code is used on a new bar, the rest will work on every tick.

 
Vitalie Postolache:

Which EA do you call standard? I haven't seen an EA "atclose prices" in the terminal's delivery.

And by open prices, you must either have the entire trading code working in this mode, or not to do it at all. You have only part of the code used on a new bar, the rest will work on every tick.

The MACD Sample is called standard. Would it be better to move the search for a new bar to the beginning?
 
Michail_David:
I would call it as a standard MACD Sample. Would you better move the search for a new bar to the beginning?

Where in MACD Sample is the "open prices only" mode, I don't see it? It's better to move the search for a new bar to the beginning of OnTick().

And it's

static datetime New_Time=TimeCurrent();// Время текущего бара

better to be declared outside the function, on a global level.

Or better yet, spend some time and search for better ways of searching for a new bar on the forum.
 
Vitalie Postolache:

Where in MACD Sample is the "open prices only" mode, I don't see it? It would be better to move the search for a new bar to the beginning of OnTick().

И

static datetime New_Time=TimeCurrent();// Время текущего бара

it's better to declare it outside the function, on a global level.

I must have misunderstood the"open prices only" mode by the standard Expert Advisor. I apologize for that. I am just beginning to understand it. Thanks for the tips. Can you view the whole code? There may be some more comments. I really need a fresh set of eyes. I would really appreciate it.
 
Michail_David:
Folks, a hint. Tester gives error: 2017.02.08 18:24:43.751 TestGenerator: unmatched data error (low value 1.09860 at 2016.07.27 19:30 is not reached from the lowest timeframe, low price 1.09880 mismatches)
What does this mean and how can it be fixed? What have I done wrong?
double Margin_Percent=AccountFreeMargin()*Percent/100; //Используемые средства для открытия ордеров
double Lots=Margin_Percent/MarketInfo(Symbol(),MODE_MARGINREQUIRED);//Определение общего количества лотов
double Lots_Volume=(MathFloor(Lots)+MarketInfo(Symbol(),MODE_LOTSTEP));
double MacdCurrent=iMACD(NULL,0,Fast_EMA_Period,Slow_EMA_Period,Signal_Period,PRICE_CLOSE,MODE_MAIN,1); //Параметры MACD основной линии текущего бара
double MacdPrevious1=iMACD(NULL,0,Fast_EMA_Period,Slow_EMA_Period,Signal_Period,PRICE_CLOSE,MODE_MAIN,2);//Параметры MACD основной линии предыдущего бара
double MacdPrevious2=iMACD(NULL,0,Fast_EMA_Period,Slow_EMA_Period,Signal_Period,PRICE_CLOSE,MODE_MAIN,3);//Параметры MACD основной линии со смещением на 2 бара
double StopLoss=iSAR(NULL,0,Step_PSAR,Maximum_PSAR,0);//Параметры Трейлинг стоп по параметрам ParabolicSAR текущего бара
double Previous_StopLoss=iSAR(NULL,0,Step_PSAR,Maximum_PSAR,1);//Параметры СтопЛосс по параметрам ParabolicSAR предыдущего бара
double CurrentPSAR=iSAR(NULL,0,Step_PSAR,Maximum_PSAR,1);//Параметры СтопЛосс по параметрам ParabolicSAR предыдущего бара

//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
  
//------
  }
//-------------------------------------------------------------------------------------------------------
This is the first time I see variable calculations done globally outside of event generating functions and the compiler doesn't even swear? Damn it, the compiler doesn't get it wrong.
 
Sergey Gritsay:
This is the first time I've seen variable calculations done globally outside of event-generating functions, and the compiler doesn't even complain?
No. It accepts everything as it is.
 
Michail_David:
No. It accepts everything as is.
put everything I highlighted in the OnTick() function
Reason: