Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.

    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;
        			}
        		}

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by frankthearm, Today, 09:08 AM
        5 responses
        14 views
        0 likes
        Last Post NinjaTrader_Clayton  
        Started by jeronymite, 04-12-2024, 04:26 PM
        3 responses
        43 views
        0 likes
        Last Post jeronymite  
        Started by yertle, Today, 08:38 AM
        5 responses
        15 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Started by adeelshahzad, Today, 03:54 AM
        3 responses
        19 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Started by bill2023, Yesterday, 08:51 AM
        6 responses
        27 views
        0 likes
        Last Post NinjaTrader_Erick  
        Working...
        X