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

Need some help

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

    Need some help

    I got this thing to plot, but the values were incorrect. I made some changes and broke it completely. The logic looks fine to me and it compiles OK, but it doesn't plot anything.

    Can you tell from this what's wrong?

    if (CurrentBar > activeBar)
    {
    previousVol = 0; // reset all variables
    buys = 0;
    sells = 0;
    activeBar = CurrentBar;
    }
    else
    {
    //Calculate the volume traded since the last update
    double tradeVol = previousVol == 0 ? Volume[0] : Volume[0] - previousVol;
    //Determine if the volume increase was on the bid or ask
    if (Close[0] >= GetCurrentAsk())
    buys += tradeVol;
    else if (Close[0] <= GetCurrentBid())
    sells += tradeVol;


    netVol = buys - sells; //Get the net volume
    previousVol = Volume[0]; //Update the volume
    }
    SpreadOpen.Set(0); //Want all bars to start at the zero line
    SpreadClose.Set(netVol); //The bar should track and close on the net volume
    SpreadHigh.Set(buys); // plot the total buy vol above the line
    SpreadLow.Set(-1*sells); //Plot the total sell vol below the line
    }

    #2
    Hello tiger45,

    Thank you for your post.

    When you add the indicator to the chart please go to the Log tab of the Control Center. Are there messages concerning the indicator? If so, what do they report?

    Comment


      #3
      Looks like two different ones:

      11/26/2014 3:01:57 PM Default Error on calling 'OnStartUp' method for indicator 'SpreadCandlesticks': Input series Period must be time-based (Minute,Day,Week,Month,Year,or Second).


      and

      11/26/2014 2:09:16 PM Default Error on plotting indicator 'SpreadCandlesticks'. Please check the 'OnBarUpdate' or the 'Plot' method: Overflow error.


      I've pieced together code from the SpreadCandlesticks indi and the BuySellVolume indi. Both of these indicators work on the volume chart individually, so there's something that I've changed or neglected.

      Thanks for your help.

      Comment


        #4
        Hello tiger45,

        Thank you for your response.

        Are you editing the SpreadCandlesticks? Or are you calling the SpreadCandlesticks in your code?

        Comment


          #5
          I got it taken care of, thanks.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by judysamnt7, 03-13-2023, 09:11 AM
          4 responses
          59 views
          0 likes
          Last Post DynamicTest  
          Started by ScottWalsh, Today, 06:52 PM
          4 responses
          36 views
          0 likes
          Last Post ScottWalsh  
          Started by olisav57, Today, 07:39 PM
          0 responses
          7 views
          0 likes
          Last Post olisav57  
          Started by trilliantrader, Today, 03:01 PM
          2 responses
          21 views
          0 likes
          Last Post helpwanted  
          Started by cre8able, Today, 07:24 PM
          0 responses
          10 views
          0 likes
          Last Post cre8able  
          Working...
          X