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

Entering 6J decimal places

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

    Entering 6J decimal places

    Scenario:

    Trying to enter a price for 6j (Japanese yen). If I go more than 4 decimals it goes to 1E-05. How can I enter a parameter value of more than 4 decimals. They are currently defined as double.

    Cheers

    #2
    Hello ct, and thank you for your question.

    I am unsure what is meant by entering a price for the 6J. Is this a historical data file you are editing by hand? If not, could you provide a simple code sample where you demonstrate what you observed?

    I look forward to assisting further.
    Jessica P.NinjaTrader Customer Service

    Comment


      #3
      Jessica

      I am entering a price that if hit will cause an alert. So for example if I enter "0.0089020" an alert will be sent if this price is hit. This way I don't have to watch my charts every second but if a key price is reached I want to know.

      Does this help?

      In reality this is price tolerance that if price get within this amount to a fib line projection it will sound the alert.. So I might enter "0.000020" so if price gets within "0.000020" of the fib line the alert is sent. I want a warning prior to the price point being hit not when it hits.

      Clear as mud?

      Cheers
      Last edited by ct; 11-23-2016, 12:44 PM.

      Comment


        #4
        This does help quite a bit, but the answer to this question will still depend heavily on the NinjaScript source code. I recommend reviewing with the developer who will have access to your NinjaScript code, and inviting them to participate in this thread.

        If you are the developer, would it be possible to provide a stripped down copy of your source code? This will make it easier to assist further.
        Jessica P.NinjaTrader Customer Service

        Comment


          #5
          Jessica

          Yes I am the developer.

          Here is the minimum I think you need. I declare the value the parameter is received into "bollingerProximity" with a default of 1 (TickSize) which works on most futures.
          as a double.

          private double bollingerProximity = 1;


          // here is the actual code I use to receive the user entered value
          // when I try to enter more than 4 decimals it displays the number incorrectly when i press "Apply"
          [Description("Bollinger Proximity")]
          [Category("Parameters")]
          public double BollingerProximitry
          {
          get { return bollingerProximity; }
          set { bollingerProximity = Math.Max(0, value);}
          }

          From there the value is used in calculations. In this code snippet I am checking to see if it has exceeded the tolerance (gotten close enough) for an alert. I also draw an ellipse at the point if was exceeded on the chart.

          if (BollingerProximitry > Proximitry)
          {
          string prox = string.Format("{0:N2}", Proximitry).Replace(",","");
          string Ellipse = Instrument.FullName + "_Above";
          DrawEllipse(Ellipse, true, 5, (All + (5 * TickSize)), -5, (All - (5 * TickSize)), Color.Green, bollingerProximitryColor, 2);
          Alert(Ellipse, NinjaTrader.Cbi.Priority.High, "1 Day Above Bollinger Alert reached at distance " + prox, "BollingerAlert.wav", alertReArmSeconds, bollingerProximitryColor, Color.Green);
          }

          Let me know if you need more.

          Cheers
          Last edited by ct; 11-23-2016, 03:31 PM.

          Comment


            #6
            Thank you for this additional information. If you would like to not have commas in your display, and you would like to have an unlimited number of digits after the decimal point (to the maximum complexity allowed a double type object), you may use

            string prox = string.Format("{0:G}", Proximitry);
            I used this publicly available MSDN documentation page as a reference.

            Learn how to convert instances of .NET types to formatted strings. Override the ToString method, make formatting culture-sensitive, and use ICustomFormatter.
            Jessica P.NinjaTrader Customer Service

            Comment


              #7
              Hi CT,

              I had similar issues with 6J.

              Hope the attached helps.

              S.
              Attached Files

              Comment


                #8
                Jessica

                To keep things simple and possibly more robust I may just change my logic a bit. Instead of specifying an exact number, I can enter a percentage of a TickSize. So .5 would be half a tick and 2 would be 2 ticks. Another advantage is this can be the same value across multiple instruments and then self adapt to the precision of that market. So going from Crude Oil (TickSize 10) to Japanese Yen (TickSize .0000005) would (in theory) require no change.

                In essence the number entered would be in relation to the markets Tick Size and not actual price. Which is where TickSize came from to begin with.

                Jessica, any thoughts or comment on this approach?

                Cheers
                Last edited by ct; 11-29-2016, 09:50 AM.

                Comment


                  #9
                  This approach could definitely work. If you would like to not have to specify this percentage value yourself, and would like your code to figure it out, I would like to recommend using Math.Log. I go into more details as far as how to do so here.



                  Specifying values does have the advantage over the Math.Log approach in terms of being easier to understand and being less effort to code and test. Math.Log, on the other hand, would make things easier for you as a user.

                  Whichever path you choose we are happy to answer any related questions we may.
                  Jessica P.NinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Kaledus, Today, 01:29 PM
                  0 responses
                  3 views
                  0 likes
                  Last Post Kaledus
                  by Kaledus
                   
                  Started by PaulMohn, Today, 12:36 PM
                  1 response
                  16 views
                  0 likes
                  Last Post NinjaTrader_Gaby  
                  Started by yertle, Yesterday, 08:38 AM
                  8 responses
                  37 views
                  0 likes
                  Last Post ryjoga
                  by ryjoga
                   
                  Started by rdtdale, Today, 01:02 PM
                  1 response
                  6 views
                  0 likes
                  Last Post NinjaTrader_LuisH  
                  Started by alifarahani, Today, 09:40 AM
                  3 responses
                  19 views
                  0 likes
                  Last Post NinjaTrader_Jesse  
                  Working...
                  X