[ MQL] Please tell me how to select order by timeframe in one chart.

To add comments, please log in or register
Cromo
259
Cromo  

For example,the EA places orders (using iCustom signal in one chart).

order#1  buy  (EA ordered with signal of time frame M5)  ---iCustom(NULL,5,"indicator name",0,1)

order#2  buy (EA ordered with signal of time frame H1)  ---iCustom(NULL,60,"indicator name",0,1)

order#3  sell (EA ordered with signal of time frame M5) ---iCustom(NULL,5,"indicator name",1,1)

Now I have total three orders in one basket.

and I want to select and close the order #1 only, which was placed with signal of timeframe M5.

How can I select the order #1? I don't want to close order #2,3.

Is it possible to select order with different  time frame? How can I do it?

Vitalii Ananev
10014
Vitalii Ananev  
kajironpu:

For example,the EA places orders (using iCustom signal in one chart).

order#1  buy  (EA ordered with signal of time frame M5)  ---iCustom(NULL,5,"indicator name",0,1)

order#2  buy (EA ordered with signal of time frame H1)  ---iCustom(NULL,60,"indicator name",0,1)

order#3  sell (EA ordered with signal of time frame M5) ---iCustom(NULL,5,"indicator name",1,1)

Now I have total three orders in one basket.

and I want to select and close the order #1 only, which was placed with signal of timeframe M5.

How can I select the order #1? I don't want to close order #2,3.

Is it possible to select order with different  time frame? How can I do it?

The easiest solution is to open positions with different magic numbers.

Cromo
259
Cromo  
Vitalii Ananev:

The easiest solution is to open positions with different magic numbers.

Vitalii, thank you for your advice.

To change magic number, you mean different magic number by each time frame, right?

EX)   MAGIC#111 =Time frame M5 order

        MAGIC#222=Time frame H1 order

Mohamad Zulhairi Baba
16414
Mohamad Zulhairi Baba  
kajironpu:

Vitalii, thank you for your advice.

To change magic number, you mean different magic number by each time frame, right?

EX)   MAGIC#111 =Time frame M5 order

        MAGIC#222=Time frame H1 order

to minimize ambiguity, use different magic number for each order.

Vitalii Ananev
10014
Vitalii Ananev  
kajironpu:

Vitalii, thank you for your advice.

To change magic number, you mean different magic number by each time frame, right?

EX)   MAGIC#111 =Time frame M5 order

        MAGIC#222=Time frame H1 order

Yeah, that's what I meant.

Can be done for example so:

....
int Magic = 555;
...
OrderSend(Symbol(),OP_BUY,Lot,Pr,Slipage,0,0,"",Magic+PERIOD_H1,0,clrNONE);
OrderSend(Symbol(),OP_BUY,Lot,Pr,Slipage,0,0,"",Magic+PERIOD_M5,0,clrNONE);
....
.....

if(OrderSelect(i, SELECT_BY_POS,MODE_TRADES)) 
{     
  if (OrderMagicNumber()==Magic+PERIOD_H1 && OrderSymbol()==Symbol())
  {
    ....
    //Any action with the position 
  }
  if (OrderMagicNumber()==Magic+PERIOD_M5 && OrderSymbol()==Symbol())
  {
    .....
    ///Any action with the position    
  }

}
...

Thus, your positions will be different from each other.

Cromo
259
Cromo  
Vitalii Ananev:

Yeah, that's what I meant.

Can be done for example so:

Thus, your positions will be different from each other.

Thank you so much. Your sample code is very helpful.

I will try that!

Cromo
259
Cromo  
Mohamad Zulhairi Baba:

to minimize ambiguity, use different magic number for each order.

Great idea! Thank you!

To add comments, please log in or register