ModifyOrder problem

How to create strategies and indicators
Message
Author
Eve
Posts: 19
Joined: Wed Mar 28, 2012 10:31 am

ModifyOrder problem

#1 Postby Eve » Thu Apr 12, 2012 9:16 am

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!

Eve
Posts: 19
Joined: Wed Mar 28, 2012 10:31 am

#2 Postby Eve » Thu Apr 12, 2012 9:21 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!

FT Support
Posts: 905
Joined: Sat Jul 11, 2009 10:54 am

#3 Postby FT Support » Thu Apr 12, 2012 6:05 pm

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.
Check our other product here:
http://www.forexcopier.com

Eve
Posts: 19
Joined: Wed Mar 28, 2012 10:31 am

#4 Postby Eve » Mon Apr 16, 2012 3:53 am

Thank you. it worked :)


Return to “FT API”

Who is online

Users browsing this forum: No registered users and 21 guests