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 Shansen, 08-30-2019, 10:18 PM
          24 responses
          938 views
          0 likes
          Last Post spwizard  
          Started by Max238, Today, 01:28 AM
          0 responses
          3 views
          0 likes
          Last Post Max238
          by Max238
           
          Started by rocketman7, Today, 01:00 AM
          0 responses
          2 views
          0 likes
          Last Post rocketman7  
          Started by wzgy0920, 04-20-2024, 06:09 PM
          2 responses
          27 views
          0 likes
          Last Post wzgy0920  
          Started by wzgy0920, 02-22-2024, 01:11 AM
          5 responses
          32 views
          0 likes
          Last Post wzgy0920  
          Working...
          X