• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

BarRange

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    BarRange

    Hi guys

    I'm looking for a function that counts bar range instead of calculating High - Low.
    Something like:

    if (BarRange[0] >= userVariable )
    {
    EnterLong(1, "EnterLong");
    }

    What do I need to use to check this "BarRange" just for the first bar of the session?

    Thank you in advance,
    KingElephant

    #2
    Hello KingElephant,

    Thank you for your post and welcome to the NinjaTrader Support Forum!

    You would use Bars.FirstBarOfSession: http://www.ninjatrader.com/support/h...rofsession.htm

    Please let me know if I may be of further assistance.
    Patrick H.NinjaTrader Customer Service

    Comment


      #3
      Thank you for suggestion with Bars.FirstBarOfSession

      I'm not sure if I use this properly.

      Would like to enter long at close price of current bar when it's range is greater than 15 ticks.

      if (Range()[0] > 0.15);
      {
      EnterLong("Long open");
      }

      Can you advise?

      What do I need to change if want open position at next bar open price rather than current bar close ? Price in most cases should be the same but just wondering.

      Comment


        #4
        Hello KingElephant,

        Thank you for your response.

        The code would use FirstTickOfBar and a bool to check the next bar. You can find an example below, and information on FirstTickOfBar at the following link: http://www.ninjatrader.com/support/h...ttickofbar.htm
        Code:
                #region Variables
        		private bool checkNBar = false;
                #endregion
        
                protected override void Initialize()
                {
        			
                }
                
                protected override void OnBarUpdate()
                {
        			if (Range()[0] > 0.15);
        			{
        				checkNBar = true;
        			}
        			if(checkNBar && FirstTickOfBar)
        			{
        				EnterLong("Long open");
        				checkNBar = false;
        			}
        		}
        Patrick H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Italianforex, Today, 06:20 AM
        0 responses
        2 views
        0 likes
        Last Post Italianforex  
        Started by NinjaCustomer, Today, 04:53 AM
        0 responses
        4 views
        0 likes
        Last Post NinjaCustomer  
        Started by Oferedry, Today, 01:56 AM
        1 response
        11 views
        0 likes
        Last Post NinjaTrader_EricB  
        Started by NinjaCustomer, Today, 01:28 AM
        1 response
        4 views
        0 likes
        Last Post NinjaTrader_PaulH  
        Started by xbionicx, Today, 01:12 AM
        0 responses
        3 views
        0 likes
        Last Post xbionicx  
        Working...
        X