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

SuperDom highest volume price

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

    SuperDom highest volume price

    Hello,

    I am getting trouble passing the Volume highest price from SuperDom Volume.

    I want to get the highest price level of the volume regardless of the "autocenter option".

    For now, the highest price is base on the window price level as it is automatically scaled in the autocenter.

    hp = 0;
    lp = double.MaxValue;
    lock (SuperDom.Rows)
    foreach (PriceRow row in SuperDom.Rows)
    {
    hp = Math.Max(hp, row.Price);
    lp = Math.Min(lp, row.Price);
    }

    sometimes it returns a different price.

    it must not be executed on this method, but is there any way I can achieve this?

    Also, I want to pass the value to strategy,

    somewhat like:

    if(Superdom.Volume().Highestprice)

    Print(""+Superdom.Volume().Highestprice);

    Any workaround, please.


    Thanks

    #2
    Hello Danville.Sumobay,

    Thank you for the post.

    What you have shown would be the way to loop over the rows and find a min/max. Can you provide more detail on what problem you are seeing when using that? You said it returns a different price, do you have an example of what price is returned in contrast to the prices in the Rows?

    it must not be executed on this method, but is there any way I can achieve this?
    I am not sure I understand what you are saying here.

    Also, I want to pass the value to strategy,
    A strategy would not be able to have the SuperDom specific code passed to it, what you have displayed is for use in a superdom column. You would need to use the Level 2 data if you wanted to access rows of price data from a strategy.


    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Thank you for your response, Jesse,

      I tried printing the values on the indicator from Samplelevel2Book but no luck in getting what I need.

      I need to get the highest price of the volume.

      Please see the yellow on the attached image.


      Thanks
      Attached Files

      Comment


        #4
        Hello Danville.Sumobay,

        Thank you for the post.

        Can you provide more detail on what problem you are seeing when using the loop you provided? You said it returns a different price, do you have an example of what price is returned in contrast to the prices in the Rows?

        From what I can see you are only checking the Prices in that loop, if you are trying to include the row volume in some way then you would need a condition to check the volume as well.


        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Hello Jesse,

          Because I would not be able to pass the SuperDom to strategy. I made a copy of Volume Superdom and add the bolded text below.

          I am trying to capture the highest price in foreach loops and passed the values thru the registry. sometimes it is the correct high and sometimes not


          private void CreateEntry()
          {
          Microsoft.Win32.RegistryKey createhp = Microsoft.Win32.Registry.CurrentUser.CreateSubKey( @"SOFTWARE\t4r1z7x1createhpandlp");
          createhp.SetValue("ise6p1i3r8x9hp", hp.ToString());
          createhp.Close();

          Microsoft.Win32.RegistryKey createlp = Microsoft.Win32.Registry.CurrentUser.CreateSubKey( @"SOFTWARE\t4r1z7x1createhpandlp");
          createlp.SetValue("ise6p1i3r8x9lp", lp.ToString());
          createlp.Close();

          //Print(""+hp);
          }

          double hp = 0;
          double lp = double.MaxValue;


          protected override void OnRender(DrawingContext dc, double renderWidth)
          {
          // This may be true if the UI for a column hasn't been loaded yet (e.g., restoring multiple tabs from workspace won't load each tab until it's clicked by the user)
          if (gridPen == null)
          {
          if (UiWrapper != null && PresentationSource.FromVisual(UiWrapper) != null)
          {
          Matrix m = PresentationSource.FromVisual(UiWrapper).Compositi onTarget.TransformToDevice;
          double dpiFactor = 1 / m.M11;
          gridPen = new Pen(Application.Current.TryFindResource("BorderThi nBrush") as Brush, 1 * dpiFactor);
          halfPenWidth = gridPen.Thickness * 0.5;
          }
          }

          if (fontFamily != SuperDom.Font.Family
          || (SuperDom.Font.Italic && fontStyle != FontStyles.Italic)
          || (!SuperDom.Font.Italic && fontStyle == FontStyles.Italic)
          || (SuperDom.Font.Bold && fontWeight != FontWeights.Bold)
          || (!SuperDom.Font.Bold && fontWeight == FontWeights.Bold))
          {
          // Only update this if something has changed
          fontFamily = SuperDom.Font.Family;
          fontStyle = SuperDom.Font.Italic ? FontStyles.Italic : FontStyles.Normal;
          fontWeight = SuperDom.Font.Bold ? FontWeights.Bold : FontWeights.Normal;
          typeFace = new Typeface(fontFamily, fontStyle, fontWeight, FontStretches.Normal);
          heightUpdateNeeded = true;
          }

          double verticalOffset = -gridPen.Thickness;

          hp = 0;
          lp = double.MaxValue;
          lock (SuperDom.Rows)
          foreach (PriceRow row in SuperDom.Rows)
          {

          hp = Math.Max(hp, row.Price);
          lp = Math.Min(lp, row.Price);

          CreateEntry();

          ...



          Thanks

          Comment


            #6
            Hello Danville.Sumobay,

            This is Jim responding on behalf of Jesse who is out of the office at this time.

            NinjaScripts are designed to be self contained so the supported way to accomplish this would be to use OnMarketDepth to read the level 2 data from the strategy. We could not help with using Windows registry to get scripts to communicate and we would not recommend it.

            Could you elaborate on what you mean by seeing different values? Keep in mind ,The SuperDOM and a chart have different refresh intervals.

            Modifying the SampleLevel2Book indicator so it always prints with new ticks, I am seeing results that I would expect. (I have also modified the loop so the Level 2 book prints from highest price to lowest price.)

            Code:
             protected override void OnBarUpdate()
            {
                //When the Close price crosses over the SMA, print the L2 books.
                //if (CrossAbove(Close, SMA(5), 1))
                {
                    ClearOutputWindow();
                    // Prints the L2 Ask Book we created. Cycles through the whole List and prints the contained objects.
                    Print("Ask Book");
                    for (int idx = askRows.Count-1; idx >= 0; idx--)
                        Print("Ask Price=" + askRows[idx].Price + " Volume=" + askRows[idx].Volume + " Position=" + idx);
            
                    // Prints the L2 Bid Book we created. Cycles through the whole List and prints the contained objects.
                    Print("Bid Book");
                    for (int idx = 0; idx < bidRows.Count; idx++)
                        Print("Bid Price=" + bidRows[idx].Price + " Volume=" + bidRows[idx].Volume + " Position=" + idx);
                }
            }
            JimNinjaTrader Customer Service

            Comment


              #7
              Hello Jim,

              I tested the modified script, but it does not work.

              Please see the image on post #3, I am trying to get the highest price of Volume, not the Bid or Ask price.


              Thanks

              Comment


                #8
                Hello Danville.Sumobay,

                From a Strategy there is no concept like you have shown in the superdom column code, that can be discarded as that won't be able to be used in a strategy.

                To get the rows of data you would need to use the SampleLevel2 as I provided in post #2.

                What Jim described in the last message would be how to order the ask/bid data (which is what is available) in highest to lowest.

                If you needed the volume from one of those rows you would need to use bidRows[idx].Volume as one example.

                Also as noted the superdom has a set refresh rate which your script will likely exceed, so that will create differences if you are viewing the superdom against your code output. You would need to only use prints to observe the data your strategy uses and just close the superdom, that won't be helpful in making comparisons against what you coded in your strategy.

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

                JesseNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by andrewtrades, Today, 04:57 PM
                1 response
                5 views
                0 likes
                Last Post NinjaTrader_Manfred  
                Started by chbruno, Today, 04:10 PM
                0 responses
                3 views
                0 likes
                Last Post chbruno
                by chbruno
                 
                Started by josh18955, 03-25-2023, 11:16 AM
                6 responses
                436 views
                0 likes
                Last Post Delerium  
                Started by FAQtrader, Today, 03:35 PM
                0 responses
                6 views
                0 likes
                Last Post FAQtrader  
                Started by rocketman7, Today, 09:41 AM
                5 responses
                19 views
                0 likes
                Last Post NinjaTrader_Jesse  
                Working...
                X