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 Perr0Grande, Today, 08:16 PM
                    0 responses
                    2 views
                    0 likes
                    Last Post Perr0Grande  
                    Started by elderan, Today, 08:03 PM
                    0 responses
                    3 views
                    0 likes
                    Last Post elderan
                    by elderan
                     
                    Started by algospoke, Today, 06:40 PM
                    0 responses
                    10 views
                    0 likes
                    Last Post algospoke  
                    Started by maybeimnotrader, Today, 05:46 PM
                    0 responses
                    9 views
                    0 likes
                    Last Post maybeimnotrader  
                    Started by quantismo, Today, 05:13 PM
                    0 responses
                    7 views
                    0 likes
                    Last Post quantismo  
                    Working...
                    X