Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Please help translating TOS to NT8 C#

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

    Please help translating TOS to NT8 C#

    I'm getting back in to trading stocks utilizing my TD account as my data provider for stocks to NT8, while I get use to trading again.

    I'm trying to code my basic indicator in NT8, but need some translation work from TOS to C#.



    User defined Input:

    Period = 1 (I want this to change

    Nonadjustable input:
    Length = 10 = default length

    Indicator zScore math here:

    zScore = (price - Average(price, length)) / StDev(price, length);

    plot zScore = Average(price, length* period);


    Thank you for any help provided. I'm new to both coding and NT 8.

    my main questions is what is the code for the following pieces of the formula above?
    is price = to close[0]
    is Average = aveclose[0]



    Last edited by Jmp470; 12-23-2020, 02:05 PM.

    #2
    Welcome to the forums Jmp470!

    If you are new to NinjaScript and C# I suggest starting with our indicator/strategy tutorials from NinjaTrader 7 to get acquainted with NinjaScript. You can then reference the Code Breaking Changes page of the Help Guide to quickly review the implementation differences.

    NinjaTrader 7 tutorials - https://ninjatrader.com/support/help...indicators.htm

    NinjaTrader 8 Code Breaking Changes - https://ninjatrader.com/support/help...ng_changes.htm

    Plotting in NinjaTrader 8 is done by adding a plot with AddPlot and assigning the plot Values[][] in OnBarUpdate. Please see AddPlot documentation and also see our open source indicators for further direction and examples.

    AddPlot - https://ninjatrader.com/support/help...8/?addplot.htm

    Averages can be calculated with an SMA indicator.

    SMA NinjaScript documentation - https://ninjatrader.com/support/help...simple_sma.htm

    User defined inputs can be easily created with a New Indicator Wizard, but you can also add them manually.

    New Indicator Wizard - https://ninjatrader.com/support/help.../ns_wizard.htm

    Creating User Defined Inputs - https://ninjatrader.com/support/help...d_input_pa.htm

    If you need further direction with C# syntax, I may suggest using the Strategy Builder to create simple logical conditions and to use the View Code button to see the resulting syntax. You may also reference some publicly available C# resources external to NinjaTrader to learn more about C#. These resources are publicly available.

    Strategy Builder 301 - https://www.youtube.com/watch?v=_KQF2Sv27oE

    External C# resource - https://www.tutorialspoint.com/csharp/index.htm

    We look forward to assisting.

    Comment


      #3
      Jim,
      First: Happy Holidays.
      Second: Thank you for the post, I've been reviewing the material that you provided, I believe I could have more questions than answers with it :-)

      I built the strategy with the wizard, but it asks for my formula, that's where I was having the problem. Knowing what the code was for price, std dev, etc. That I have not found yet. I will keep looking, but if your in the giving mood, I would take the code for that one line.

      Comment


        #4
        Thanks for the wishes Jmp470!

        The Strategy Builder can be used to add StdDev indicators and to see how PriceSeries (Open, High. Low Close) are used. You can also reference the System Indicators section of the Help Guide as well as our Working with PriceSeries documentation.

        Working with PriceSeries - https://ninjatrader.com/support/help...ice_series.htm

        System Indicator Methods - https://ninjatrader.com/support/help...indicators.htm

        If you have any follow up questions, please feel free to ask them here. If you have another inquiry that could be considered separate or may be useful to others browsing the forum if a new thread is opened, please do not hesitate to open a new thread.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        605 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        351 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        105 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        560 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        561 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X