No TakeProfit Execution

 

Hello,

I am trying to implement an idea into an expert advisor.

Unfortunately TakeProfits are not executed as implement (using the Strategy Tester).

Please look at the attachment to see two examples. The OrderSend-comment for the first example is the following:

OrderSend(Symbol(),OP_SELL,0.1,1.44773,3,1.44993,1.44743,"COMMENT", 20111009,0,Red);

Are there any settings I have to set?

Hope you can help me.

Thanks in advance.

Alex

Files:
chart2.jpg  24 kb
chart.jpg  18 kb
 

post the EA otherwise other people unable to help

 

It's a very simple one, just for testing.

I have a 5 digits broker.

Thanks for helping.

Concerning the problem: Maybe it has something to do with spread? Is it possible?

//+------------------------------------------------------------------+

//| |
//+------------------------------------------------------------------+
#property link ""

#define SYMBOL_MAIN "EURUSD"
#define TIMEFRAME_MAIN PERIOD_M5
#define PriceMode PRICE_CLOSE
#define MAGICMA 20102211
#define TimePeriodADX 14
#define TradingAreaADX 50

extern int StopLoss = 220;
extern int TakeProfit = 35;
extern int Slippage = 3;
extern double Lots = 0.1;

//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init(){
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{

if(Bars<100 || IsTradeAllowed()==false) return;

if(CalculateCurrentOrders(SYMBOL_MAIN)==0 ) CheckForOpen();

return(0);
}
//+------------------------------------------------------------------+

int SignalIn(){

if( iADX(NULL,TIMEFRAME_MAIN,TimePeriodADX,PriceMode,MODE_MAIN,2) >= TradingAreaADX
&& iADX(NULL,TIMEFRAME_MAIN,TimePeriodADX,PriceMode,MODE_MAIN,15) < TradingAreaADX
&& iADX(NULL,TIMEFRAME_MAIN,TimePeriodADX,PriceMode,MODE_MAIN,16) < TradingAreaADX
&& iADX(NULL,TIMEFRAME_MAIN,TimePeriodADX,PriceMode,MODE_MAIN,1) < iADX(NULL,TIMEFRAME_MAIN,TimePeriodADX,PriceMode,MODE_MAIN,2)
&& iADX(NULL,TIMEFRAME_MAIN,TimePeriodADX,PriceMode,MODE_MAIN,3) < iADX(NULL,TIMEFRAME_MAIN,TimePeriodADX,PriceMode,MODE_MAIN,2)
&& iATR(NULL, TIMEFRAME_MAIN, TimePeriodADX, 1) >= 0.0003
){
if( iADX(NULL,TIMEFRAME_MAIN,TimePeriodADX,PriceMode,MODE_PLUSDI,2) < iADX(NULL,TIMEFRAME_MAIN,TimePeriodADX,PriceMode,MODE_MINUSDI,2)
&& iRSI(NULL,0,TimePeriodADX,PriceMode,1) > 33
&& Open[1] > Close[2]
){ return(OP_BUY);
}else if( iADX(NULL,TIMEFRAME_MAIN,TimePeriodADX,PriceMode,MODE_PLUSDI,2) > iADX(NULL,TIMEFRAME_MAIN,TimePeriodADX,PriceMode,MODE_MINUSDI,2)
&& iRSI(NULL,0,TimePeriodADX,PriceMode,1) < 66
&& Open[1] < High[2]
){ return(OP_SELL);
}else{
return(99);
}

}else{
return(99);
}

return(99);

}

//+------------------------------------------------------------------+
//| Calculate open positions |
//+------------------------------------------------------------------+
int CalculateCurrentOrders(string symbol)
{
int buys=0,sells=0;
//----
for(int i=0;i<OrdersTotal();i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
if(OrderSymbol()==Symbol() && OrderMagicNumber()==MAGICMA)
{
if(OrderType()==OP_BUY) buys++;
if(OrderType()==OP_SELL) sells++;
}
}
//---- return orders volume
if(buys>0) return(buys);
else return(-sells);
}



void CheckForOpen(){

//---- sell conditions
if(SignalIn() == OP_SELL){
OrderSend(SYMBOL_MAIN,OP_SELL,0.1,Bid,30,(Bid + StopLoss * Point),(Bid - TakeProfit * Point), "Sell" + CurTime(),MAGICMA,0,Red);
return;
}
//---- buy conditions
if(SignalIn() == OP_BUY){
OrderSend(SYMBOL_MAIN,OP_BUY,0.1,Ask,30,(Ask - StopLoss * Point), (Ask + TakeProfit * Point), "Buy" + CurTime(),MAGICMA,0,Green);
return;
}

}

 

Are only the TPs not being executed or is it both TPs and SLs not being executed? If both are not working then you would probably need to send no values for TP and SL in the initial order opening process. Then after the order is opened, immediately modify the order with the proper TP and SL. Try using new rates and normalized rates too. This never hurts.

 

It would be possible that it was the TPs!

 

Here are a few solutions on the subject of order management.

 

Here are a few solutions on the subject of order management.

Reason: