Pending TakeProfit Problem

 

I have a problem when my EA places a pending order and my trade hits TP. I get lot size (0.01)* 5pips = 0.42 profit instead of 0.50. With JPY pairs its less 0.37 etc. Here is my code below, please help if you know the problem.

extern double TakeProfit=5.5;
int MagicNumber;

int MaxTrades=0;

int CountPenOrders()
 {
  int Pending=0;
  for(int Loop2=OrdersTotal()-1;Loop2>=0;Loop2--)
  {
   if(OrderSelect(Loop2,SELECT_BY_POS,MODE_TRADES))
   if(OrderSymbol()==Symbol()&&OrderMagicNumber()==MagicNumber)
   if(OrderType()==OP_BUYSTOP||OrderType()==OP_SELLSTOP)
   Pending++;
  }
   
  return(Pending);
 } 
 
double Pips()
 {
  double PipPoint=0;
  double Digit=MarketInfo(Symbol(),MODE_DIGITS);
  
  if(Digit==1||Digit==2||Digit==3){PipPoint=Point*10;}//PipPoint=Point*100;}
  else if(Digit==1||Digit==2||Digit==3){PipPoint=Point*100;}
  else if(Digit==4||Digit==5){PipPoint=Point*10;}
  
  return(PipPoint);
 } 
 
void Buy()
 {
  double Spread=(Bid-Ask);
  double TakeProfitBuy=Ask+TakeProfit*Pips()+Spread;
  
  int Lowest=iLowest(Symbol(),0,MODE_LOW,10,1);
  int Lowest2=iLowest(Symbol(),0,MODE_LOW,10,2);
  
  if(OrdersTotal()<1)
  if(Close[1]>Lowest&&Close[1]<Lowest2)
  {
   int BuyTrade=OrderSend(Symbol(),OP_BUYSTOP,0.01,Ask+(0.5*Pips()),0,0,TakeProfitBuy,"JackBuda",0,0,clrBlue);
  }
  
 } 
 
void Sell()
 {
  double Spread=(Bid-Ask);
  double TakeProfitSell=Bid-TakeProfit*Pips()-(Spread);
  
  int Highest=iHighest(Symbol(),0,MODE_HIGH,10,1);
  int Highest2=iHighest(Symbol(),0,MODE_HIGH,10,2);
  
  if(OrdersTotal()<1)
  if(Close[1]<Highest&&Close[1]>Highest2)
  {
   int SellTrade=OrderSend(Symbol(),OP_SELLSTOP,0.01,Bid-(0.5*Pips()),0,0,TakeProfitSell,"JackBuda",0,0,clrRed);
  }
  
 } 
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
 {
  double AccBalance=AccountBalance();
  
  int Figures=0;

  if(AccBalance>10)
   {
    Figures=2;
   }

  switch(Figures)
  {
   case 2:
   if(CountPenOrders()<1){Buy();}

   if(CountPenOrders()<1){Sell();}

   break;
  }
   
 }

I tried changing Ask+ to something else but no luck.

 
Jack Buda:

I have a problem when my EA places a pending order and my trade hits TP. I get lot size (0.01)* 5pips = 0.42 profit instead of 0.50. With JPY pairs its less 0.37 etc. Here is my code below, please help if you know the problem.

I tried changing Ask+ to something else but no luck.

Why are you expecting $0.50 profit for 5 pips? That would only be true for symbols ending in USD.

Different symbols may have different tick values.

 
Jack Buda: I get lot size (0.01)* 5pips = 0.42 profit instead of 0.50. With JPY pairs its less 0.37 etc.
Keith Watford #: Why are you expecting $0.50 profit for 5 pips? That would only be true for symbols ending in USD. Different symbols may have different tick values.

I would like to add to Keith's post by saying that it also depends on your Account Currency as well, even for xxxUSD symbols.

So always evaluate your risk (and reward) based on the tick size and the tick value. Don't just assume those amounts.

 
Keith Watford #:

Why are you expecting $0.50 profit for 5 pips? That would only be true for symbols ending in USD.

Different symbols may have different tick values.

Maybe its how I described my problem. When my EA places  pending orders, my Take profit is too close, especially on JPY pairs. The way I see it, it's caused by the spread on different pairs.
 
Fernando Carreiro #:

I would like to add to Keith's post by saying that it also depends on your Account Currency as well, even for xxxUSD symbols.

So always evaluate your risk (and reward) based on the tick size and the tick value. Don't just assume those amounts.

Are you saying I Should use
MODE_TICKSIZE

&

MODE_TICKVALUE

??

 
 
Jack Buda #:
Maybe its how I described my problem. When my EA places  pending orders, my Take profit is too close, especially on JPY pairs. The way I see it, it's caused by the spread on different pairs.

Whatever problem you are having, you still haven't described it.

In your OP

Jack Buda:

I have a problem when my EA places a pending order and my trade hits TP. I get lot size (0.01)* 5pips = 0.42 profit instead of 0.50. With JPY pairs its less 0.37 etc. Here is my code below, please help if you know the problem.

I tried changing Ask+ to something else but no luck.

the only problem that you describe is that you are only getting $0.42 profit for 5 pips when you are expecting $0.50

That has been answered.

 
Thank you Fernando, the 1st post solved my problem!!!
 
Jack Buda #: Thank you Fernando, the 1st post solved my problem!!!
You are welcome!