Hello, I need help for my code
The trailing stop does not move(it's fixed when it is active), it should move once the price go to the take profit
here is my code for that
What does it say as an error in the expert tab?
tell me, we can find where the error came from with the code change.
if (Local_Res == false)//Si la orden no se modifico correctamente { Print("Local_ticket: ",Local_ticket, " OrderOpenPrice():" ,OrderOpenPrice(), "New_TSL_Buy:",New_TSL_Buy, " OrderTakeProfit()",OrderTakeProfit(), " Error ",GetLastError()); Alert("Failed for order #", OrderTicket()); Alert("Error code: ", GetLastError()); }
Hello, I need help for my code
The trailing stop does not move(it's fixed when it is active), it should move once the price go to the take profit
here is my code for that
I wouldn't recommend this:
double Trailing_Start= (OrderOpenPrice()-OrderStopLoss())/2; //My SL is not fixed but it depends on the strategy double Trailing_Step= (OrderOpenPrice()-OrderStopLoss())/5; //My TP is not fixed but it depends on the strategy
You are using DIVISION, which will generate non-linear values, which will at some point be out of the STEP values of the Symbol..
By using it like a simple division (which is how it is).. this will work sometimes, and not other times, like lottery.
The better is to create a STEPPING degree, based on a better scale, which must be verified against the STEP values of the Symbol, to adjust for the Correct Stepping
Also, you have to normalize the values, always, this is a must, normalize the resulting value (the new SL value) BEFORE sending it to OrderModify.
The absense of normalization is the most commom source of OrderModify returns failures.
I wouldn't recommend this:
You are using DIVISION, which will generate non-linear values, which will at some point be out of the STEP values of the Symbol..
By using it like a simple division (which is how it is).. this will work sometimes, and not other times, like lottery.
The better is to create a STEPPING degree, based on a better scale, which must be verified against the STEP values of the Symbol, to adjust for the Correct Stepping
Also, you have to normalize the values, always, this is a must, normalize the resulting value (the new SL value) BEFORE sending it to OrderModify.
The absense of normalization is the most commom source of OrderModify returns failures.
- 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 need help for my code
The trailing stop does not move(it's fixed when it is active), it should move once the price go to the take profit
here is my code for that