Question about instantorder

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

Question about instantorder

#1 Postby woodrat » Wed Jul 01, 2009 7:06 pm

Hi Mike,

From:

if (A > B) and( Orderstotal=0) then Sendinstantorder

When the Order closes and if the criteria is satisfied another Order is made. How do I apply the "if"-function after an Orderclosed bar is complete and goes on to bar(1).

imax:=0;
for i := 1 to 20 do
If imax < High(i) then imax:=High(i);

if (Imax <= High(0)) and (OrdersTotal = 0) then
SendInstantOrder(Symbol, op_Buy, LotSize, Ask - StopLoss*Point, Ask + TakeProfit*Point, '', 0, OrderHandle);

Like from the codes above, after applying them to the 20 bars and after their Orderclose, how do I search for another set of 20 bars again?


And,

When an alarm goes off as a bar exceeds the amount of the highest value of the first 20 bars and if the alarm goes off at PERIOD_H1, tell me how to search again for the same signal/alarm at PERIOD_M15 from that point to make a Sendnstatorder.

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

Re: Question about instantorder

#2 Postby dackjaniels » Thu Jul 02, 2009 6:37 am

woodrat wrote:Hi Mike,

From:

if (A > B) and( Orderstotal=0) then Sendinstantorder

When the Order closes and if the criteria is satisfied another Order is made. How do I apply the "if"-function after an Orderclosed bar is complete and goes on to bar(1).

imax:=0;
for i := 1 to 20 do
If imax < High(i) then imax:=High(i);

if (Imax <= High(0)) and (OrdersTotal = 0) then
SendInstantOrder(Symbol, op_Buy, LotSize, Ask - StopLoss*Point, Ask + TakeProfit*Point, '', 0, OrderHandle);

Like from the codes above, after applying them to the 20 bars and after their Orderclose, how do I search for another set of 20 bars again?


And,

When an alarm goes off as a bar exceeds the amount of the highest value of the first 20 bars and if the alarm goes off at PERIOD_H1, tell me how to search again for the same signal/alarm at PERIOD_M15 from that point to make a Sendnstatorder.



Hi Woodrat,

I'm not Mike but will try and help...

Regarding searching the next 20 bars once the order is closed, your code above should work (I've not tested it though). The 20 bar search will actually be carried out on every tick but a new order will only be created if no order already exists and the entry criteria are met. Unless I am mis-understanding you the end result is what you want.

There are some important points though. If you have any other orders open at the time from another source such as a manual order or this strategy (or another) running on another pair, then this method will not work. In this case you would need to search for the existence of an order more specifically. For instance you could search by currency and perhaps magic number.

Regarding your second question about getting signal on H1 and then moving to M15 to find an entry...maybe something like this....again, not tested...


Global var...

SearchTimeFrame: integer = 60; //intialises search TF to H1


GetSingleTick Proc...

imax:=0;
for i := 1 to 20 do
If imax < iHigh(Symbol, SearchTimeFrame, i) then imax:=High(Symbol, SearchTimeFrame, i);

if (imax <= iHigh(Symbol, SearchTimeFrame, 0)) and (OrdersTotal = 0) then
If SearchTimeFrame = 15 then
begin
SendInstantOrder(Symbol, op_Buy, LotSize, Ask - StopLoss*Point, Ask + TakeProfit*Point, '', 0, OrderHandle); //Opens order if valid entry found on M15
SearchTimeFrame := 60; //After an order is opened the next search reverts to higher timeframe
end
else SearchTimeFrame := 15; // If valid entry found on H1 sets searchtimeframe to M15

If you have further questions don't hesitate.

Steve


Return to “FT API”

Who is online

Users browsing this forum: No registered users and 20 guests