Coding help - page 410

 

thanks mladen. it works perfect. i am coder now!!!

 
sunshineh:
As I see is there actual no posibility to draw a rectangle behind a button and define, that clicking on the button is the Event and not the rectangle...

But I have another question:

How can I draw a horizontal line with a defined length? I tried it with OBJ_TREND, but one side of the line is infinite or Zero. So I can't draw a horizonal line from Bid-10 to Bid+10.

Do you now a solution?

sunshineh

Set the RAY property (OBJPROP_RAY) of the trend line to false and then it will not extend to infinite

 

Hi all, if I want to assign a different magic number for each order that is opened by an EA, can I use the following :

extern int MagicNumber = 1000000;

if(Conditions)

{

SendOrder(OP_BUY,MagicNumber);

MagicNumber = MagicNumber+1;

}

I'd rather use the magic number as an identifier, rather than a comment. Number are easier to manipulate than strings imo...

Thanks.

 
airquest:
Hi all, if I want to assign a different magic number for each order that is opened by an EA, can I use the following :

extern int MagicNumber = 1000000;

if(Conditions)

{

SendOrder(OP_BUY,MagicNumber);

MagicNumber = MagicNumber+1;

}

I'd rather use the magic number as an identifier, rather than a comment. Number are easier to manipulate than strings imo...

Thanks.

Tried it. It works well

 
airquest:
Hi all, if I want to assign a different magic number for each order that is opened by an EA, can I use the following :

extern int MagicNumber = 1000000;

if(Conditions)

{

SendOrder(OP_BUY,MagicNumber);

MagicNumber = MagicNumber+1;

}

I'd rather use the magic number as an identifier, rather than a comment. Number are easier to manipulate than strings imo...

Thanks.

It is OK but how are you identifying the exact magic number that you wish to process once when the order is opened?

 
mladen:
It is OK but how are you identifying the exact magic number that you wish to process once when the order is opened?

Well, kind of tricky. In the OnInit, I've stored the original magic number (1000000) in a int variable (OriginalMagic), and then when calling OrderSelect, I filter by the unique MagicNumber and stores the variables (OrderOpenPrice, OrderLots, etc.) in an array, so for each order the index will be : MagicNumber - OriginalMagic (so first one is 0, then 1, etc.). The point is to do two things : 1) only to open a limited number of orders (ArrayRange is a constant number (extern int MaxOpenTradesToManage) and the opening order loop will not run if MagicNumber is < OriginalMagic + MaxOpenTradesToManage - 1); 2) define specifics (and different) order management rules for each open orders (which is the reason to have a unique MagicNr).

Mladen, I have another question for you, I saw in one of your EA (Ichimoku 5.3.5, maybe it's Mr. Tools' one, not sure), that you open orders with the following :

int buyTicket = OrderSend(symbol,OP_BUY,lots,price,slippage,0,0,comment,magic,0,color);

if (buyTicket >= 0)

bool buyOrderMod = OrderModify(buyTicket,OrderOpenPrice(),STOPLOSS,TAKEPROFIT,0,color);

[/CODE]

Does it change something from just putting the OrderSend function with already defines SL and TP ? Is it better to open with 0,0 and then use OrderModify to set SL and TP ? :

[CODE]

OrderSend(symbol,OP_BUY,lots,price,slippage,STOPLOSS,TAKEPROFIT,comment,magic,0,color);

Thanks for your reply. Best regards and a very Happy Christmas.

 
airquest:
Well, kind of tricky. In the OnInit, I've stored the original magic number (1000000) in a int variable (OriginalMagic), and then when calling OrderSelect, I filter by the unique MagicNumber and stores the variables (OrderOpenPrice, OrderLots, etc.) in an array, so for each order the index will be : MagicNumber - OriginalMagic (so first one is 0, then 1, etc.). The point is to do two things : 1) only to open a limited number of orders (ArrayRange is a constant number (extern int MaxOpenTradesToManage) and the opening order loop will not run if MagicNumber is < OriginalMagic + MaxOpenTradesToManage - 1); 2) define specifics (and different) order management rules for each open orders (which is the reason to have a unique MagicNr).

Mladen, I have another question for you, I saw in one of your EA (Ichimoku 5.3.5, maybe it's Mr. Tools' one, not sure), that you open orders with the following :

int buyTicket = OrderSend(symbol,OP_BUY,lots,price,slippage,0,0,comment,magic,0,color);

if (buyTicket >= 0)

bool buyOrderMod = OrderModify(buyTicket,OrderOpenPrice(),STOPLOSS,TAKEPROFIT,0,color);

[/CODE]

Does it change something from just putting the OrderSend function with already defines SL and TP ? Is it better to open with 0,0 and then use OrderModify to set SL and TP ? :

[CODE]

OrderSend(symbol,OP_BUY,lots,price,slippage,STOPLOSS,TAKEPROFIT,comment,magic,0,color);

Thanks for your reply. Best regards and a very Happy Christmas.

airquest

It does not change. But ...

It must be done that way for ECN/STP type of brokers. They do not allow placing stop loss and / or take profit when ye order is opened and then it must be done that way in two steps

 
mladen:
airquest It does not change. But ... It must be done that way for ECN/STP type of brokers. They do not allow placing stop loss and / or take profit when ye order is opened and then it must be done that way in two steps

Ok, thanks a lot for the tip. For pending orders also ?

 
airquest:
Ok, thanks a lot for the tip. For pending orders also ?

Yes, for those too

 

Coding help

Hi Mladen

This indicator does not work on Monday

"Google Translate"

Thanks

Files:
Reason: