Order Send if previous order is opened?

To add comments, please log in or register
doctorbeppo
44
doctorbeppo  

I am trying to work out the best way to say: if a certain ticket is opened, then open a new pending order. I am having trouble with order selects and finding tickets in previous functions so help would be much appreciated. 

I want to say : if ticket3 is open, OrderSend ticket4.


Many thanks!

 bool res;
     res = OrderModify(ticket,price-0.0050,StopLossLevel,0,0,clrNONE);
     Alert ("ticket modified");
   
        int ticket3;
        res =  ticket3 = OrderSend (Symbol(), OP_BUYLIMIT,lotsize1,StopLossLevel+0.0002,10,0,0,"LotLimit1",0,0,clrRed);
      
Mehrdad Jeddi
28882
Mehrdad Jeddi  
doctorbeppo:

I am trying to work out the best way to say: if a certain ticket is opened, then open a new pending order. I am having trouble with order selects and finding tickets in previous functions so help would be much appreciated. 

I want to say : if ticket3 is open, OrderSend ticket4.


Many thanks!

bool res = OrderModify(ticket,price-0.0050,StopLossLevel,0,0,clrNONE);
if(res)Alert ("ticket modified");

int ticket3 = OrderSend (Symbol(), OP_BUYLIMIT,lotsize1,StopLossLevel+0.0002,10,0,0,"LotLimit1",0,0,clrRed);
int ticket4;
if(ticket3>0)ticket4 = OrderSend (Symbol(), OP_BUYLIMIT,lotsize1,StopLossLevel+0.0002,10,0,0,"LotLimit1",0,0,clrRed);
if(ticket4>0)Alert ("ticket4 opened");
doctorbeppo
44
doctorbeppo  
Mehrdad Jeddi:

Hi thanks again for your response, 


this is nearly it; however when you say: if(ticket3>0) .   ticket3 is a BuyLimit order. Ideally I only want to send ticket4 after the limit has been activated as a Buy and not if it stays as a limit. Perhaps something like if(ticket3 == open) but I am not sure what this would be?

Keith Watford
Moderator
18439
Keith Watford  
   if(OrderSelect(ticket3,SELECT_BY_TICKET) && OrderType()==OP_BUY)
     {
      //pending order 3 has triggered
      //insert code to open a new pending order
     }

Of course, you will have to include safeguards so that the new pending order is not opened again and again.

doctorbeppo
44
doctorbeppo  
Keith Watford:

Of course, you will have to include safeguards so that the new pending order is not opened again and again.

I'm afraid this doesn't seem to work:&& OrderType()==OP_BUY)


ticket3 will be opened as a BuyLimit, so I don't think they OrderType will ever exist as OP_BUY. Rather, when the price falls back down to activate the BuyLimit so it then opens - ticket4 is opened. 

Is there a way to say: if order is now as Buy , without the ordertype being OP_BUY?

Keith Watford
Moderator
18439
Keith Watford  
doctorbeppo:

I'm afraid this doesn't seem to work:&& OrderType()==OP_BUY)


ticket3 will be opened as a BuyLimit, so I don't think they OrderType will ever exist as OP_BUY. Rather, when the price falls back down to activate the BuyLimit so it then opens - ticket4 is opened. 

Is there a way to say: if order is now as Buy , without the ordertype being OP_BUY?

Suit yourself

doctorbeppo
44
doctorbeppo  
Keith Watford:

Suit yourself

Do you know of a way to say only if the buylimit is opened and not just set as pending? Thanks

Keith Watford
Moderator
18439
Keith Watford  
doctorbeppo:

Do you know of a way to say only if the buylimit is opened and not just set as pending? Thanks

I already told you

if(OrderSelect(ticket3,SELECT_BY_TICKET) && OrderType()==OP_BUY)

But you don't like my answer.

doctorbeppo
44
doctorbeppo  
Keith Watford:

I already told you

But you don't like my answer.

Apologies, it's not that I don't like your answer, but when I use the code the ticket doesn't open, because the order type is not OP_BUY it is OP_BUYLIMIT. I think I might be unclear of what I would like. Ideally ticket3 would open as a BuyLimit. Only when the BuyLimit is opened does the 'if' function come into place, rather than the 'if' saying that the ordertype is already written as OP_BUY, if that makes sense? No worries if not I will continue to figure it out

William Roeder
19843
William Roeder  
doctorbeppo: because the order type is not OP_BUY it is OP_BUYLIMIT. I
It is buy limit only if the pending order has not opened. It is a buy once it does. Keith has answered you twice.
Keith Watford
Moderator
18439
Keith Watford  
doctorbeppo:

Do not double post.

You have this thread open so why open another that is basically following on from this one?

The other topic has been deleted.

12
To add comments, please log in or register