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

Help with simple indicator.

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

    Help with simple indicator.

    Hi everyone!
    I have no programming skills , And try to get some help with this one.

    Take 3 points from a candlestick and plug it into this equation :
    X= (Close - Low)/ (High- Low)

    That's it!

    And in the next bar:
    Only buy when X score is between 0-25%
    Only sell when X score is between 75-100%

    I recommend it with addition to your strategy...

    Thank you very much!
    Attached Files
    Last edited by Oferedry; 11-11-2015, 07:53 AM.

    #2
    Hello Oferedry,

    Thank you for your inquiry.

    You would be able to get Close, Low, and High values of a bar by utilizing the Close, Low, and High collections.

    More information about these collections can be found in the NinjaTrader help guide at the links below:

    Here's a quick example of how you could utilize these in NinjaScript:
    Code:
    private double X = 0;
    
    protected override void OnBarUpdate()
    {
         // with CalculateOnBarClose set to true in Initialize(), the logic below will execute once a bar closes
         X = (Close[0] - Low[0]) / (High[0] - Low[0]);
    
         if (X >= 0 && X <= 25) // if X is more than or equal to 0 AND less than or equal to 25, enter long
              EnterLong();
         else if (X >= 75 && X <= 100) // else if X is more than or equal to 75 AND less than or equal to 100, enter short
              EnterShort();
    }
    We do have resources to help you begin creating NinjaScript Strategies/Indicators.

    The best way to begin learning NinjaScript is to use the Strategy Wizard. With the Strategy Wizard you can setup conditions and variables and then see the generated code in the NinjaScript Editor by clicking the View Code button.

    I'm also proving a link to a pre-recorded set of videos 'Strategy Wizard 301' and 'NinjaScript Editor 401' for you to view at your own convenience.
    Strategy Wizard 301
    NinjaScript Editor 401

    There are a few Sample Automated Strategies which come pre-configured in NinjaTrader that you can use as a starting point. These are found under Tools--> Edit NinjaScript--> Strategy. You will see locked strategies where you can see the details of the code, but you will not be able to edit (you can though always create copies you can later edit via right click > Save as)

    We also have some Reference samples online as well as ‘Tips and Tricks’ for both indicators and strategies:
    Click here to see our NinjaScript Reference Samples
    Click here to see our NinjaScript Tips

    These samples can be downloaded, installed and modified from NinjaTrader and hopefully serve as a good base for your custom works.

    Further, 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


      #3
      Thank you
      For now it's too complicate to me... But I'm on it!!!
      Can you guide me how to wrote new indicator that plot the value of X
      soon as the current bar is close?
      No need a strategy the enter buy or sell command .
      All i want is to see the X value.

      Thank you again

      Comment


        #4
        Hello Oferedry,

        If you would like your indicator to plot the value of X at bar close, you'll want to ensure that CalculateOnBarClose is set to true in the Initialize() method. In OnBarUpdate(), you'll just have your indicator calculate and plot X.

        Here's an example:
        Code:
        private double X = 0;
        
        protected override void Initialize()
        {
             CalculateOnBarClose = true;
             Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "X Line"));
        }
        
        protected override void OnBarUpdate()
        {
             X = (Close[0] - Low[0]) / (High[0] - Low[0]);
             Value.Set(X);
        }
        Please, let us know if we may be of further assistance.
        Zachary G.NinjaTrader Customer Service

        Comment


          #5
          Thank you very much!!!
          You are great as always.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by algospoke, Yesterday, 06:40 PM
          2 responses
          23 views
          0 likes
          Last Post algospoke  
          Started by ghoul, Today, 06:02 PM
          3 responses
          15 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by jeronymite, 04-12-2024, 04:26 PM
          3 responses
          45 views
          0 likes
          Last Post jeronymite  
          Started by Barry Milan, Yesterday, 10:35 PM
          7 responses
          22 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by AttiM, 02-14-2024, 05:20 PM
          10 responses
          181 views
          0 likes
          Last Post jeronymite  
          Working...
          X