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

Volume Comparisons

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

    Volume Comparisons

    Hi NT,

    I am trying to do something similar with the VolumeUpDown indicator.

    That is, draw an up arrow when there is an increase in volume from the previous bar.

    I added the following code below OBU in the VolumeUpDown indicator (in MS Notepad, since it is locked).
    Recall, in the VolumeUpDown indicator that Calculate = Calculate.OnBarClose;

    Code:
    //Add your custom indicator logic here.
    if (CurrentBar < 2)
    return;
    
    #region Increase Volume
    if (Volume[0] > Volume[1])
    {
    Draw.ArrowUp(this, "Volume1"+CurrentBar.ToString(), false, 0, Volume[0], Brushes.White);
    }
    #endregion
    It works well on historical data when you Reload NinjaScript F5
    However, if the bar is developing or the bar has just finished, then there are issues.

    - If the volume bar is developing, it actually moves from that volume bar to the developing bar. It then moves back and forth until the bar is complete.
    So I find myself always pressing F5.

    Do you get the same bug, if so why and how can it be fixed?

    Please see two screen shots.

    Thanks Irv
    Attached Files

    #2
    Hi, Thanks for posting. I moved your post to a new topic because the other one was 2 years old. The question is in reference to this post:
    Hello, I've gone through the NT8 @VolumeUpDown.cs Indicator but can't see how to add an alert for specific condition. The specific condition is very simple: Fire an audio alert every time the current Volume Bar value on each tick is Greater or equal to the average volume of the past x number of bars. The Number of bars to


    Is your indicator running OnEachTick? Is the VOL indicator on the Chart running OnEachTick or OnBarClose? It looks like OnBarClose from the screen shot. Visually, you are not seeing the updates from the latest bar until it has closed. Please post the full script if this does not resolve.

    Kind regards,
    -ChrisL
    ​​​​​​​
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_ChrisL View Post
      Hi, Thanks for posting. I moved your post to a new topic because the other one was 2 years old. The question is in reference to this post:
      Hello, I've gone through the NT8 @VolumeUpDown.cs Indicator but can't see how to add an alert for specific condition. The specific condition is very simple: Fire an audio alert every time the current Volume Bar value on each tick is Greater or equal to the average volume of the past x number of bars. The Number of bars to


      Is your indicator running OnEachTick? Is the VOL indicator on the Chart running OnEachTick or OnBarClose? It looks like OnBarClose from the screen shot. Visually, you are not seeing the updates from the latest bar until it has closed. Please post the full script if this does not resolve.

      Kind regards,
      -ChrisL
      ​​​​​​​
      Hi Chris,

      I added my snippet of code to the VolumeUpDown indicator. It has Calculate == BOC.
      VOL has Calculate == OnEachTick

      Please see attached.

      Thanks Irv
      Attached Files

      Comment


        #4
        Hello ij001,

        Please do not modify system indicators. The NinjaScript Editor locks these so that you cannot modify system indicators.

        Make a copy of the system indicator with a new unique name and then modify the copy.

        By using BarsAgo 0 and Calculate .OnBarClose, the drawn object will appear on the most recent fully closed bar, (and not the current building bar), one that bar fully closes.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_ChelseaB View Post
          Hello ij001,

          Please do not modify system indicators. The NinjaScript Editor locks these so that you cannot modify system indicators.

          Make a copy of the system indicator with a new unique name and then modify the copy.

          By using BarsAgo 0 and Calculate .OnBarClose, the drawn object will appear on the most recent fully closed bar, (and not the current building bar), one that bar fully closes.
          Hi ChelseaB,

          Thanks for your suggestion. I made a copy of the VolumeUpDown system indicator and modified the copy.

          Even though my code had Calculate == BOC, I noticed that in the dialog box > "Properties" > "Setup" > "Calculate" = OnEachTick.
          So I changed it to "Calculate" = OnBarClose

          However, it does not always print correctly as mentioned above. There are some bars where it draws on the developing bar.

          I am curious, if you see the bug on your or Chris end?
          If not, I wonder if it is because I have multiple data series on the chart I am using.

          Please see attached.

          Thanks Irv
          Attached Files

          Comment


            #6
            Hello ij001,

            The script you have provided has 'Calculate = Calculate.OnEachTick;' on line 35.

            Is this not the correct script?

            Have you modified the script after posting it on the forums?

            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_ChelseaB View Post
              Hello ij001,

              The script you have provided has 'Calculate = Calculate.OnEachTick;' on line 35.

              Is this not the correct script?

              Have you modified the script after posting it on the forums?
              Hi Chelsea,

              Yes, it is the script I am using.

              Also, yes I noticed on line 36 it said Calculate == OnEachTick
              However, I have it setup as OnBarClose in the dialog box. You can see attached, if you need to.

              Overall, does it matter?

              Thanks for your help.
              Irv
              Attached Files

              Comment


                #8
                Hello Irv,

                Yes, the default is set in State.SetDefaults for what is defaulted in the Indicators window, but the value actually selected in the Indicators window will be what is used.
                If you print the property in State.DataLoaded, you would be able to see what it's actually set to for the script.

                Can we see a video showing that drawing objects are appearing on the currently building bar while Calculate is OnBarClose?

                Techsmith Jing can record short videos if you need some recording software.
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by NinjaTrader_ChelseaB View Post
                  Hello Irv,

                  Yes, the default is set in State.SetDefaults for what is defaulted in the Indicators window, but the value actually selected in the Indicators window will be what is used.
                  If you print the property in State.DataLoaded, you would be able to see what it's actually set to for the script.

                  Can we see a video showing that drawing objects are appearing on the currently building bar while Calculate is OnBarClose?

                  Techsmith Jing can record short videos if you need some recording software.
                  Hi NT,

                  Yes, I appreciate the support.

                  Before I send a video, I would like to narrow down the issue on my end.
                  That is, I am running multiple data series and other indicators as well.

                  How can I troubleshoot and where should I put the "Print" statements to observe the behavior for BOC?

                  Thanks Irv

                  Comment


                    #10
                    Hello Irv,

                    When you are testing and trying to indentify behavior in code, only run one script at a time so that you are not confusing the results.

                    Below is a link to a forum post that shows where to put the prints in the code (above the condition in question), and how to look at the results in the output window.
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      Originally posted by ij001 View Post
                      Hi NT,

                      I am trying to do something similar with the VolumeUpDown indicator.

                      That is, draw an up arrow when there is an increase in volume from the previous bar.

                      I added the following code below OBU in the VolumeUpDown indicator (in MS Notepad, since it is locked).
                      Recall, in the VolumeUpDown indicator that Calculate = Calculate.OnBarClose;

                      Code:
                      //Add your custom indicator logic here.
                      if (CurrentBar < 2)
                      return;
                      
                      #region Increase Volume
                      if (Volume[0] > Volume[1])
                      {
                      Draw.ArrowUp(this, "Volume1"+CurrentBar.ToString(), false, 0, Volume[0], Brushes.White);
                      }
                      #endregion
                      It works well on historical data when you Reload NinjaScript F5
                      However, if the bar is developing or the bar has just finished, then there are issues.

                      - If the volume bar is developing, it actually moves from that volume bar to the developing bar. It then moves back and forth until the bar is complete.
                      So I find myself always pressing F5.

                      Do you get the same bug, if so why and how can it be fixed?

                      Please see two screen shots.

                      Thanks Irv
                      Hello ij001

                      I have something similar so I had a try for the VolumeUpDown Indicator.

                      It works regardless of On Bar Close or On Each Tick.

                      I added line 70:-

                      Code:
                      if (CurrentBar < 1) return;
                      I put your code in at line 88:

                      Code:
                      if (Volume[0] > Volume[1])
                      {
                      
                      Draw.ArrowUp(this, "Volume1"+CurrentBar.ToString(), false, 0, Volume[0]+P1, C5);
                      
                      }

                      I also added colour change (C5) for the arrows and an arrow offset (P1) (lines 50 and 51)
                      and their Properties from line 113.



                      Hope it helps.

                      Attached "VolumeUpDownWithArrows" (NT8)
                      Attached Files
                      Last edited by dj22522; 04-14-2022, 05:55 AM.

                      Comment


                        #12
                        Hi Irv,
                        I trying to do something kind of similar. Did you make your indicator work as you intended?
                        I am also looking at the code dj22522 submitted to this post.

                        Comment


                          #13
                          Originally posted by morrnel View Post
                          Hi Irv,
                          I trying to do something kind of similar. Did you make your indicator work as you intended?
                          I am also looking at the code dj22522 submitted to this post.
                          Hi Morrnel,

                          On my end, it works with one data series.
                          I use more than one data series so the issue is still happening. I have not had the time to trouble shoot.
                          As a work around, I am not using any draw object and BarBrush instead.

                          That is

                          BarBrush = Brushes.White;

                          What are you experiencing on your end?

                          Comment


                            #14
                            I haven't done anything with tick data for well over a year and am reviewing what I can find.
                            What I'm doing is analyzing what is happening at the tick level, both price and volume. And I stumbled upon your work and am intrigued.
                            I intend to feed the tick data into a real time ML/AI module.

                            Once I have something to share and if you have the time, we can take this offline in a zoom session and compare notes. In the mentime, I am looking at the data at 1 sec or 30 ticks.

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by Rapine Heihei, Today, 08:19 PM
                            1 response
                            6 views
                            0 likes
                            Last Post NinjaTrader_Manfred  
                            Started by Rapine Heihei, Today, 08:25 PM
                            0 responses
                            5 views
                            0 likes
                            Last Post Rapine Heihei  
                            Started by f.saeidi, Today, 08:01 PM
                            1 response
                            4 views
                            0 likes
                            Last Post NinjaTrader_Manfred  
                            Started by Rapine Heihei, Today, 07:51 PM
                            0 responses
                            6 views
                            0 likes
                            Last Post Rapine Heihei  
                            Started by frslvr, 04-11-2024, 07:26 AM
                            5 responses
                            98 views
                            1 like
                            Last Post caryc123  
                            Working...
                            X