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 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 samish18, Today, 08:31 AM
        1 response
        1 view
        0 likes
        Last Post NinjaTrader_Clayton  
        Started by Creamers, 09-08-2023, 10:26 AM
        6 responses
        157 views
        0 likes
        Last Post JonyGurt  
        Started by funk10101, Today, 08:14 AM
        1 response
        2 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by trilliantrader, Today, 08:16 AM
        2 responses
        6 views
        0 likes
        Last Post trilliantrader  
        Started by bill2023, Yesterday, 08:51 AM
        3 responses
        22 views
        0 likes
        Last Post bltdavid  
        Working...
        X