need help with OrderType command

 

guys and girls


I am novice programmer and would really appreciate some help. I am trying to close an order if certain conditions are met using the following code


if (orderopen == 1 && OrderType() == OP_BUY && FMA < SMA)
{
CloseOrder();
}


using alerts I notice that OrderType is returning 0 for long and short positions....shouldn't OrderType be 1 if its a short position?


thanks in advance


atif

 
atifkhan:

guys and girls


I am novice programmer and would really appreciate some help. I am trying to close an order if certain conditions are met using the following code


if (orderopen == 1 && OrderType() == OP_BUY && FMA < SMA)
{
CloseOrder();
}


using alerts I notice that OrderType is returning 0 for long and short positions....shouldn't OrderType be 1 if its a short position?


thanks in advance


atif

Are you sure you have read your order before testing the type ?

 

You must first select the appropriate order using the OrderSelect() function.

Then you may test the type using the OrderType() function in either of the following ways:


if (OrderType() == OP_SELL)

{

...


or


if (OrderType() == 1)

{

...


CB

 

ah ha


thanks chaps

Reason: