[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 397

 
VOLDEMAR:

Yes, if you set it as x=0, it will go to zero if you just set it as x:, it won't go to zero, it will go up.


Sorry I didn't notice that it's in the startup core ....
 
I'm sure it'll reset. Thank you all, it's a bit hilarious.
 
int tiket,tikett;double volume=0.1;int i=0,R1=0,R2=0,A=1 ;
int start()
  { 
int    X=0; 
double price=(Ask+Bid)/2;      
int total=OrdersTotal();                                         
                                       
   for (int i=total-1; i>=0; i--)                                 
   {
    if(OrderSelect(i, SELECT_BY_POS))                          
     { 
      Alert ("Uy",i);
      if(OrderSymbol()==Symbol()&&OrderMagicNumber( )==1000||OrderMagicNumber( )==2000 &&OrderSymbol()==Symbol())
       {
       X ++;
       }  
       }
       }
       Alert ("X",X);}

if (X==0)
   {
   tiket= OrderSend( Symbol(), OP_BUYSTOP,  volume*A, price +otstup*Point, Point* 3, R1, price+takeprofit*Point+otstup*Point, "OP_BUYSTOP", 1000,  expiration, Red); 
   Alert ("OP_BUYSTOP", GetLastError( )); 
   tikett= OrderSend( Symbol(), OP_SELLSTOP,  volume*A, price -otstup*Point, Point* 3,R2, price-takeprofit*Point-otstup*Point, "OP_SELLSTOP" , 2000,  expiration,C'0,128,255' );
    Alert ("OP_SELLSTOP", GetLastError( )); 
    }       


   return(0);
  

This is the right way to go!!!!!

 
Dimka-novitsek:
I'm sure it'll reset. Thank you all, it's a bit hilarious.
Better to use comment(); then during testing you can see what is happening with your variables at the top left......
 
Thank you!!!
 
I put in your code, it doesn't compile. What is the error, I can't understand. But the main thing, I still asked, there must be some kind of logical error, orders are opened on every tick, most likely this part does not work.
 if(OrderSymbol()==Symbol()&& OrderMagicNumber( )==1000||OrderMagicNumber( )==2000 && OrderSymbol()==Symbol())
This is the part that is not working and I can't understand it either?
 
VOLDEMAR:

Guys a more complicated question......

How to make an EA close all orders when a given profit is reached .... Close only orders on one symbol ...

Example : EA works on 3 pairs amount to close all orders on one symbol 100p ...

If the EUR has more than 100p it will only close orders on EUR while others may have 200p ...

If I take accountbalanse(), then EA will close only when the sum of three pairs is more than 100p. This option does not work for me !!!!

Help please.........



Probably with
OrderProfit( )
And also If (OrderSymbol()==Symbol()) {} Although I can't write it myself...
 

Please advise what is wrong in the code. The robot is supposed to close a sell order, if it is not there, it should buy. Error 4105 appears, which I try to handle, but there is no result. Maybe there are other ways to process it?

PRICECURRENTPPROFIT is the buy level.


// ROBOT SELLS
// determine if there are sell orders
if (Bid>=PRICECURRENTPPROFIT && PRICECURRENTMPROFIT>0)
{
for(cnt=OrdersTotal();cnt>=0;cnt--)
{OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); mode = OrderType(); if(OrderSymbol() == "EURUSD")
{if(mode == OP_BUY)
{go=OrderClose(OrderTicket(), Lots, Bid, slippage, Green);

}
}
} // if open, close
} if(go != true) {Print("Failed to open SELL order. Error N", GetLastError());
switch(GetLastError()) {case 4105: OrderSend("EURUSD",OP_SELL,Lots,Bid,2*Point,0,0, "robot sells",MagicNumber,0,Red);break;}
}

 

I want to add some functions to it to make it open for buy and sell but for sell and buy need a separate magicnumber

If a Take Profit order triggers, the robot closes all pending orders. I want it to close all pending orders OP_SELLLIMIT and leave them unchanged OP_BUYLIMIT, OP_BUY

 
Dimka-novitsek:
I put in your code, it doesn't compile. What is the error, I can't understand. But most importantly, I still asked, there must be some kind of logical error, orders are opened on every tick, most likely this part is not working, and I can't understand it either?
Either the code is not all shown or the closing curly bracket is missing at the very bottom.
Reason: