Help me plz~~ some question about order

How to create strategies and indicators
Message
Author
woodrat
Posts: 3
Joined: Wed Jul 01, 2009 6:58 pm

Help me plz~~ some question about order

#1 Postby woodrat » Fri Jul 03, 2009 1:46 am

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!

dackjaniels
Posts: 151
Joined: Tue Feb 24, 2009 1:03 pm

#2 Postby dackjaniels » Fri Jul 03, 2009 7:56 am

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

lhx
Posts: 5
Joined: Sun May 15, 2011 3:54 pm
Location: Texas

#3 Postby lhx » Tue May 17, 2011 10:49 pm

While my problem was different, your code helped a bunch. Many thanks!


Return to “FT API”

Who is online

Users browsing this forum: No registered users and 20 guests