Hi,
I am developing an expert advisor and while I was tested it I got an error in the OrderSend function. I didnt know what happend and in order to solve the problem I did a test with a simple script and I get an amazing error. The script is...
---
int start()
{
int ticket;
double TP, SL;
//----
while(true)
{
SL = Ask - 50 * Point;
TP = Ask + 50 * Point;
Print ("Ask = ", Ask, " SL = ", SL, " TP = ", TP);
ticket=OrderSend(Symbol(),OP_BUY,0.1,Ask,3, SL, TP, "Comment",255,0, CLR_NONE);
if(ticket <= 0)
{
int error=GetLastError();
Print (ErrorDescription (error));
break;
}
else { OrderPrint(); break; }
//---- 10 seconds wait
Sleep(10000);
}
//----
return(0);
}
//+------------------------------------------------------------------+
In the Expert Log the output is:
Invalid stops
Ask = 1.4662 // SL = 1.4657 // TP = 1.4667
Note that stop loss is only five points below ask price and the server return an "invalid stops" error. I dont know what happen because I think the program logic is ok but these results are illogical because stop loss should be 50 points below ask price according to the "SL = Ask - 50 * Point" line. I have checked the code in orden to find something wrong but I didnt found nothing wrong.
I am running this script in a demo account that shows rates in pippetes (I dont know if this info could be important to solve the problem).
Anybody have idea how to solve this problem?
Thanks in advance,
DayDream
I am developing an expert advisor and while I was tested it I got an error in the OrderSend function. I didnt know what happend and in order to solve the problem I did a test with a simple script and I get an amazing error. The script is...
---
int start()
{
int ticket;
double TP, SL;
//----
while(true)
{
SL = Ask - 50 * Point;
TP = Ask + 50 * Point;
Print ("Ask = ", Ask, " SL = ", SL, " TP = ", TP);
ticket=OrderSend(Symbol(),OP_BUY,0.1,Ask,3, SL, TP, "Comment",255,0, CLR_NONE);
if(ticket <= 0)
{
int error=GetLastError();
Print (ErrorDescription (error));
break;
}
else { OrderPrint(); break; }
//---- 10 seconds wait
Sleep(10000);
}
//----
return(0);
}
//+------------------------------------------------------------------+
In the Expert Log the output is:
Invalid stops
Ask = 1.4662 // SL = 1.4657 // TP = 1.4667
Note that stop loss is only five points below ask price and the server return an "invalid stops" error. I dont know what happen because I think the program logic is ok but these results are illogical because stop loss should be 50 points below ask price according to the "SL = Ask - 50 * Point" line. I have checked the code in orden to find something wrong but I didnt found nothing wrong.
I am running this script in a demo account that shows rates in pippetes (I dont know if this info could be important to solve the problem).
Anybody have idea how to solve this problem?
Thanks in advance,
DayDream