3 bar high/low entry maintain active order until 3 bar high/low in opposite direction - NinjaTrader Programming | futures io social day trading
futures io futures trading


3 bar high/low entry maintain active order until 3 bar high/low in opposite direction
Updated: Views / Replies:3,585 / 8
Created: by mrticks Attachments:1

Welcome to futures io.

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

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

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

Reply
 
Thread Tools Search this Thread
 

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

  #1 (permalink)
Elite Member
Dublin, Ireland.
 
Futures Experience: Advanced
Platform: NinjaTrader, TOS, Multicharts, Open Source various
Favorite Futures: FDAX, cable/yen, FX, options on commodities
 
mrticks's Avatar
 
Posts: 67 since Jun 2009
Thanks: 16 given, 9 received

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).


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
3 bar high/low entry maintain active order until 3 bar high/low in opposite direction-3blong.bmp  
Reply With Quote
The following user says Thank You to mrticks for this post:
 
  #2 (permalink)
Administrator: Retired Backtester
 Vendor: speedytradingservers.com 
Rennes France
 
Futures Experience: Advanced
Platform: NinjaTrader
Broker/Data: IB/Kinetick
Favorite Futures: Futures
 
sam028's Avatar
 
Posts: 3,366 since Jun 2009
Thanks: 3,573 given, 3,982 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.

Reply With Quote
 
  #3 (permalink)
Elite Member
Dublin, Ireland.
 
Futures Experience: Advanced
Platform: NinjaTrader, TOS, Multicharts, Open Source various
Favorite Futures: FDAX, cable/yen, FX, options on commodities
 
mrticks's Avatar
 
Posts: 67 since Jun 2009
Thanks: 16 given, 9 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
 
  #4 (permalink)
Elite Member
Neubrandenburg, Germany
 
Futures Experience: Advanced
Platform: R
Favorite Futures: Stocks
 
wh's Avatar
 
Posts: 538 since Jun 2009
Thanks: 297 given, 480 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:
 
  #5 (permalink)
Elite Member
Dublin, Ireland.
 
Futures Experience: Advanced
Platform: NinjaTrader, TOS, Multicharts, Open Source various
Favorite Futures: FDAX, cable/yen, FX, options on commodities
 
mrticks's Avatar
 
Posts: 67 since Jun 2009
Thanks: 16 given, 9 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
 
  #6 (permalink)
Elite Member
Neubrandenburg, Germany
 
Futures Experience: Advanced
Platform: R
Favorite Futures: Stocks
 
wh's Avatar
 
Posts: 538 since Jun 2009
Thanks: 297 given, 480 received

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

hope it helps ...

Reply With Quote
 
  #7 (permalink)
Elite Member
Arcata, CA
 
Futures Experience: Intermediate
Platform: NinjaTrader
Favorite Futures: index futures, oil
 
Saroj's Avatar
 
Posts: 482 since Jun 2009
Thanks: 223 given, 389 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
 
  #8 (permalink)
Elite Member
Neubrandenburg, Germany
 
Futures Experience: Advanced
Platform: R
Favorite Futures: Stocks
 
wh's Avatar
 
Posts: 538 since Jun 2009
Thanks: 297 given, 480 received

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

<googl>odt open</google>

Reply With Quote
 
  #9 (permalink)
Elite Member
Dublin, Ireland.
 
Futures Experience: Advanced
Platform: NinjaTrader, TOS, Multicharts, Open Source various
Favorite Futures: FDAX, cable/yen, FX, options on commodities
 
mrticks's Avatar
 
Posts: 67 since Jun 2009
Thanks: 16 given, 9 received

Follow up

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:

Reply



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

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Globex High Low spinnybobo The Elite Circle 6 September 11th, 2011 05:45 PM
Plot High/Low points proton242 EasyLanguage Programming 11 July 24th, 2011 05:07 AM
Historical high/low data for advanced bar types RM99 Commodities Futures Trading 9 June 21st, 2011 09:53 AM
Candle strategy High/Low wallsteetking NinjaTrader Programming 3 April 11th, 2011 03:34 PM
Tick diff between High-Low tickvix NinjaTrader 4 June 29th, 2010 02:14 PM


All times are GMT -4. The time now is 12:32 PM.

Copyright © 2017 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
Page generated 2017-12-16 in 0.15 seconds with 20 queries on phoenix via your IP 54.91.38.173