Platform: NinjaTrader, TOS, Multicharts, Open Source various
Favorite Futures: FDAX, cable/yen, FX, options on commodities
Posts: 67 since Jun 2009
Thanks: 16 given,
3 bar high/low entry maintain active order until 3 bar high/low in opposite direction
Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).
This is my first post so I hope I don't mess it up! I have written code to enter a buy stop after three successive lower bars at the previous bar high. So when the close is lower than the open 3 times in a row a buy stop is entered at the high of the previous bar, which is . So it looks like,
if (Close < Open && Close < Open && Close < Open)
EnterLongStop(ContractAmount, High, "3BR Long Entry" );
My question is, how can I keep that buy order active untill a specified number of bars have closed without it being filled? I find that I get a lot of orders pending only to be cancelled after the next bar closes as it hasn't reached the buy stop, only for the market to go that way 3 or 4 bars later.
I have attached a screenshot with an example of buy orders placed. I intend to modify this strategy to also implement sell stop orders with the opposite criteria and also place orders a certain amount of ticks above the previous bar high.
Any tips/help/advice or code snippets would be greatly appreciated!!!!!
The following user says Thank You to mrticks for this post:
Maybe using the IOrder class, and manage yourself the cancellation ( see the method EnterLongStop(int barsInProgressIndex, bool liveUntilCancelled, int quantity, double stopPrice, string signalName) ).
But you'll have to manage yourself the order cancellation, wait 1 or 2 bars more for ex.
Thanks for the respone and I took a quick look at some of that code. We likey! We likey! It gave me a warm feeling.
lastBarCount = Bars.Count;
This gave me a few ideas that I will see if I can do something with IOrder and that. Will post my code up when I'm finished if it tests OK. I'll spend some time looking at your code later on this evening and see what I can throw up.