MQL4 Trailing OrderSend

 
void OnTick()
{

double PRICE = 100;

      if (OrdersTotal()==0)
      
         {
             int buyticket1 = OrderSend(Symbol(),OP_BUYSTOP,0.01,Bid + (( PRICE *2)*_Point),3,Bid-(( PRICE *2)*_Point),0,NULL,0,0,Green);
             int buyticket2 = OrderSend(Symbol(),OP_BUYSTOP,0.01,Bid + (( PRICE *3)*_Point),3,Bid-(( PRICE *3)*_Point),0,NULL,0,0,Green);
             int buyticket3 = OrderSend(Symbol(),OP_BUYSTOP,0.01,Bid + (( PRICE *4)*_Point),3,Bid-(( PRICE *4)*_Point),0,NULL,0,0,Green);
         }
   
   
             for (int b=OrdersTotal()-1;b<=0;b++)
             {
                 if (OrderSelect(b,SELECT_BY_POS,MODE_TRADES))
                 if (OrderSymbol()==Symbol())
                 if (OrderType()==OP_BUYSTOP)  
                     { 
                          if (OrderOpenPrice()>=Bid + (( PRICE *3)*_Point))
                          int DELETE = OrderDelete(OrderTicket(),Red);
                        
                     }
             }

}


Hello. Im something more than beginner, but less than medium programmer, so im looking for help :).

This is the begining of my expert advisor. Strange thing is that rest of EA works perfectly, but this begining of EA is the core of my idea.

When i open forex platform and start EA, i want to make a 3 buytickets (3 is example, it could be 10 or 88). When price go UP, everything is fine, i have a stopp loss and it works good. But when i have 3 orders and price go DOWN more than 100 points [ if (OrderOpenPrice()>=Bid + (( PRICE *3)*_Point)) ] i want to delete all of this order sends which was makes before, and make another 3 ordersend till the price go UP more than PRICE*2=200 points. When rhere is only one buyticket1 it works fine, but when there is more than 1 ordersend (buyticket2, buticket 3 ....) it doesnt work.

I know that there is another 1000 ways to do it mayby more correctly, but for now i somebody wants to help, please go with this code.

THX.

Basic Principles - Trading Operations - MetaTrader 5 Help
Basic Principles - Trading Operations - MetaTrader 5 Help
  • www.metatrader5.com
is an instruction given to a broker to buy or sell a financial instrument. There are two main types of orders: Market and Pending. In addition, there are special Take Profit and Stop Loss levels. is the commercial exchange (buying or selling) of a financial security. Buying is executed at the demand price (Ask), and Sell is performed at the...
 

Please edit your post and use the code button (Alt+S) to paste code.

In future please post in the correct section

I will move your topic to the MQL4 and Metatrader 4 section.

 
Keith Watford:

Please edit your post and use the code button (Alt+S) to paste code.

In future please post in the correct section

I will move your topic to the MQL4 and Metatrader 4 section.

THX, i change it :)
 
for (int b=OrdersTotal()-1;b>=0;b--)
;)