[Archive!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Couldn't go anywhere without you - 2. - page 112

 

Good evening!

I have a simple question.

For what reason, the EA, after initialisation, cannot go to start(); ?

Maybe someone has faced such a problem?

From init(); I exit return(0); .

Thanks in advance for the answer!

 
And how do you know that he "didn't go to Start"?
 
BBSL:

Good evening!

I have a simple question.

For what reason, the EA, after initialisation, cannot go to start(); ?

Maybe someone has faced such a problem?

From init(); I exit return(0); .

Thanks in advance for the answer!

No quotes - no start. Ticks are needed to move to start + expert approval.
 

Hi all and profits!

I have such a problem.

On my home computer I'm doing a graphic layout. How to transfer it to another computer - which file should be overwritten?

I cannot use the output like copying the whole MT4 folder and then copying it with a new name to another computer because it is too complicated. The interesting thing is that if I leave the folder on another computer with the old name there is nothing new on the charts...

Who knows, help!

 

BBSL ,I used to write "start();" - is that how you wrote it? You don't need a colon there. maybe there are no curly brackets

kiimar, did you close it? If so, you need to see the code

 
BBSL:

Good evening!

I have a simple question.

For what reason, the EA, after initialisation, cannot go to start(); ?

Maybe someone has faced such a problem?

From init(); I exit return(0); .

Thanks in advance for the answer!

The answer is even simpler: The presence of the return(0) operator at the end of a function body does not mean that this operator will ever be executed.
 

How do I check if an order is triggered by TakeProfit or StopLoss? Thank you for your reply!

 
BBSL:

For what reason, the EA, after initialisation, cannot go to start(); ?

Maybe someone has faced this problem?

Sometimes there are complex calculations or loading history in init(), or the terminal has a lot of indicators and EAs suspending the terminal or...

but if during the code initialization the terminal terminals interrupts the code, the following error will appear in the log: ".... timeout in expert ...."

If the log shows no error, it means that initialization was successful. The start() function itself is easy to check - write start() : Print("new tick") in the first line;

 
Sayod ,what timeframe did you trade on and with what parameters?
 
Jaguar1974:

How do I check if an order is triggered by TakeProfit or StopLoss? Thanks for the reply!


Check order history, if close price equals SL or TP - then ... but I think it would be easier to check the profit of a closed order - if > 0 then take otherwise ...

here is a similar meaningful piece of code:

double history(){
int time = 0;double profit = 0;//обьявляем необходимые нам переменные куда мы положим интересующие нас характеристики ордера
for(int i = OrdersHistoryTotal();i>=0;i--){// Перебираем все закрытые ордера
  if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)){//если ордер с таким номером (i) в списке закрытых ордеров есть ( не путать с тикетом)
    if(OrderSymbol() == Symbol()){//если выбранный ордер был открыт по нашей валютной паре
      if(time<OrderCloseTime()){//(сравниваем его с хранящимся в пероеменной time) 
        time=OrderCloseTime();//если время закрытия ордера больше - ложим его в переменную
        profit=OrderProfit();//и заодно запоминаем прибыль ордера
      }
    }
  }
}
//по окончании этой процедуры в наших переменных будут сидет наибольшее время закрытия, и его профит. Или по нулям если история чистая.
//теперь мы можем выставлять условия в зависимости от результата процедуры
   
if(profit == 0 &&time == 0){//действия если история чистая

}
if(profit >= 0){//действия если последний ордер был прибыльным, или нулевым

}
if(profit <  0 ){//действия если последний ордер был убыточным

}
return(0);
}
Reason: