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

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 JoMoon2024, Today, 06:56 AM
        0 responses
        6 views
        0 likes
        Last Post JoMoon2024  
        Started by Haiasi, 04-25-2024, 06:53 PM
        2 responses
        17 views
        0 likes
        Last Post Massinisa  
        Started by Creamers, Today, 05:32 AM
        0 responses
        5 views
        0 likes
        Last Post Creamers  
        Started by Segwin, 05-07-2018, 02:15 PM
        12 responses
        1,786 views
        0 likes
        Last Post Leafcutter  
        Started by poplagelu, Today, 05:00 AM
        0 responses
        3 views
        0 likes
        Last Post poplagelu  
        Working...
        X