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

Custom Historical Volume Indicator Problem

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

    Custom Historical Volume Indicator Problem

    So I'm looking at this indicator I downloaded. I'm trying to make my own Conditional Statement that basically says if (Volume Crosses the AverageVolume)...Do Something.

    But I can't get it to work. keep getting errors. I've Attached the Indicator. my attempt is on Line 174.

    Can someone show me the Code that I need to make the indicator call Current Volume when it Crosses the AverageVolume. I tried
    Code:
    if(CrossAbove(VOL()[0], averageVolume, 1))
    where "averageVolume" is a Double variable that holds the average. I have no idea how to access it.

    Please Help.

    Thank You
    Attached Files
    Last edited by ginx10k; 06-12-2014, 05:57 PM.

    #2
    Hello ginx10k,

    Thank-you for your post.

    The reason that your code isn't working is because CrossAbove (or CrossBelow) require a dataseries as an input to compare to either another data series or a level.

    Here is what you currently have: if(CrossAbove(VOL()[0], averageVolume, 1)). Using VOL()[0] is specifying the current bar volume which is a double value. The averageVolume is also a double type. Note that there is also a dataseries called AverageVolume.

    To look at the dataseries VOL() crossing above the dataseries AverageVolume, use the following line of code:

    if (CrossAbove (VOL(), AverageVolume,1))

    {

    // do something

    }

    Here is the help guides language reference section where you can find CrossAbove: http://www.ninjatrader.com/support/h..._reference.htm

    Please let me know if I can be of further assistance.
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Thanks for Response.

      Question 1: the Dataseries AverageVolume are you mentioning that cause it's already part of the indicator. the "Plot"??


      and question 2: I used this exact code now:
      Code:
      //Attempting Conditional Statements against Average Volume (If Current Volume Crosses Above Average Volume...Do something)
      			if(CrossAbove(VOL(), AverageVolume, 1))
      			{
      			DrawDot("My dot" + CurrentBar, false, 1, Close[0] + 2 * TickSize, Color.Blue);
      			Alert("Alert", NinjaTrader.Cbi.Priority.Low, " Volume Exceeded",  @"Alert2.wav", 0, Color.Black, Color.Lime);
      
      			}
      and its NOT giving me the Alert or drawing a DOT in real time. can you please check what I'm doing wrong and how to correct this.

      I need the code to Alert as soon as Current Volume Crosses above AverageVolume. thanks Paul

      Comment


        #4
        Basically. I did the code. and tested it out. there was One single instance that it gave me an alert. but I don't understand why other times it's NOT giving alerts when the VOL() goes from 0 and Crosses Above the Average Volume

        Please Can Someone look and Tell me why is this happening. I would like to get this to work before the Weekend.

        Thank you!!

        Comment


          #5
          Hello ginx10k,

          Thank-you for your post.

          The alert only fires once because the rearm time is set to 0. Please set it to some positive value, keeping in mind that you are using the indicator with CalcOnBarClose= false and may get multiple alerts on the same bar.

          The Drawdots is not showing because it is trying to draw dots in the indicator panel when your code indicates it wants to be drawn in the price panel (based on the Close[0]+2* TickSize). Also the dot is being drawn on the wrong bar, it is being drawn on the bar before the volume crossover. To fix the latter, change your code to: DrawDot('My dot' + CurrentBar, false, 0, Close[0] + 2 * TickSize, Color.Blue);

          To put the dots in the pricepanel:
          1) In the initialize section add Overlay = false;
          2) in the code section for the crossover: (I put 30 for the rearm seconds, please set to meet your needs)

          Code:
          if(CrossAbove(VOL(), AverageVolume, 1))
          {
          Overlay = true;
          DrawOnPricePanel=true;
          DrawDot("My dot" + CurrentBar, false, 0, Close[0] + 2 * TickSize, Color.Blue);
          Overlay=false;
          Alert("Alert", NinjaTrader.Cbi.Priority.Low, " Volume Exceeded", @"Alert2.wav", 30, Color.Black, Color.Lime);
          
          }
          Please let me know if I can be of further assistance.
          Paul H.NinjaTrader Customer Service

          Comment


            #6
            I've placed the code and attached to chart. and I see Dots on back test. but when using Market replay Or Live Forward Data, it DOESN'T Plot DOT Nor does it Alert.

            can you or someone put this on a chart, look at market replay or live data. and Help me realize what is wrong with the Conditional Statement.

            Please!!

            Comment


              #7
              I also tried this

              Code:
              Add (new Plot (new Pen (Color.Red, 3), PlotStyle.Line, "VolumePlot"));
              Code:
              VolumePlot.Set(Volume[0]);
              			
              			if(CrossAbove(VolumePlot[0], AverageVolume, 1))
              					{
              					DrawDot("My dot" + CurrentBar, false, 0, Close[0] + 2 * TickSize, Color.Blue);
              					Alert("VolAlert", NinjaTrader.Cbi.Priority.Low, " Volume Exceeded", @"Alert2.wav", 30, Color.Black, Color.Lime);
              					}
              And Now it Plots the Volume on chart also, but It Still Doesn't do anything when Volume Crosses above AverageVolume. There has to be something I;'m doing wrong. Please help

              Comment


                #8
                Hello Ginx10k,

                I took a look at the code and ran the code on my side and in market replay and in real-time I was able to get alerts and dots drawn. There must be something different between your setup and my setup that we need to isolate to figure out what’s going on.

                To do this please revert back to the code I had posted and add a “Print()” statement before the if statement “if(CrossAbove(VOL(), AverageVolume, 1))” and print out the values of VOL() and AverageVolume so that we can figure out why this if statement is not evaluating true and plotting the dot and alerting you.

                Print(“Historical: “ + Historical + “ Bar Number: “ + CurrentBar + “ VOL(): “ + VOL() + “ AverageVolume: “ + AverageVolume);

                Then compile the script and run again on your side and lets inspect the output in the NinjaScript output which will allow us to figure out what is going on.

                For more information on the debugging process please see the following page: http://www.ninjatrader.com/support/f...ead.php?t=3418

                Also, if you could identify what instrument, timeframe and chart you are using this on, along with the indicator parameters used. Might be easier to take a couple of screenshots of the chart and of the indicator parameters window.

                I look forward to your reply.
                Paul H.NinjaTrader Customer Service

                Comment


                  #9
                  Thanks again for your help. I did as you said, and I do get an alert on RealTime. just None on Market Replay. I'm looking at GBP/USD

                  Here's a Pic: http://screencast.com/t/n31CP0Pdw1

                  I just have to figure out why I can't get it to work on market replay

                  Comment


                    #10
                    Hi ginx10k,

                    Thanks for your post/reply and picture. Glad to hear that it is working realtime.

                    On the Print statement, I left off the currentbar, so you can change VOL() to VOL()[0] to get a more meaningful number which would represent the volume of the current bar.

                    Regarding market replay, can you advise whom is providing your market replay data? Or are you recording it yourself?

                    I look forward to your reply.
                    Paul H.NinjaTrader Customer Service

                    Comment


                      #11
                      Getting it from NinjaTrader it'self. Just going to utilities and Downloading a Day or 2.

                      Comment


                        #12
                        Hello ginx10k,

                        With regards to forex data, if you want to use volume data you will need to record the data yourself as it is not available to us to supply in our forex replay data. You chart shows both historical data from your historical data provider and the market replay which does not contain forex volume.

                        Please let me know if I can be of further assistance.
                        Paul H.NinjaTrader Customer Service

                        Comment


                          #13
                          Understood thanks bud. I might have one more question about this indicator. but If I can't figure it out. I'll post here.

                          thanks again!!

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by junkone, Today, 11:37 AM
                          2 responses
                          12 views
                          0 likes
                          Last Post junkone
                          by junkone
                           
                          Started by frankthearm, Yesterday, 09:08 AM
                          12 responses
                          43 views
                          0 likes
                          Last Post NinjaTrader_Clayton  
                          Started by quantismo, 04-17-2024, 05:13 PM
                          5 responses
                          35 views
                          0 likes
                          Last Post NinjaTrader_Gaby  
                          Started by proptrade13, Today, 11:06 AM
                          1 response
                          7 views
                          0 likes
                          Last Post NinjaTrader_Clayton  
                          Started by love2code2trade, 04-17-2024, 01:45 PM
                          4 responses
                          35 views
                          0 likes
                          Last Post love2code2trade  
                          Working...
                          X