Hello, I am learning to programing and I have a problem, so I need your help.
I created a script, to open order (works)
Latter I tried to make TP and SL (doesnt work)
I thought I will try it with modyfiing order: (doesnt work)
I tried all of them on Oanda and XeMarkets, could you help me make these simple scripts with TP and SL ?
I want script with 100pip TP and 50 SLWhat is the error code that you get when trying to execute those scripts?
When I was added this line:
Print("OrderSelect failed error code is",GetLastError());
it wrote its error 130, it should be something with TP...
When I was added this line:
Print("OrderSelect failed error code is",GetLastError());
it wrote its error 130, it should be something with TP...Error 130 means invalid stops. Try using NormalizeDouble(yourStopLoss,Digits) for stop loss and NormalizeDouble(yourTakeProfit,Digits) for take profit with OrderSend(). If it still writes that error than try the second form you have tried. If still even then you get that error make the stop loss and take profit wider
Also, in this line :
you have an error. Change it to this :
[PHP]OrderModify(ticket,Ask+100*Point,Ask-100*Point,0,0,Blue);Error 130 means invalid stops. Try using NormalizeDouble(yourStopLoss,Digits) for stop loss and NormalizeDouble(yourTakeProfit,Digits) for take profit with OrderSend(). If it still writes that error than try the second form you have tried. If still even then you get that error make the stop loss and take profit wider
Also, in this line :
you have an error. Change it to this :
[PHP]OrderModify(ticket,Ask+100*Point,Ask-100*Point,0,0,Blue);Could you eplain where to use NormalizeDouble(yourStopLoss,Digits)
I am new in programing, thats why I am asking for help
Could you eplain where to use NormalizeDouble(yourStopLoss,Digits) I am new in programing, thats why I am asking for help
For example like this :
ORder was opened, but still to TP or SL set.. :?
{
int ticket;
//----
ticket=OrderSend(Symbol(),OP_SELL,1.0,Ask,0,0,0,"some comment",16384,0,Green);
OrderSelect(ticket,SELECT_BY_TICKET);
OrderModify(ticket,NormalizeDouble(Ask+100*Point,Digits),NormalizeDouble(Ask-100*Point,Digits),0,0,Blue);
Print("OrderSelect failed error code is",GetLastError());
//----
return(0);
}ORder was opened, but still to TP or SL set.. :?
Try widening Stop loss and Take profit. That is only a 10 pip stop loss and take profit on 5 digit broker and on some brokers it is to near to the opening price
Try widening Stop loss and Take profit. That is only a 10 pip stop loss and take profit on 5 digit broker and on some brokers it is to near to the opening price
I tried also
Ask-10000*Point
Ask+10000*Point
I tried also
Ask-10000*Point
Ask+10000*PointThen I can not help you. Sorry. Check for error codes and see what error are you getting now. If you are doing it properly (all at the righ places) it must work
Finaly I got the code, how to open my order with SL and TP :
int start()
{
x=1;
if (OrdersTotal()<1)
int ticket = OrderSend(Symbol(),OP_BUY,x,Ask,3,0,0,"some comment",16384,Green);
if(ticket == -1)
{
Print(GetLastError());
} else
{
Sleep(1000);
OrderSelect(ticket,SELECT_BY_TICKET);
Print("OrderOpenPrice=", DoubleToStr(OrderOpenPrice(), 5));
int isModified = OrderModify(ticket,OrderOpenPrice(),OrderOpenPrice()-75*Point,OrderOpenPrice()+100*Point,OrderExpiration());
if(!isModified)
{
Print(GetLastError());
}
}
return(0);
}- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello, I am learning to programing and I have a problem, so I need your help.
I created a script, to open order (works)
int start()
{
OrderSend(Symbol(),OP_SELL,1.0,Ask,0,0,0,"some comment",16384,0,Green);
return(0);
}Latter I tried to make TP and SL (doesnt work)
int start() {
OrderSend(Symbol(),OP_BUY,1.0,Ask,0,Ask-250*Point,Ask+250*Point,"some comment",16384,0,Green);
return(0);}
I thought I will try it with modyfiing order: (doesnt work)
{
int ticket;
//----
ticket=OrderSend(Symbol(),OP_SELL,1.0,Ask,0,0,0,"some comment",16384,0,Green);
OrderSelect(ticket,SELECT_BY_TICKET);
OrderModify(ticket,Ask-100*Point,Ask-100*Point,0,0,Blue);
//----
return(0);
}I tried all of them on Oanda and XeMarkets, could you help me make these simple scripts with TP and SL ?
I want script with 100pip TP and 50 SL