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

 
int Count=0;
//+------------------------------------------------------------------+
//| expert initialization function|
//+------------------------------------------------------------------+
int init()
{
Alert ("The init() function failed on startup");
return;
}
//+------------------------------------------------------------------+
//| expert start function|
//+------------------------------------------------------------------+
int start()
{
double Price = Bid;
Count++;
Alert("New Tick ",Count," Price = ",Price);
return;
}
//+------------------------------------------------------------------+
int deinit()
{
Alert ("Deinit() triggered on unloading");
return;

}

As far as I understand, in this script at each new Bid price a message ...... should appear, but it is not ..... what is wrong? ...what to do?

 
i999i:
int Count=0;
//+------------------------------------------------------------------+
//| expert initialization function|
//+------------------------------------------------------------------+
int init()
{
Alert ("The init() function failed on startup");
return;
}
//+------------------------------------------------------------------+
//| expert start function|
//+------------------------------------------------------------------+
int start()
{
double Price = Bid;
Count++;
Alert("New Tick ",Count," Price = ",Price);
return;
}
//+------------------------------------------------------------------+
int deinit()
{
Alert ("Deinit() triggered on unloading");
return;

}

As far as I understand, in this script at each new Bid price a message ...... should appear, but it is not ..... what is wrong? ...what to do?

Probably turn on"allow EA to trade" in terminal settings.
 

Is there any way to modify the stop loss, but leave the take profit on one line (do not mention it, i.e. it needs to stay the way it was set before by other functions)

OrderModify(OrderTicket(),0,stop_loss, ???, 0,CLR_NONE);

 
rigonich:


If the tester had counted as many orders as the server does, the data would also be multi-digit.

The tester, just like the server, assigns each new order a unique order number (ticket), but the server does this from the moment the brokerage house was created, for all of its clients and for all instruments.


Got it, thanks :)))
 
rigonich:
Probably have "allow EA to trade" in the terminal settings.


Doesn't help
 
i999i:

Doesn't help

Sorry - all class .......thank you
 
lottamer:

Is there any way to modify the stop loss, but leave the take profit on one line (do not mention it, i.e. it needs to stay the way it was set before by other functions)

OrderModify(OrderTicket(),0,stop_loss, ???, 0,CLR_NONE);

OrderModify(OrderTicket(),OrderLots( ),stop_loss,OrderTakeProfit( ), 0,CLR_NONE);

Stop, so your lot is 0.

 
This order must also be selected by OrderSelect beforehand. Otherwise the ticket can often become anything.
 
Dimka-novitsek:
This order must also be selected by OrderSelect beforehand. Otherwise the ticket can often become anything.

Yes, the ticket will be the one you indicate, but the valuesOrderLots( ) andOrderTakeProfit( ), it may return for any order.
 

Good morning!

I categorically cannot figure it out - conditions for trailing stop do not work.

//***************************************   
 
 bool nahodka=false;
  
 if (OrderSelect(tacket, SELECT_BY_TICKET , MODE_HISTORY)) 
 if (OrderTakeProfit( )-3*Point<profit&&OrderTakeProfit( )+3*Point>profit) nahodka=true;     // Находим ордер, сработавший именно по тейкпрофиту 
   
 if(nahodka){if (OrderSelect(tucket,SELECT_BY_TICKET)){
 if(OrderStopLoss( )<Bid-treylingstop*Point ){ Print ("втораямодифи    " );
 OrderModify(  tucket, OrderOpenPrice(), Bid-treylingstop*Point, OrderTakeProfit(), 0, CLR_NONE);}}}
 if (BUY == 0) {perenos=false;srabotka=false;nahodka=false;} 
 
 
 //*************************************** 
 
 //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
 
               
               //SELL

So, the order is taken away immediately when it's not yet on the history, which I don't understand at all!

//***************************************   
 
  nahodka=false;
 
 for (i=0; i<=OrdersHistoryTotal(); i++) {
 if (!OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) continue;
 if (OrderSymbol()!=Symbol())continue; 
 if (OrderMagicNumber() != 450) continue; 
 if (tocket==OrderTicket()) 
 if (OrderTakeProfit( )-3*Point<profitsell&&OrderTakeProfit( )+3*Point>profitsell) nahodka=true;}
     // Находим ордер, сработавший именно по тейкпрофиту 
 
 
  
 if(nahodka){if (OrderSelect(tecket,SELECT_BY_TICKET)){
 if(OrderStopLoss( )>Bid+treylingstop*Point ){ Print ("четвёртаямодифи    " );
 OrderModify(  tecket, OrderOpenPrice(), Bid+treylingstop*Point, OrderTakeProfit(), 0, CLR_NONE);}}}
 for ( i = OrdersTotal() - 1; i >= 0; i--)

And this is the situation is better! If we have this trick, at least the order is corrected when it is already on the history.

But once in five or ten times nahodka does not take the valuetrue, and further modification does not occur!

Reason: