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

Create a custom simple Index

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

    Create a custom simple Index

    I am new to NinjaScript and I thought maybe someone has done this before or knows an easy solution...

    I want to create a simple Index (hereafter VB Index) that charts in Ninja, and this VB Index is comprised of up to 15 or less stocks. I also want a stock a Weighting Factor (WF). The formula for the VB Index would look as follows…

    VB Index = Stock1 * WF1 + Stock2 * WF2 + Stock3 * WF3 + ……. + Stock15 * WF15

    Seems pretty simple, but then again I do not know much about NinjaScript at this time. I would simply Graph this VB Index in a 2nd Panel along side the Instrument that I am trading.

    Vince B

    #2
    Hello Vince,

    Thank you for your post.

    This is possible and requires adding the instruments to be used to the the indicator via the Add() method. Then you would use Closes[barsInProgress][barsAgo] to call the correct instrument and bar type. For information on using multiple instruments and time frames in your NinjaScript code please visit the following link: http://www.ninjatrader.com/support/h...nstruments.htm

    Please let me know if I may be of further assistance.

    Comment


      #3
      Question...

      If I build this simple VB Index using the 1 Minute Bar charts... and I use the Data of the current Bar (ie: Close[0]... Open[0],...High[0]...Low[0] )... Will the Ninja Chart show the formation of this current Bar[0]... in other words, when you display indicators (ie: EMA(20) ). the current data point of the EMA(20) does not show up until the completion of the 1 Minute Bar (60 seconds)... but when I chart say the Nasdaq 100 Index (ie: NDX)... it shows the creation of the current Bar in real time... tick by tick... the Close and High and Low are bopping up and down until the completion of the 60 second (1 Minute) Bar... I was hoping that my VB Index current Bar will do the same thing... in other words, with the current Bar be shown on the Graph as it is being created for the 60 seconds... or will it just appear as a completed Bar after the 60 seconds just like the EMA(20) Indicator ??

      Vince

      Comment


        #4
        Hello Vince,

        Thank you for your response.

        In that case you would use the property CalculateOnBarClose and set it to false. This means that the indicators will calculate on each incoming tick.

        For information on CalculateOnBarClose please visit the following link: http://www.ninjatrader.com/support/h...onbarclose.htm

        Please let me know if I may be of further assistance.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by andrewtrades, Today, 04:57 PM
        1 response
        5 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by chbruno, Today, 04:10 PM
        0 responses
        3 views
        0 likes
        Last Post chbruno
        by chbruno
         
        Started by josh18955, 03-25-2023, 11:16 AM
        6 responses
        436 views
        0 likes
        Last Post Delerium  
        Started by FAQtrader, Today, 03:35 PM
        0 responses
        6 views
        0 likes
        Last Post FAQtrader  
        Started by rocketman7, Today, 09:41 AM
        5 responses
        19 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Working...
        X