Announcement

Collapse
No announcement yet.

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() -

    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 -

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by sjsj2732, Yesterday, 04:31 AM
        0 responses
        33 views
        0 likes
        Last Post sjsj2732  
        Started by NullPointStrategies, 03-13-2026, 05:17 AM
        0 responses
        286 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        284 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        133 views
        1 like
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        91 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Working...
        X