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

newbie needs urgently help with inputs

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

    newbie needs urgently help with inputs

    hey,
    i have a big problem, if i am in the OnBarUpdate() how exactly do i get here my prices? is currentbar the current prize? Can somebody exactly explain what is happening in the code below? I know its a simple moving average and see that also roughly but i dont know what the value-array is and the input array (what is in these arrays?)

    Code:
     protected override void OnBarUpdate()
            {
                // Use this method for calculating your indicator values. Assign a value to each
                if (CurrentBar == 0)
                    Value.Set(Input[0]);
                else
                {
                    double last = Value[1] * Math.Min(CurrentBar, Period);
    
                    if (CurrentBar >= Period)
                        Value.Set((last + Input[0] - Input[Period]) / Math.Min(CurrentBar, Period));
                    else
                        Value.Set((last + Input[0]) / (Math.Min(CurrentBar, Period) + 1));
                }
    Would be really nice if u could help me with this.
    Franz

    #2
    Franzl, Value references the first, main indicator value series - http://www.ninjatrader-support.com/H...AndValues.html

    Of course an indicator be hold multiple ones, those would stored in the Values array - http://www.ninjatrader-support.com/H...V6/Values.html

    Input references the data source the indicator uses, you can enable this to be user configurable if setting PriceTypeSupported = true in the Initialize() -

    BertrandNinjaTrader Customer Service

    Comment


      #3
      hey, thanks for your fast reply, i tried now by myself with creating a new indicator and got this piece of code
      Code:
       protected override void OnBarUpdate()
              {
                  // Calculate the volume average
                  double smavol = SMA(VOL(), Period)[0];
                  //smavol = 0.9*smavol + Vol[0]*0.1;
                  
                  // Set the calculated value to the plot
                  Plot0.Set(smavol);
      it's actually working out, but if i increase the value behind period by 1 to get one bar ago then i dont get a graph if i try to apply that on chart, but actually it should only shift the average back by one or not?
      And my next line the Vol[0] should give me the volume of my current bar or not?

      Comment


        #4
        You're welcome, you run into this issue here - http://www.ninjatrader-support2.com/...ead.php?t=3170

        You also want to review this on your 'current bar' question -

        BertrandNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by selu72, Today, 02:01 PM
        1 response
        4 views
        0 likes
        Last Post NinjaTrader_Zachary  
        Started by WHICKED, Today, 02:02 PM
        2 responses
        9 views
        0 likes
        Last Post WHICKED
        by WHICKED
         
        Started by f.saeidi, Today, 12:14 PM
        8 responses
        21 views
        0 likes
        Last Post f.saeidi  
        Started by Mikey_, 03-23-2024, 05:59 PM
        3 responses
        50 views
        0 likes
        Last Post Sam2515
        by Sam2515
         
        Started by Russ Moreland, Today, 12:54 PM
        1 response
        8 views
        0 likes
        Last Post NinjaTrader_Erick  
        Working...
        X