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

A little transformation

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

    A little transformation

    Hi guys!


    Could you please assist me with adding features to the original indicator.

    We will take an ordinary volume indicator (VOL) as a base. Same window at the bottom chart, but showing only the Top 3 volume during a particular period of time.


    An example:

    1). A volume bar must be painted "red", if it is the highest volume during a chosen period. Each next top volume should have a red volume bar.

    Similarly, every 2nd highest volume bar must be painted "yellow" during the period.

    And finally, every 3rd highest volume must be "green".

    Other bars should be left as they are.

    2). If the current highest volume bar is 3.5 times higher than the previous one, it must be painted not red but black colour.


    Thanks very much for your help.

    Arthur

    #2
    Hello Arthur,

    Thank you for your post.

    Using BarColor we can color different bars based on different conditions, and using MRO we can check for the first, second and third most recent occurrences of the condition.

    For information on BarColor please visit the following link: http://www.ninjatrader.com/support/h...7/barcolor.htm

    For information on MRO please visit the following link: http://www.ninjatrader.com/support/h...urence_mro.htm

    For the comparison you would need to store the first VOL condition value in a variable and check that against the previous variable. You could use two variable or a Data Series to achieve this.

    For information on the DataSeries Class in NinjaTrader please visit the following link: http://www.ninjatrader.com/support/h...ries_class.htm

    Please let me know if I may be of further assistance.

    Comment


      #3
      Hello Patrick!


      I'm fairly new to coding and not able to write it myself unfortunately yet.. But I try to undestand the logic in each particular case in order to be able to do it without someone's help later on. So, I took the original VOL indicator. Here is a part of code:



      protectedoverridevoid Initialize()
      {
      Add(
      new Plot(new Pen(Color.Blue, 2), PlotStyle.Bar, "Volume"));
      Add(
      new Line(Color.DarkGray, 0, "Zero line"));
      Add(
      new Plot(new Pen(Color.Red, 2), PlotStyle.Bar, "The highest Vol"));
      Add(
      new Plot(new Pen(Color.Yellow, 2), PlotStyle.Bar, "2nd highest Vol"));
      Add(
      new Plot(new Pen(Color.Green, 2), PlotStyle.Bar, "3rd highest Vol"));
      Add(
      new Plot(new Pen(Color.Black, 2), PlotStyle.Bar, "The highest x3.5 Vol"));

      I added more lines in "initialize" section, which meet my criteria.

      Next I have to define a particular period of time, when any further conditions will be considered at (like from and to). I've seen this principal in BvzOpening Range indicator, but the code is quite long and I'm not sure how to transfer it from there. Maybe it is just enough to copy/paste a particular part as it is just about the time range? Please find the indicators attached.

      I appreciate your help.


      Many thanks,
      Arthur
      Attached Files

      Comment


        #4
        Hello Arthur,

        Thank you for your response.

        If you are looking for a filter for time you can use the reference sample at the following link: http://www.ninjatrader.com/support/f...ead.php?t=3226

        The reference sample will also provide insight into using DateTime. For information on using DateTime please visit the following link: http://msdn.microsoft.com/en-us/libr....datetime.aspx

        Please let me know if I may be of further assistance.

        Comment


          #5
          Thank you for the references, but I decided to make a session as a period first.

          Could you clarify please, does one of these bold lines make sense in order to find the highest volume?

          protectedoverridevoid Initialize()
          {
          Add(
          new Plot(new Pen(Color.Blue, 2), PlotStyle.Bar, "Volume"));
          Add(
          new Plot(new Pen(Color.Red, 2), PlotStyle.Bar, "TheHighestVol"));

          protectedoverridevoid OnBarUpdate()
          {
          Value.Set(Volume[
          0]);
          TheHighestVol.Set(Volume[0] > GetHigh(Volume,Bars.BarsSinceSession-1)); }

          or

          int TopVol = MRO(delegate {return Volume[0] > GetHigh(Volume,Bars.BarsSinceSession-1);}, 1, Bars.BarsSinceSession-1);

          If the second one is correct, how can I link this int with "TheHighestVol"?


          Many thanks,
          Arthur

          Comment


            #6
            Hello Arthur,

            Thank you for your response.

            You could actually make it as simple as the following by using HighestBar():
            Code:
            TheHighestVol.Set(Volume[HighestBar(Volume, Bars.BarsSinceSession - 1)]);
            For information on HighestBar() please visit the following link: http://www.ninjatrader.com/support/h...highestbar.htm

            Please let me know if I may be of further assistance.

            Comment


              #7
              Hello Patrick,


              Thank you for suggestion.

              Could you explain please why we need a first/bold volume, if we will have it in HighestBar series later and it is already sounds like a full condition for .Set?

              TheHighestVol.Set(Volume[HighestBar(Volume, Bars.BarsSinceSession - 1)]);


              Following this, do I still need a MRO method to find the second highest volume (which is lower than the highest one) in order to complete another .Set condition?


              Many thanks,
              Arthur

              Comment


                #8
                Also, would it be correct to find a 3 times higher volume than the previous highest volume in the example below?

                3xHighestVol.Set((Volume[HighestBar(Volume, Bars.BarsSinceSession - 1)/3]) > (Volume[HighestBar(Volume, Bars.BarsSinceSession - 1)]);


                Thanks for your help.

                Arthur

                Comment


                  #9
                  Hello Arthur,

                  Thank you for your response.

                  The HighestBar() only returns an int representing the bar number of the highest bar, not the actual price or volume data, that is why we use Volume[HighestBar(...)]. For information on HighestBar() please visit the following link: http://www.ninjatrader.com/support/h...highestbar.htm

                  For the second highest volume MRO() would be the correct course of action, but I do not know why you would store that in the same DataSeries as the Volume[HighestBar(Volume, Bars.BarsSinceSession - 1)]. It would make sense however in comparisons to store the MRO() for the second highest volume in a variable and then call that when comparing against the TheHighestVol DataSeries.

                  It would not be possible to find a higher value than the last highest value as this should be updated on each bar update with Volume[HighestBar(Volume, Bars.BarsSinceSession - 1)].

                  Can you expand further on what you are attempting to achieve here and I can provide further information on this matter?

                  Comment


                    #10
                    Patrick-


                    Thanks a lot for explanations.

                    Alright, please find a picture attached. With a help of photoshop I'm able to show exactly what I need.

                    Imagine that session starts at 11:30.

                    Every Red bar is the highest volume and every Yellow is the second highest comparing to all other bars from the session start.

                    That is it basically..

                    Well, I would also like to have a simple function to not to show these Red and Yellow bars during a specific time period. But this is something to do later..


                    Thank you,
                    Arthur
                    Attached Files
                    Last edited by FxInception; 10-21-2013, 12:37 PM.

                    Comment


                      #11
                      So, if Volume[HighestBar(...)] hold a volume figure of previous highest bar, we need to compare it with the current one, isn't it? Do we really need Data Series in this case?

                      Maybe just like:

                      Volume[0] > Volume[HighestBar(Volume, Bars.BarsSinceSession - 1)]

                      And MRO will look like:

                      int TopVol = MRO(delegate {return Volume[0] > Volume[HighestBar(Volume, Bars.BarsSinceSession - 1)] ;}, 1, Bars.BarsSinceSession);
                      if (TopVol > -1)
                      then link it somehow with Add(new Plot(new Pen(Color.Red, 2), PlotStyle.Bar, "TheHighestVol"));

                      Don't know if it makes any sense..


                      Thank you,
                      Arthur
                      Last edited by FxInception; 10-21-2013, 12:57 PM.

                      Comment


                        #12
                        Hello Arthur,

                        Thank you for your patience.

                        In your screenshot I see times that the red bar should be yellow or that yellows should be blues and that blues should be red or yellow. I unfortunately do not fully understand what you are attempting to achieve here.

                        I can help you to work out your idea and I can provide a code snippet that would paint the highest bar of the session for VOL as red and the second bar as yellow, but only one bar would be red and one bar would be yellow - ever.

                        I will need further details on what exactly you wish to accomplish here.

                        Comment


                          #13
                          Patrick-


                          Please check a picture attached.

                          1). Yes, sorry, I missed this one, it should be yellow.

                          2). These are equal, but since the second one is not higher - it is yellow.

                          3). It looks like 2nd highest, but in fact it is a little higher than the previous highest one.

                          I suppose you meant these instances.

                          It is basically like reading a sentence from left to the right and increase two horizontal lines every time we have the new highest or second highest volume and paint those bars accordingly.

                          Sorry, I hope I'm clear enough this time.


                          Regards,
                          Arthur
                          Attached Files

                          Comment


                            #14
                            Hello Arthur,

                            Thank you for your patience.

                            I created a sample script using the VOL indicator to demonstrate how you might do this with for loops and PlotColors. You can find this script attached to this post. We do not provide programming services but I am able to provide this as an example of how to achieve what you are looking for.
                            Attached Files

                            Comment


                              #15
                              Patrick-


                              Thanks a lot for a clue, with a tiny change I've got what I want now in terms of the highest volume.

                              I believe I will achieve my goal completely if you would be able to show me how to express the 2nd highest volume similar to this format, if it's possible:

                              HighestBar(Volume, Bars.BarsSinceSession)

                              Much appreciate your help.


                              Arthur

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by timmbbo, 07-05-2023, 10:21 PM
                              4 responses
                              158 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Started by tkaboris, Today, 08:01 AM
                              1 response
                              7 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Started by Lumbeezl, 01-11-2022, 06:50 PM
                              31 responses
                              818 views
                              1 like
                              Last Post NinjaTrader_Adrian  
                              Started by xiinteractive, 04-09-2024, 08:08 AM
                              5 responses
                              15 views
                              0 likes
                              Last Post NinjaTrader_Erick  
                              Started by swestendorf, Today, 11:14 AM
                              2 responses
                              6 views
                              0 likes
                              Last Post NinjaTrader_Kimberly  
                              Working...
                              X