OrderProfit() question ...

 

I am backtesting the following script. The return value for orderprofit is 0 and it should not be.

What am I doing wrong.

int ticket= OrderSend(Symbol(),OP_BUY,0.1,Ask,3,Ask-.0011,Ask+.0014); // Scenario 1

OrderSelect(ticket, SELECT_BY_TICKET);

if(OrderSelect(ticket, SELECT_BY_TICKET)==true)

{ Gain_1[k] = OrderProfit() ; }

else

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

 
Did your OrderSend work ? why aren't you testing it's return value to check if it worked ? if it fails your ticket number is -1, then both of your OrderSelect() ( why 2 ?? ) fail as well . . . and then you report that your OrderSend failed even if it's your OrderSelect() that didn't work . . .
 
RaptorUK:
Did your OrderSend work ? why aren't you testing it's return value to check if it worked ? if it fails your ticket number is -1, then both of your OrderSelect() ( why 2 ?? ) fail as well . . . and then you report that your OrderSend failed even if it's your OrderSelect() that didn't work . . .
if (ticket > 0) ... use just one order select...:)
 
RaptorUK:
Did your OrderSend work ? why aren't you testing it's return value to check if it worked ? if it fails your ticket number is -1, then both of your OrderSelect() ( why 2 ?? ) fail as well . . . and then you report that your OrderSend failed even if it's your OrderSelect() that didn't work . . .

Thanks, I made the change and when I run it I get OrderSend 131 error
 
ERR_INVALID_TRADE_VOLUME131Invalid trade volume, error in the volume granularity. All attempts to trade must be stopped, and the program logic must be changed.

Show your modified code . .

Please use this to post code . . . it makes it easier to read.

 
phillw:

I am backtesting the following script. The return value for orderprofit is 0 and it should not be.

What am I doing wrong.

int ticket= OrderSend(Symbol(),OP_BUY,0.1,Ask,3,Ask-.0011,Ask+.0014); // Scenario 1


try like this

double sl = Bid - (11* Point);
double tp = Bid + (14* Point);

int ticket= OrderSend(Symbol(),OP_BUY,0.1,Ask,3,sl,tp); // Scenario 1