Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
3 bar high/low entry maintain active order until 3 bar high/low in opposite direction
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 [1]. So it looks like,
if (Close[2] < Open[2] && Close[1] < Open[1] && Close[0] < Open[0])
{
EnterLongStop(ContractAmount, High[1], "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!!!!!
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.
Platform: NinjaTrader, TOS, Multicharts, Open Source various
Trading: FDAX, cable/yen, FX, options on commodities
Posts: 67 since Jun 2009
Thanks Given: 16
Thanks Received: 10
Thanks for the response Sam. I had seen IOrder in the NinjaTrader help section and it is very close to what I need.
The code looks like:
I was looking for a method to:
else if keep alive for "X" amount of bars &&
else if cancel after "X" amount of bars if not filled &&
else if set period of time &&
else if 3 bar reversal in the other direction ;
I'll look further into IOrder and maybe attach an exit long attached to a different signal.
Platform: NinjaTrader, TOS, Multicharts, Open Source various
Trading: FDAX, cable/yen, FX, options on commodities
Posts: 67 since Jun 2009
Thanks Given: 16
Thanks Received: 10
Hi wh,
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.
Platform: NinjaTrader, TOS, Multicharts, Open Source various
Trading: FDAX, cable/yen, FX, options on commodities
Posts: 67 since Jun 2009
Thanks Given: 16
Thanks Received: 10
Hello all,
As a follow up, I found this code achieved what I needed, which was to keep an order alive for x amount of bars before cancelling the order. Snippets of the necessary below.