New Order at same Price - page 2

 
delandee:

Good idea, but what about orders not closed by OrderClose function but closed by reaching TP ?

I really apreciate your spendt time to help me. Thanks !!

Can check history and look for

OrderCloseTime()


if it !=0 differs zero the order was closed.

 
   double supportLvl[10]={ 0.12345,0.23456,0.34567,... } //{Activ, Price}
   int ticket[10]={0,0,0,...}

   for(int lvl=0;lvl<10;lvl++)
     {
      if(Ask+50*_Point<supportLvl[lvl])
        {
         if(!ticket[lvl])
            ticket[lvl]=OrderSend(OP_BUYSTOP...);
         for(int cnt=OrdersTotal()-1;cnt>=0;cnt--)
           { 
            if(!OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES))
               continue;
            if(ticket[lvl]==OrderTicket() || supportLvl[lvl]==OrderOpenPrice())
               break;
            ticket[lvl]=0;
           }
        }
     }
 
Marco vd Heijden:

Can check history and look for


if it !=0 differs zero the order was closed.

Check history has bad performance no ??
 
pipPod:

seems to be the right way !

But new problem ^^

EA sends OP_BUYSTOP at 2.0000 with ticket number 1 for ticket[0], when price hit 2.0000 and changes OP_BUYSTOP to OP_BUY, ticket[0] becomes 0 instead of 1, and when Ask goes down to 2.0000 - 5 pips, the EA sends a OP_BUYSTOP at 2.0000

then there is already a OP_BUY at this price level :(



 

I think it's finally good !!


   double supportLvl[10]={ 0.12345,0.23456,0.34567,... } //{Activ, Price}
   int ticket[10]={0,0,0,...}

   for(int lvl=0;lvl<10;lvl++)
     {
      if(Ask+50*_Point<supportLvl[lvl])
        {
         if(!ticket[lvl])
            ticket[lvl]=OrderSend(OP_BUYSTOP...);
         for(int cnt=OrdersTotal()-1;cnt>=0;cnt--)
           { 
            if(!OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES))
               continue;
            if(ticket[lvl]==OrderTicket() || supportLvl[lvl]==OrderOpenPrice())
               break;
            //ticket[lvl]=0;
           }
        }

       if(OrderSelect(ticketUp[lvl], SELECT_BY_TICKET,MODE_HISTORY))
        {
           if (StringFind(OrderComment(), "[tp]") >= 0)
           {
              ticketUp[lvl]=0;
           }
        }

     }


Big thanks to pipPod && Marco vd Heijden for support !!

:)


 
delandee:

seems to be the right way !

But new problem ^^

EA sends OP_BUYSTOP at 2.0000 with ticket number 1 for ticket[0], when price hit 2.0000 and changes OP_BUYSTOP to OP_BUY, ticket[0] becomes 0 instead of 1, and when Ask goes down to 2.0000 - 5 pips, the EA sends a OP_BUYSTOP at 2.0000

then there is already a OP_BUY at this price level :(



It's probably not comparing prices correctly. Try this:

   double supportLvl[10]={ 0.1234,0.2345,0.3456,... } //only 2 or 4 decimal places
   int ticket[10]={0,0,0,...}

   for(int lvl=0;lvl<10;lvl++)
     {
      if(Ask+50*_Point<supportLvl[lvl])
        {
         if(!ticket[lvl])
            ticket[lvl]=OrderSend(OP_BUYSTOP...);
         for(int cnt=OrdersTotal()-1;cnt>=0;cnt--)
           { 
            if(!OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES))
               continue;
            if(ticket[lvl]==OrderTicket() || supportLvl[lvl]==NormalizeDouble(OrderOpenPrice(),_Digits-1))
               break;
            ticket[lvl]=0;
           }
        }
     }
Reason: