3 bar high/low entry maintain active order until 3 bar high/low in opposite direction - futures io
futures io futures trading



3 bar high/low entry maintain active order until 3 bar high/low in opposite direction


Discussion in NinjaTrader

Updated by mrticks
      Top Posters
    1. looks_one mrticks with 4 posts (3 thanks)
    2. looks_two wh with 3 posts (2 thanks)
    3. looks_3 Saroj with 1 posts (0 thanks)
    4. looks_4 sam028 with 1 posts (0 thanks)
    1. trending_up 4,493 views
    2. thumb_up 5 thanks given
    3. group 2 followers
    1. forum 8 replies
    2. attach_file 1 attachments




Welcome to futures io: the largest futures trading community on the planet, with well over 100,000 members
  • 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 and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

 
Search this Thread
 

3 bar high/low entry maintain active order until 3 bar high/low in opposite direction

(login for full post details)
  #1 (permalink)
Dublin, Ireland.
 
Experience: Advanced
Platform: NinjaTrader, TOS, Multicharts, Open Source various
Trading: FDAX, cable/yen, FX, options on commodities
 
mrticks's Avatar
 
Posts: 67 since Jun 2009
Thanks: 16 given, 10 received



Hello,

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!!!!!

 
Code
protected override void Initialize()
        {
            CalculateOnBarClose = true;
            
        SetTrailStop("3BR Long Entry", CalculationMode.Ticks, TrailStop, false);
        }
        


        /// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()
        {
            if  (Close[2] < Open[2] && Close[1] < Open[1] && Close[0] < Open[0])
            {
             EnterLongStop(ContractAmount, High[1], "3BR Long Entry" );
            }

Attached Thumbnails
Click image for larger version

Name:	3BLong.bmp
Views:	331
Size:	2.22 MB
ID:	3608  
Reply With Quote
The following user says Thank You to mrticks for this post:

Can you help answer these questions
from other members on futures io?
Trade Summary Error
MultiCharts
QDEL
Stocks and ETFs
Degiro Negative Balance Advice
Traders Hideout
Contract-adjusted volume composite in Sierra
Sierra Chart
Where I can find knoxville divergence indicator for ninja trader 8?
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on futures io
VWAP for stock index futures trading?
43 thanks
VWAP oscillator for NT8
15 thanks
Battlestations: Show us your trading desks!
12 thanks
Price Action Kewltech Style
7 thanks
Index options vs futures options
7 thanks
 
(login for full post details)
  #2 (permalink)
Site Moderator
 
 
sam028's Avatar
 
Posts: 3,639 since Jun 2009
Thanks: 3,764 given, 4,445 received

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.

Follow me on Twitter Reply With Quote
 
(login for full post details)
  #3 (permalink)
Dublin, Ireland.
 
Experience: Advanced
Platform: NinjaTrader, TOS, Multicharts, Open Source various
Trading: FDAX, cable/yen, FX, options on commodities
 
mrticks's Avatar
 
Posts: 67 since Jun 2009
Thanks: 16 given, 10 received



sam028 View 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 response Sam. I had seen IOrder in the NinjaTrader help section and it is very close to what I need.

The code looks like:
 
Code
private IOrder  entryOrder = null;
 protected override  void OnBarUpdate()  
{ 
    if (entryOrder == null && Close[0] >  Open[0]) 
        entryOrder = EnterLong();  
}
 protected override void OnOrderUpdate(IOrder order) 
{ 
    if (entryOrder  != null &&  entryOrder.Token == order.Token) 
    {  
        Print(order.ToString()); 
         if (order.OrderState ==  OrderState.Filled) 
            entryOrder =  null; 
     } 
}
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.


Thanks.

Reply With Quote
 
(login for full post details)
  #4 (permalink)
Neubrandenburg, Germany
 
Experience: Advanced
Platform: R
Trading: Stocks
 
wh's Avatar
 
Posts: 538 since Jun 2009
Thanks: 298 given, 503 received

sory forget yesterday to post:

here are some examples

asgs - Revision 13: /trunk

Reply With Quote
The following 2 users say Thank You to wh for this post:
 
(login for full post details)
  #5 (permalink)
Dublin, Ireland.
 
Experience: Advanced
Platform: NinjaTrader, TOS, Multicharts, Open Source various
Trading: FDAX, cable/yen, FX, options on commodities
 
mrticks's Avatar
 
Posts: 67 since Jun 2009
Thanks: 16 given, 10 received


wh View Post
sory forget yesterday to post:

here are some examples

asgs - Revision 13: /trunk

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.


Thanks,

Gavin.

Reply With Quote
 
(login for full post details)
  #6 (permalink)
Neubrandenburg, Germany
 
Experience: Advanced
Platform: R
Trading: Stocks
 
wh's Avatar
 
Posts: 538 since Jun 2009
Thanks: 298 given, 503 received

thats is not my code i do not auto trade ... but sometimes ...

hope it helps ...

Reply With Quote
 
(login for full post details)
  #7 (permalink)
Arcata, CA
 
Experience: Intermediate
Platform: NinjaTrader
Trading: index futures, oil
 
Saroj's Avatar
 
Posts: 486 since Jun 2009
Thanks: 232 given, 413 received


wh View Post
sory forget yesterday to post:

here are some examples

asgs - Revision 13: /trunk

wh, I see a file with the extension ".odt".. Indicators.odt. What is this please?

Reply With Quote
 
(login for full post details)
  #8 (permalink)
Neubrandenburg, Germany
 
Experience: Advanced
Platform: R
Trading: Stocks
 
wh's Avatar
 
Posts: 538 since Jun 2009
Thanks: 298 given, 503 received

odt is an open office format like the a word document from micro office

<googl>odt open</google>

Reply With Quote
 
(login for full post details)
  #9 (permalink)
Dublin, Ireland.
 
Experience: Advanced
Platform: NinjaTrader, TOS, Multicharts, Open Source various
Trading: FDAX, cable/yen, FX, options on commodities
 
mrticks's Avatar
 
Posts: 67 since Jun 2009
Thanks: 16 given, 10 received

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.


private IOrder myEntryOrder = null;
private int barNumberOfOrder = 0;
protected override void OnBarUpdate()

enterlongstop blah blah blah
barNumberOfOrder = CurrentBar;

// If entryOrder has not been filled within x bars, cancel the order.
else if (myEntryOrder != null && CurrentBar > barNumberOfOrder + ActiveBars)
{

CancelOrder(myEntryOrder);
}


The ActiveBars reference above in the else if statement is from a private int.

Reply With Quote
The following 2 users say Thank You to mrticks for this post:


futures io Trading Community Platforms and Indicators NinjaTrader > 3 bar high/low entry maintain active order until 3 bar high/low in opposite direction


November 13, 2009


Upcoming Webinars and Events
 

An Afternoon With futures io member TropicalTrader

Elite only
     



Copyright © 2020 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts