Help me with a function and startegy tester

 

This is the function:

void OpenBuy() {

double ldLot, ldStop, ldTake;

string lsComm;

ldLot = GetSizeLot();

ldStop = GetStopLossBuy();

ldTake = Ask+(takeProfitBuy*Point);

lsComm = GetCommentForOrder();

int ticket = OrderSend(Symbol(),OP_BUY,ldLot,Ask,3,ldStop,ldTake,lsComm,MAGIC,0,CLR_NONE);

if (ticket < 0) {

Print("Error: ",GetLastError());

Print("Lots: ",ldLot," Ask: ",Ask," StopLoss: ",ldStop," TakeProfit: ",ldTake);

}

}

This is in logs:

2006.07.15 09:41:53 2006.07.14 22:42 someEA_02 EURUSD,M15: Error: 130

2006.07.15 09:41:53 2006.07.14 22:40 someEA_02 EURUSD,M15: Lots: 0.01 Ask: 1.2651 StopLoss: 1.2498 TakeProfit: 1.2666

2006.07.15 09:41:53 2006.07.14 22:40 someEA_02 EURUSD,M15: Error: 130

2006.07.15 09:41:53 2006.07.14 22:40 someEA_02 EURUSD,M15: Lots: 0.01 Ask: 1.2652 StopLoss: 1.2499 TakeProfit: 1.2667

Where i`m wrong ?

This driving me crazy from about 8 hours

if ldTake = 0 - no error but no Take Profit.

 

I don't know. The problem may come from the Stop Loss, or the Take Profit: remember that it can't be too close to the price. Check with MarketInfo() that 15 pips is far away enough. Check all the variables' types (including what is returned by the functions) and make sure the takeprofit is normalized (right number of digits). Slippage issues interfering with SL/TP are not documented but might happen?

A remark: a takeprofit of 15 pips with a stop loss of 153 pips is very strange...(unless it is an emergency stop loss for ~9/11 events and you normally close the trade well before that).

Reason: