• 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

Indicator values from different time frames

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

    Indicator values from different time frames

    Is it possible to create an indicator/strategy that f.x. uses the Stochastic value from 2 different time frames simultaneously?

    #2
    Hello m96gran,

    Thank you for writing in.

    It is possible for your script to reference the Stochastic value of two different series.

    You will need to ensure that you add the desired time frames to your script. You can then pass them into the Stochastics indicator.

    More information about working with multi-series scripts can be found here: https://ninjatrader.com/support/help...nstruments.htm

    Here's an example:
    Code:
    protected override void Initialize()
    {
         // adding a 10 minute series of the same instrument to the script
         Add(PeriodType.Minute, 10);
    }
    
    protected override void OnBarUpdate()
    {
         // make sure that all series contain enough bars before beginning
         // this is checking to see that each series contains at least one bar
         if (CurrentBars[0] < 0 || CurrentBars[1] < 0)
              return;
    
         // in my example, I just want the stochastics D value of the primary series to be printed if the primary series is calling OnBarUpdate() and the stochastics D value of the secondary series to be printed if the secondary series is calling OnBarUpdate()
         if (BarsInProgress == 0)
              Print(Stochastics(BarsArray[0], 3, 14, 7).K[0];
    
         if (BarsInProgress == 1)
              Print(Stochastics(BarsArray[1], 3, 14, 7).K[0];
    }
    Please, let us know if we may be of further assistance.
    Zachary G.NinjaTrader Customer Service

    Comment


      #3
      Thanks. But I'll have to study how to program some more first I think, I'm pretty new to this

      I want to make an indicator that prints Value=1 if Stochastic on Timeframe 240min is > 80 & Stochastic on Timeframe Day > 80.
      Else Value=0.

      Comment


        #4
        Hello m96gran,

        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 providing 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
        Zachary G.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by tff2011, Today, 01:15 AM
        1 response
        14 views
        0 likes
        Last Post NinjaTrader_PatrickG  
        Started by StevenNelson, Today, 05:39 AM
        0 responses
        1 view
        0 likes
        Last Post StevenNelson  
        Started by Tradix10, 11-14-2018, 09:34 PM
        25 responses
        668 views
        1 like
        Last Post aprendiz  
        Started by GLFX005, Today, 05:05 AM
        0 responses
        6 views
        0 likes
        Last Post GLFX005
        by GLFX005
         
        Started by ArmKnuckle, Today, 01:25 AM
        0 responses
        18 views
        0 likes
        Last Post ArmKnuckle  
        Working...
        X