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

Price value in the alert message

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

    Price value in the alert message

    Hi Support,

    How do i achieve a little deviation in the price value message.The formula for the closing price alert is this(i could be wrong):

    Math.Round( Close[0]

    So i get the message in wich it`s said i should sell at 1,2345.So,how do i get the price a percent higher?So if the real price is 1,2345,then i want the value of 1,246845 in the message.Is there a way to do that?

    Thanks

    #2
    Originally posted by cachevery View Post
    Hi Support,

    How do i achieve a little deviation in the price value message.The formula for the closing price alert is this(i could be wrong):

    Math.Round( Close[0]

    So i get the message in wich it`s said i should sell at 1,2345.So,how do i get the price a percent higher?So if the real price is 1,2345,then i want the value of 1,246845 in the message.Is there a way to do that?

    Thanks
    The poorly named: Round2TickSize

    Comment


      #3
      Originally posted by cachevery View Post
      Hi Support,

      How do i achieve a little deviation in the price value message.The formula for the closing price alert is this(i could be wrong):

      Math.Round( Close[0]

      So i get the message in wich it`s said i should sell at 1,2345.So,how do i get the price a percent higher?So if the real price is 1,2345,then i want the value of 1,246845 in the message.Is there a way to do that?

      Thanks
      ? So simply multiply the price by the necessary percentage? No?

      Comment


        #4
        Originally posted by koganam View Post
        ? So simply multiply the price by the necessary percentage? No?

        By using a calculator?Yes,you can.But if you place 80-100 limit orders per day,it`d be quiet intensive.

        So no easy way do it in the code?

        Comment


          #5
          Hello cachevery,

          Thank you for your post.

          I believe I understand what you are asking for here, please see below:
          Code:
                  #region Variables		
          		private int percent = 10;
                  #endregion
          
          		
                  protected override void Initialize()
                  {
          			
                  }
          		
          		protected override void OnBarUpdate()
          		{	
          			double limitValue = Instrument.MasterInstrument.Round2TickSize((percent * Close[0])/100);
          			// Then add or subtract from Close[0] for order price.
          		}
          There should be no issue in calculating this multiple times for different orders.

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

          Comment


            #6
            Originally posted by NinjaTrader_PatrickH View Post
            Hello cachevery,

            Thank you for your post.

            I believe I understand what you are asking for here, please see below:
            Code:
                    #region Variables		
            		private int percent = 10;
                    #endregion
            
            		
                    protected override void Initialize()
                    {
            			
                    }
            		
            		protected override void OnBarUpdate()
            		{	
            			double limitValue = Instrument.MasterInstrument.Round2TickSize((percent * Close[0])/100);
            			// Then add or subtract from Close[0] for order price.
            		}
            There should be no issue in calculating this multiple times for different orders.

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

            where should i place it in the code.When i try i get errors

            Comment


              #7
              Patrick,it`s a bit complex code,so the price value is calculated in this line:

              int lastY = ChartControl.GetYByValue( Bars, Close[0] );
              double percentage = 100.0 - ( ( lastY * 100.0 ) / bounds.Height );

              When i try to add your snippet,i thin it mixes things up and i get error.

              Any ideas?

              Comment


                #8
                Hello cachevery,

                Thank you for your response.

                Can you provide the full code used or the .cs file for this indicator or strategy?

                Comment


                  #9
                  Originally posted by NinjaTrader_PatrickH View Post
                  Hello cachevery,

                  Thank you for your response.

                  Can you provide the full code used or the .cs file for this indicator or strategy?
                  No,it`s too expensive.

                  Comment


                    #10
                    Hlelo cachevery,

                    Thank you for your response.

                    You do not copy and paste the code I provide here, you need to implement the calculation into your own calculations. So my calculation used a double for the example:
                    double limitValue = Instrument.MasterInstrument.Round2TickSize((percen t * Close[0])/100);
                    I honestly would just store the value in a double, then use the double for the price of your order subtracted or added to the Close[0]. What are you attempting here with the y value? Are you actually placing Drawing Objects? Why not just use a double for the y value as I have and just provide this for the y value of the Drawing Object?

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by sambathraj, Today, 07:46 PM
                    0 responses
                    4 views
                    0 likes
                    Last Post sambathraj  
                    Started by topa11, Today, 12:52 PM
                    2 responses
                    32 views
                    0 likes
                    Last Post topa11
                    by topa11
                     
                    Started by torento, Yesterday, 05:43 PM
                    4 responses
                    83 views
                    0 likes
                    Last Post torento
                    by torento
                     
                    Started by sprks7979, Today, 05:59 PM
                    0 responses
                    26 views
                    0 likes
                    Last Post sprks7979  
                    Started by intelligenttrader, 09-11-2022, 06:02 PM
                    8 responses
                    230 views
                    0 likes
                    Last Post Lance El Camino  
                    Working...
                    X