Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Indicator for the body of the candlestick

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

    Indicator for the body of the candlestick

    Hello,

    I have developed a trading system, where the body of the candlestick is playing an important part. I enter a position only when the body of the candlestick occupies a certain amount of the whole candlestick. For example, if the body forms more than 70% of the candlestick, I go long/short.
    So, I would like to ask you, is there such an indicator in NinjaTrader 7, which could calculate percentages real-time?

    Thanks for answers.

    #2
    Originally posted by Wulfgar View Post
    Hello,

    I have developed a trading system, where the body of the candlestick is playing an important part. I enter a position only when the body of the candlestick occupies a certain amount of the whole candlestick. For example, if the body forms more than 70% of the candlestick, I go long/short.
    So, I would like to ask you, is there such an indicator in NinjaTrader 7, which could calculate percentages real-time?

    Thanks for answers.
    You would have to write the indicator, but the code for the method is relatively trivial.
    Code:
    bool validTradeBar = (Math.Abs(Close[0] - Open[0]) >= 0.70 * (High[0] - Low[0]));

    Comment


      #3
      Originally posted by koganam View Post
      You would have to write the indicator, but the code for the method is relatively trivial.
      Code:
      bool validTradeBar = (Math.Abs(Close[0] - Open[0]) >= 0.70 * (High[0] - Low[0]));
      Thanks for the idea, but I am a total beginner to programming in NinjaScript, so I was not able to make a functional indicator - where exactly do I need to "put" that bool line?
      Thanks in advance.

      Comment


        #4
        Hello Wulfgar,

        You would want to place the boolean variable in the Variables region of your code first. Then, in the OnBarUpdate() method, you would assign that variable to the (Math.Abs(Close[0] - Open[0]) >= 0.70 * (High[0] - Low[0])); statement. The reason why you would be assigning the variable in the OnBarUpdate() is because this method is run on every tick (if CalculateOnBarClose is set to false) or at every close of a bar (if CalculateOnBarClose is set to true). As you would like to be calculating in real time, you would want to set the CalculateOnBarClose property to false in the Initialize() method.

        Example:
        Code:
        #region Variables
        private bool validTradeBar = false;
        #endregion
        
        protected override void OnBarUpdate()
        {
             validTradeBar = (Math.Abs(Close[0] - Open[0]) >= 0.70 * (High[0] - Low[0]));
        }
        The following link is to our help guide with an alphabetical reference list to all supported methods, properties, and objects that are used in NinjaScript.
        Alphabetical Reference

        We also have a few tutorials in our help guide for both Indicators and Strategies.
        Indicator tutorials
        Strategy tutorials

        Please let me know if I can be of further assistance.
        Zachary G.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        599 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        344 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        103 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        558 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        557 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X