geting price into a variable

 

hi all,

need a little help

the code is:

basically its a scalping EA. timeframe 5/15/30 min. the algo is like if certain conds are satisfied enter into trade and exit after a few pips say 10 pips. the EA should compare 10+entry price. i am having trouble getting the price at which i entered into the trade into a variable. any help???

 

if(some condn............................................&&.............................&&.............................&&............................ )

        {

         ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,NULL,NULL,"macd sample",16384,0,Green);  // can i replace null with something close_buy() when macd_1<signal????

         last=Ask+TakeProfit*Point;

 if(ticket>0)

           {

            if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice());

           }

         else Print("Error opening BUY order : ",GetLastError()); 

         return(0); 

        }

 

 

 

 

 some thing something...............

 

//codn to close order

 

 

for(cnt=0;cnt<total;cnt++)

     {

      OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);

      if(OrderType()<=OP_SELL &&   // check for opened position 

         OrderSymbol()==Symbol())  // check for symbol

        {

         if(OrderType()==OP_BUY)   // long position is opened

           {

            // should it be closed?

            here i want a condn that would compare the current price with the price at which the last open position was executed + fixed profit margin   // say  USD EUR bought@1.3299...i wanna compare if the current price is 1.3369....if so, the existing order should close 

         //tried using the take profit format built in orderselect. but my orders wont execute at all      



 

{

                 OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet); // close position

                 return(0); // exit

                } 
 
cryptex:

hi all,

need a little help

the code is:

<CODE REMOVED>

Please edit your post . . . 

 

Use SRC 

 
here i want a condn that would compare the current price with the price at which the last open position was executed + fixed profit margin say USD EUR bought@1.3299...i wanna compare if the current price is 1.3369....if so, the existing order should close
So what's your problem?
if (Bid > OrderOpenPrice() + 10 * pips2dbl){ ..
Since there are no slaves here, you have only three choices: Search for it, learn to code it, or pay someone. We're not going to code it FOR you. We are willing to HELP you when you post your attempt and the nature of your problem.
Reason: