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 cre8able, 02-11-2023, 05:43 PM
        3 responses
        235 views
        0 likes
        Last Post rhubear
        by rhubear
         
        Started by frslvr, 04-11-2024, 07:26 AM
        8 responses
        113 views
        1 like
        Last Post NinjaTrader_BrandonH  
        Started by stafe, 04-15-2024, 08:34 PM
        10 responses
        45 views
        0 likes
        Last Post stafe
        by stafe
         
        Started by rocketman7, Today, 09:41 AM
        3 responses
        11 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by traderqz, Today, 09:44 AM
        2 responses
        10 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Working...
        X