Download MetaTrader 5
To add comments, please log in or register
Are you a real pro? Share your knowledge with millions of traders!
Romanko
7
Romanko 2014.07.18 08:27 

Hi guys,

I'm new to the forum,Actually i'm new to trading, and :) i'm not a programmer.

Nice to meet you! 

I was hoping that someone can help me with a problem i have in my code.

I added comments as much as possible.

This function is suppose to close orders  as i don't want to do it with stop loss or take profit

I added a row to update me on the close price of the deal that i opened. But when it prints it on the screen it always prints a different number, how can it be?

The close price of the deal that i opened  suppose to be a constant! 

???? 

Note : Other parts of this function is working when the condition are met it cal's another function that closes the deal. 

 

void Porezlelemala_M()

  {

  if (st1>0)                                                           // Start maintaining Porezlelemala ( this is the variable that gets the ticket number when the deal is opened)

   {

    if(OrderSelect(st1, SELECT_BY_TICKET)==true)                        // Check if this ticket is valid

    {

      double Close_price=OrderClosePrice();                             // Obtain  price of deal

      Alert ("close prise is=",DoubleToStr(Close_price,5));             //For testing print close price

      if(Bid>Close_price+0.00060)                                       // decide take profit

      {                                                                    

        st1=closeorder(st1,0.4,"st1");                                // call closeorder function

      }

      else if(Bid<Close_price-0.00030)                                  // decide stoploss 

      {                                                                               

        st1=closeorder(st1,0.4,"st1");                                // call closeorder function

      }

    }

    else

      Print("OrderSelect returned the error of ",GetLastError());

   }

  }   

qjol
3243
qjol 2014.07.18 09:12  

romanko:

The close price of the deal that i opened  suppose to be a constant! 

????


not at all

the OrderClosePrice returns the last price available to close the order

and please for the next time use SRC for code

/
To add comments, please log in or register