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

Assigning Data to Custom Series

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

    Assigning Data to Custom Series

    Ok I want to define a custom series where the end result is a series Velocity[0] = Close[0] - Close[1] and Velocity[1]=Close[1]-Close[2] etc. etc. So far I have coded part of it as following...

    public class SeriesTest : Strategy
    {
    private Series<double> Velocity;
    .
    .
    .

    else if (State == State.DataLoaded)
    {
    Velocity = new Series<double>(this);

    I have tried the following code OnBarUpdate

    Velocity[0]=Close[0]-Close[1];

    But when I print out my Velocity values they are incorrect.

    How and where do I correctly assign the Data to my series?

    #2
    Hello DuggyLou,

    If you add print statements which contain the time of the bar, do they differ from what you’d expect?

    For example,
    Print(Time[0].ToString()+Time[1].ToString()+Close[0].ToString()+":"+Close[1].ToString());

    I look forward to your reply.
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      Here is a sample of my output. I have added the statement you provided and also printed out my resulting Velocity values "Velocity[0] Through Velocity[2].. It looks like Velocity[0] is correct but [1] and [2] are always -0.0399999999999991 and 0.019999999999996 respectively.. How do I get the correct data loaded into the whole series and not just the first value Velocity[0] ?

      My code is
      Velocity[0]=Close[0]-Close[1];
      Print(Time[0].ToString()+Time[1].ToString()+Close[0].ToString()+":"+Close[1].ToString());
      Print("Velocity[0] Velocity1[1] Velocity[2]");
      Print(Velocity[0]);
      Print(Velocity[1]);
      Print(Velocity[2]);

      5/26/2017 2:55:00 PM5/26/2017 2:54:50 PM49.37:49.4
      Velocity[0] Velocity1[1] Velocity[2]
      -0.0300000000000011
      -0.0399999999999991
      0.019999999999996
      5/26/2017 2:55:00 PM5/26/2017 2:54:40 PM49.37:49.44
      Velocity[0] Velocity1[1] Velocity[2]
      -0.0700000000000003
      -0.0399999999999991
      0.019999999999996
      5/26/2017 2:55:00 PM5/26/2017 2:54:30 PM49.37:49.42
      Velocity[0] Velocity1[1] Velocity[2]
      -0.0500000000000043
      -0.0399999999999991
      0.019999999999996
      5/26/2017 2:55:00 PM5/26/2017 2:54:10 PM49.37:49.45
      Velocity[0] Velocity1[1] Velocity[2]
      -0.0800000000000054
      -0.0399999999999991
      0.019999999999996
      5/26/2017 2:55:00 PM5/26/2017 2:50:00 PM49.37:49.39
      Velocity[0] Velocity1[1] Velocity[2]
      -0.0200000000000031
      -0.0399999999999991
      0.019999999999996
      5/26/2017 2:55:10 PM5/26/2017 2:55:00 PM49.38:49.37
      Velocity[0] Velocity1[1] Velocity[2]
      0.0100000000000051
      -0.0399999999999991
      0.019999999999996
      5/26/2017 2:55:20 PM5/26/2017 2:55:10 PM49.39:49.38
      Velocity[0] Velocity1[1] Velocity[2]
      0.00999999999999801
      -0.0399999999999991
      0.019999999999996
      5/26/2017 2:55:20 PM5/26/2017 2:55:00 PM49.39:49.37
      Velocity[0] Velocity1[1] Velocity[2]
      0.0200000000000031
      -0.0399999999999991
      0.019999999999996
      5/26/2017 2:55:20 PM5/26/2017 2:54:40 PM49.39:49.44
      Velocity[0] Velocity1[1] Velocity[2]
      -0.0499999999999972
      -0.0399999999999991
      0.019999999999996
      5/26/2017 2:55:30 PM5/26/2017 2:55:20 PM49.38:49.39
      Velocity[0] Velocity1[1] Velocity[2]
      -0.00999999999999801
      -0.0399999999999991
      0.019999999999996
      5/26/2017 2:55:30 PM5/26/2017 2:55:00 PM49.38:49.37
      Velocity[0] Velocity1[1] Velocity[2]
      0.0100000000000051
      -0.0399999999999991
      0.019999999999996
      5/26/2017 2:55:40 PM5/26/2017 2:55:30 PM49.39:49.38
      Velocity[0] Velocity1[1] Velocity[2]
      0.00999999999999801
      -0.0399999999999991
      0.019999999999996
      5/26/2017 2:55:40 PM5/26/2017 2:55:20 PM49.39:49.39
      Velocity[0] Velocity1[1] Velocity[2]
      0
      -0.0399999999999991
      0.019999999999996

      Comment


        #4
        I've got it figured out. I've created a Velocity indicator and call that method within my main script. Seems to work fine. Thanks for your input.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Waxavi, Today, 02:10 AM
        0 responses
        2 views
        0 likes
        Last Post Waxavi
        by Waxavi
         
        Started by TradeForge, Today, 02:09 AM
        0 responses
        6 views
        0 likes
        Last Post TradeForge  
        Started by Waxavi, Today, 02:00 AM
        0 responses
        2 views
        0 likes
        Last Post Waxavi
        by Waxavi
         
        Started by elirion, Today, 01:36 AM
        0 responses
        4 views
        0 likes
        Last Post elirion
        by elirion
         
        Started by gentlebenthebear, Today, 01:30 AM
        0 responses
        4 views
        0 likes
        Last Post gentlebenthebear  
        Working...
        X