For an example, if an order is made with take profit as 100pip and stop loss as 100pip, I would like to know how to change the stop loss to the initial order price with mofidyorder when the price increases more than 50pip from the initial order price.
Also, I want to know how to not let an order be made for a certain period of time after an order is closed.
Thank you so much for your help!
Help me plz~~ some question about order
-
- Posts: 151
- Joined: Tue Feb 24, 2009 1:03 pm
Hi woodrat,
You can use something like this to adjust the stop loss...
OrderSelect(OrderHandle1, SELECT_BY_TICKET, MODE_TRADES);
if (OrderProfitPips >= FirstProfitTarget) AND (OrderStopLoss <> OrderOpenPrice) AND NOT (OrderClosed(OrderHandle1)) then
ModifyOrder(OrderHandle1,0,OrderOpenprice,0);
Where OrderHandle1 is the Order Handle you stored when creating the order and FirstProfitTarget is the limit you need to reach before the stop is moved (50 in your example).
Regarding the time delay before opening a new order...
You could create a global variable to store the time the last order was closed (the time of the candle on which it is closed, not the actual time on your local clock!!)
Then using this variable you can compare the time of the current candle to your stored time and work out if enough time has passed. If it has then continue to look for a new entry otherwise exit. Google and help files will assist you in finding the correct commands to manipulate and compare the time variables but if you have problems post again
Hope this helps,
Steve
You can use something like this to adjust the stop loss...
OrderSelect(OrderHandle1, SELECT_BY_TICKET, MODE_TRADES);
if (OrderProfitPips >= FirstProfitTarget) AND (OrderStopLoss <> OrderOpenPrice) AND NOT (OrderClosed(OrderHandle1)) then
ModifyOrder(OrderHandle1,0,OrderOpenprice,0);
Where OrderHandle1 is the Order Handle you stored when creating the order and FirstProfitTarget is the limit you need to reach before the stop is moved (50 in your example).
Regarding the time delay before opening a new order...
You could create a global variable to store the time the last order was closed (the time of the candle on which it is closed, not the actual time on your local clock!!)
Then using this variable you can compare the time of the current candle to your stored time and work out if enough time has passed. If it has then continue to look for a new entry otherwise exit. Google and help files will assist you in finding the correct commands to manipulate and compare the time variables but if you have problems post again
Hope this helps,
Steve
Who is online
Users browsing this forum: No registered users and 16 guests