Hello,
I have problem with modifing orders.
I set stop-loss buy orders and I want to change them just if the value of the currency increase by 6 Points in the way so that I change only stop-loss value, keeoing the takeprofit unchanged.
Because of that i saved takeprofit value in the moment when i set the order in the first place and later I tried to change my orders with the following code:
for (int i=0; i<OrdersTotal() ; i++){
if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true){
if (OrderClosed(OrderTicket())==false){
if (OrderType() == tp_Buy){
if (iLow(Symbol(),TimeFrame,0)<min){
min=iLow(Symbol(),TimeFrame,0);
}
if ( iClose(Symbol(),TimeFrame,0)-ulaz>=6*Point() && Bid()<takepr ){
ModifyOrder(OrderTicket(),0,min-1*Point(),Ask());
}
}
}
}
}
However journal in forex tester says it can't modifiy the order because of incorrect takeprofit.
Please help!
ModifyOrder problem
-
- Posts: 19
- Joined: Wed Mar 28, 2012 10:31 am
Sorry I cope-pasted the wrong code:
The correct one is:
for (int i=0; i<OrdersTotal() ; i++){
if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true){
if (OrderClosed(OrderTicket())==false){
if (OrderType() == tp_Buy){
if (iLow(Symbol(),TimeFrame,0)<min){
min=iLow(Symbol(),TimeFrame,0);
}
if ( iClose(Symbol(),TimeFrame,0)-ulaz>=6*Point() && Bid()<takepr ){
ModifyOrder(OrderTicket(),0,min-1*Point(),takepr);
}
}
if (OrderType() == tp_Sell){
if (iHigh(Symbol(),TimeFrame,0)>max){
max=iHigh(Symbol(),TimeFrame,0);
}
if ( ulaz-iClose(Symbol(),TimeFrame,0) >=6*Point() && Bid()>takepr ){
ModifyOrder(OrderTicket(),0,max+1*Point(),takepr);
}
}
}
}
}
where the takepr is the variable which is remembering takeprofit from before.
Cheers!
The correct one is:
for (int i=0; i<OrdersTotal() ; i++){
if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true){
if (OrderClosed(OrderTicket())==false){
if (OrderType() == tp_Buy){
if (iLow(Symbol(),TimeFrame,0)<min){
min=iLow(Symbol(),TimeFrame,0);
}
if ( iClose(Symbol(),TimeFrame,0)-ulaz>=6*Point() && Bid()<takepr ){
ModifyOrder(OrderTicket(),0,min-1*Point(),takepr);
}
}
if (OrderType() == tp_Sell){
if (iHigh(Symbol(),TimeFrame,0)>max){
max=iHigh(Symbol(),TimeFrame,0);
}
if ( ulaz-iClose(Symbol(),TimeFrame,0) >=6*Point() && Bid()>takepr ){
ModifyOrder(OrderTicket(),0,max+1*Point(),takepr);
}
}
}
}
}
where the takepr is the variable which is remembering takeprofit from before.
Cheers!
-
- Posts: 905
- Joined: Sat Jul 11, 2009 10:54 am
Hello,
please print the takeprofit which you plan to set for the order into the log and then try to modify the TP for the order manually with this value.
If you cannot do that then TP value can be incorrect or "Minimal distance to price" option in currency pair setting is too big.
please print the takeprofit which you plan to set for the order into the log and then try to modify the TP for the order manually with this value.
If you cannot do that then TP value can be incorrect or "Minimal distance to price" option in currency pair setting is too big.
Check our other product here:
http://www.forexcopier.com
http://www.forexcopier.com
Who is online
Users browsing this forum: No registered users and 18 guests