How to code? - page 33

 
 

Check order closed by TP or SL

hello

How to check if the order was closed by TP OR SL ?

master001

 

Help in Coding!

int k, vOrders;

vOrders = OrdersTotal();

//{

double Profit = 0;

double PipsProfit = 0;

for (k=vOrders-1;k>=0;k--)

{

if (OrderSelect(k, SELECT_BY_POS, MODE_TRADES))

{

if (OrderSymbol()==Symbol() && ((OrderMagicNumber () == Reference) || MagicNumber==0))

{

if (OrderType() == OP_BUY) PipsProfit+ == ((Bid - OrderOpenPrice())/Point);

Profit+= OrderProfit();

else if (OrderType() == OP_SELL) PipsProfit+ = ((OrderOpenPrice() - Ask)/Point);

{

//Profit += OrderProfit();

}

}

}

}

Someone gave me this coding in the past and I tried to work with it. It gives me errors dealing with the ' + ' after PipsProfit. Can someone debug this for me please! With sincere appreciation in advance for your assistance.

Dave

 

if (OrderType() == OP_BUY) PipsProfit+ == ((Bid - OrderOpenPrice())/Point);

[/php]

The + after PipsProfit shouldn't be there at all. It is being used in a comparison NOT an incremental function. You're ASKING does PipsProfit equal Bid - etc etc ?

Try this...

[php]

if ((OrderType() == OP_BUY) && (PipsProfit == (Bid - OrderOpenPrice())/Point)){

// do something IF the above two conditions are TRUE...

}

Good Luck

Lux

 

The problem is that there is no space between PipsProfit and '+' and a space between '=' and '+' ...... - in other words it should be like this ->

else if (OrderType() == OP_SELL) PipsProfit += ((OrderOpenPrice() - Ask)/Point); {

You also should include the second 'Profit += OrderProfit();' in the code (remove those '//')

 

Coding Question

I know an EA can be coded to onlytrade Demo accounts. Can I also code an EA NOTto trade on PAMM accounts? This would allow the EA to trade on live accounts, but not be used for money managers to trade PAMM accounts - unless there was a separate license agreement.

 

comma separated extern variable(s)

Hi,

for an indicator I use I have to set the digits for each symbol. I do this in the code with e.g.

if(Symbol()=="GBPJPY" || Symbol()=="EURJPY" || Symbol()=="USDJPY" ....and so on) nDigits = 2;[/PHP]

Now I like to spin these symbols off to an extern variable so that the user can set his symbols for himself. I thought to add sth. like

[PHP]extern string Symbols_nDigits2 = "GBPJPY,EURJPY,USDJPY";

How can I use this comma separated list of symbols and split it out so I can use it again in the indicator code like shown above (if(Symbol()=="GBPJPY"....)?

(Or is there a better solution for this "digits problem" out there?)

Thanks

 
MarketInfo( Symbol(), MODE_DIGITS )
 

perfect, thx!

 

Got it working thanks to both of you. Really appreciate it!

Dave

<<<