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

Learning NT programing

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

    Learning NT programing

    I'm very new to NT and I now want to implement some customized strategies on NT. As a begining step I'm trying to covert the following trade station code to NT.

    Could anyone please give me some tips that how can I get it start? Is that doable by a simple program, or I have to develop a new indicator first then develop the strategy on top?

    Sorry if my question seems mis-sync, overall I havent got a clue yet so please bear with me.

    Here is the TS code, its the well know RS system No. 1:

    Variables:
    RelStr(0),
    AvgRelStr(0),
    CalcRelStr(0),
    AvgOBV(0),
    CalcOBV(0),
    CalcStr(0);

    RelStr = IFF(AvgPrice = 0, 0, AvgPrice / AvgPrice Data2);
    AvgRelStr = Average(RelStr, 5);
    CalcRelStr = IFF(RelStr = 0, 0, RelStr / AvgRelStr);

    AvgOBV = Average(OBV, 5);
    CalcOBV = IFF(OBV = 0, 0, OBV / AvgOBV);

    CalcStr = CalcRelStr * CalcOBV;

    If CalcStr Crosses Above 1.0 and MarketPosition = 0 Then
    Buy on Close;
    If CalcStr Crosses Below 1 Then
    ExitLong on Close;
    If Close < EntryPrice * 0.96 Then
    ExitLong on Close;

    #2
    Hi JesseOnt,

    Thanks for your post.

    As you are new to programming in NinjaScript, the best approach would be to build the 'CalcStr' as a custom indicator and complete the executing NinjaScript strategy then in the wizard. Your indicator will then be easily available as a custom 'function' (like in TradeStation), but without having the need to explicitly program it as such.

    I highly recommend you working yourself through these tutorials first, as a lot of questions are covered here - http://www.ninjatrader-support.com/H...verview18.html

    For completing the strategy aspect in the wizard, please review those links then - http://www.ninjatrader-support.com/H...onditions.html







    Originally posted by JesseOnt View Post
    I'm very new to NT and I now want to implement some customized strategies on NT. As a begining step I'm trying to covert the following trade station code to NT.

    Could anyone please give me some tips that how can I get it start? Is that doable by a simple program, or I have to develop a new indicator first then develop the strategy on top?

    Sorry if my question seems mis-sync, overall I havent got a clue yet so please bear with me.

    Here is the TS code, its the well know RS system No. 1:

    Variables:
    RelStr(0),
    AvgRelStr(0),
    CalcRelStr(0),
    AvgOBV(0),
    CalcOBV(0),
    CalcStr(0);

    RelStr = IFF(AvgPrice = 0, 0, AvgPrice / AvgPrice Data2);
    AvgRelStr = Average(RelStr, 5);
    CalcRelStr = IFF(RelStr = 0, 0, RelStr / AvgRelStr);

    AvgOBV = Average(OBV, 5);
    CalcOBV = IFF(OBV = 0, 0, OBV / AvgOBV);

    CalcStr = CalcRelStr * CalcOBV;

    If CalcStr Crosses Above 1.0 and MarketPosition = 0 Then
    Buy on Close;
    If CalcStr Crosses Below 1 Then
    ExitLong on Close;
    If Close < EntryPrice * 0.96 Then
    ExitLong on Close;
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Hi Bertrand

      Yes I had reviewed these topics and now I'm able to build a customer indicator plus a strategy, I think the idea is clear to me but still one thing I'm not getting yet:

      for this sentence:
      RelStr = IFF(AvgPrice = 0, 0, AvgPrice / AvgPrice Data2);

      I assume the first 'AvgPrice' is the average price of current bar, say a 5-min chart, and the 'AvgPrice Data2' is the average price of 2nd data stream, say a daily average data.

      TradeStation handles them using multiple streams, but I don't know how can I implement it through Ninja...I don't knowon a NT's 5-min chart, how to get the data belongs to a daily chart?

      Comment


        #4
        Hi JesseOnt,

        You can use the Add() method to add a datastream to your strategy, please also review this link - http://www.ninjatrader-support.com/H...struments.html

        Then you can access the data with with the 'Closes', 'Highs' or 'Lows' keywords.

        More can be found under those links-







        Here is a code snippet demonstrating the correct use of those keywords -

        Code:
        [COLOR=#0000ff]protected override[/COLOR] [COLOR=#0000ff]void[/COLOR] Initialize() 
        { 
        [COLOR=#008000]// Adds a 5-minute Bars object to the strategy and is automatically assigned [/COLOR][COLOR=#008000]a Bars object index of 1 since the primary data the strategy is run against[/COLOR] [COLOR=#008000]set by the UI takes the index of 0.[/COLOR] 
        Add(Instrument, PeriodType.Minute, 5);} 
         
        [COLOR=#0000ff]protected override[/COLOR] [COLOR=#0000ff]void[/COLOR] OnBarUpdate() 
        { 
        [COLOR=#008000]// Compares the primary bar's low price to the 5-minute bar's low price[/COLOR] 
        [COLOR=#0000ff]if[/COLOR] (Lows[0][0] > Lows[1][0]) 
        Print("The current bar's low price is greater"); 
        }
        BertrandNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by futtrader, Today, 01:16 PM
        0 responses
        1 view
        0 likes
        Last Post futtrader  
        Started by Segwin, 05-07-2018, 02:15 PM
        14 responses
        1,789 views
        0 likes
        Last Post aligator  
        Started by Jimmyk, 01-26-2018, 05:19 AM
        6 responses
        838 views
        0 likes
        Last Post emuns
        by emuns
         
        Started by jxs_xrj, 01-12-2020, 09:49 AM
        6 responses
        3,294 views
        1 like
        Last Post jgualdronc  
        Started by Touch-Ups, Today, 10:36 AM
        0 responses
        13 views
        0 likes
        Last Post Touch-Ups  
        Working...
        X