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

tick size for Initialize()

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

    #16
    Try this one
    SetStopLoss("Long Entry 1", CalculationMode.Ticks, Instrument.MasterInstrument.Round2TickSize(MyDoubl e*TickSize), false);
    SetProfitTarget("Long Entry 1", CalculationMode.Ticks, (2.0*A_big/TickSize));

    Comment


      #17
      Originally posted by koganam View Post
      By separating them.
      Code:
      Value[0][0] < Value[0][1] - TickSize  || Value[0][0] > Value[0][1] + TickSize
      Thanks koganam,

      i tried this very equation,but it seems after that it ignored the other confditions i have.

      Should i bracket this equation?

      Comment


        #18
        Originally posted by olres7 View Post
        Try this one
        SetStopLoss("Long Entry 1", CalculationMode.Ticks, Instrument.MasterInstrument.Round2TickSize(MyDoubl e*TickSize), false);
        SetProfitTarget("Long Entry 1", CalculationMode.Ticks, (2.0*A_big/TickSize));
        Hi,thank you,

        but it`s not about setting stops and profits.It`s about adding some degree of freedom to conditions to take place.

        Comment


          #19
          Originally posted by outsource View Post
          Thanks koganam,

          i tried this very equation,but it seems after that it ignored the other confditions i have.

          Should i bracket this equation?
          Hard to say. You asked a very specific question, and I gave you the specific expression that you would use. Generally, you have to write statements in a program, so the expression itself standing alone would not do much.

          What are you trying to do in this small instance, and I may be able to give you a complete statement, that might be more useful?
          Last edited by koganam; 11-16-2015, 12:17 PM. Reason: Corrected punctuation.

          Comment


            #20
            Hello outsource,

            As koganam stated, if you could provide additional information as to exactly what you are trying to achieve with this particular code, we will be able to provide further guidance. A snippet of your actual code around where you are inserting this may be beneficial to include as well.

            Thank you in advance!
            Michael M.NinjaTrader Quality Assurance

            Comment


              #21
              Originally posted by koganam View Post
              Hard to say.. You asked a very specific question, and I gave you the specific expression that you would use. Generally, you have to write statements in a program, so the expression itself standing alone would not do much.

              What are you trying to do in this small instance, and I may be able to give you a complete statement, that might be more useful?
              I created sort of a channel off the two averages(one of the Low another of the High) ,and want the body of a candle to be inside the channel when other conditions are triggered,OR to be slightly(ticksize) above the Upper average for buying condition or to be inside or slightly(ticksize) below the Lower average for selling conditions.

              Comment


                #22
                Originally posted by NinjaTrader_MichaelM View Post
                Hello outsource,

                As koganam stated, if you could provide additional information as to exactly what you are trying to achieve with this particular code, we will be able to provide further guidance. A snippet of your actual code around where you are inserting this may be beneficial to include as well.

                Thank you in advance!
                Hi,Michael,

                For illustration,you can take Snake eye method as an exampe with its two SMAs one is 8 period for the Low input,and another is 10 period for the High input.Thus create a channel.So now the price should be inside the channel or slightly above(but no more then) 10 SMA of the High or below(but no more then) 8 SMA of the Low

                Comment


                  #23
                  Hello Outsource,

                  As an example here is how that logic is created with TickSize. This is following the pattern set by koganam.

                  Code:
                  if (Close[0] <= SMA(High, 10)[0] + TickSize && Close >= SMA(Low, 8)[0] - TickSize)
                  {
                  	// close is 1 tick outside of the channel or within
                  	// close is less than or equal to sma using high as input with a period of 10
                  	// and close is greater than or equal to the sam using the low as input with period of 8
                  }
                  
                  if (Close[0] > SMA(High, 10)[0] + TickSize || Close < SMA(Low, 8)[0] - TickSize)
                  {
                  	// close is more than 1 tick outside the channel
                  	// close is greater than sma using high as input with period of 10
                  	// OR close is less than sma using low as input with period of 8
                  }
                  If you wanted to increase the number of ticks, you can multiply the ticksize to add ticks.

                  For example:
                  int buffer = 2;
                  Print(SMA(High, 10)[0] + buffer * TickSize);

                  This would print the value of the sma using the high with a period of 10 plus 2 ticks.

                  if buffer was equal to -3 this would subtract 3 ticks.
                  Last edited by NinjaTrader_ChelseaB; 11-17-2015, 03:25 PM.
                  Chelsea B.NinjaTrader Customer Service

                  Comment


                    #24
                    Originally posted by NinjaTrader_ChelseaB View Post
                    Hello Outsource,

                    As an example here is how that logic is created with TickSize. This is following the pattern set by koganam.

                    Code:
                    if (Close[0] <= SMA(High, 10)[0] + TickSize && Close >= SMA(Low, 8)[0] - TickSize)
                    {
                    	// close is 1 tick outside of the channel or within
                    	// close is less than or equal to sma using high as input with a period of 10
                    	// and close is greater than or equal to the sam using the low as input with period of 8
                    }
                    
                    if (Close[0] > SMA(High, 10)[0] + TickSize || Close < SMA(Low, 8)[0] - TickSize)
                    {
                    	// close is more than 1 tick outside the channel
                    	// close is greater than sma using high as input with period of 10
                    	// OR close is less than sma using low as input with period of 8
                    }
                    If you wanted to increase the number of ticks, you can multiply the ticksize to add ticks.

                    For example:
                    int buffer = 2;
                    Print(SMA(High, 10)[0] + buffer * TickSize);

                    This would print the value of the sma using the high with a period of 10 plus 2 ticks.

                    if buffer was equal to -3 this would subtract 3 ticks.
                    Hi Chelsea,

                    thank you for the example.It`s not exactly what i asked.I need the price to be inside the channel OR slightly(ticksize) above the High(10) for buy signal and vice versa for sell.

                    So that

                    if (Close[0] <= SMA(High, 10)[0] && Close >= SMA(Low, 8)[0] ) +/- TickSize

                    Is there a way to accomplish something like this.When i try to imply the "||" statement it doesnt work properly.

                    Comment


                      #25
                      Hello outsource,

                      Without being able to see what you have written I wouldn't be able to comment.

                      However, when you say "It`s not exactly what i asked.I need the price to be inside the channel OR slightly(ticksize) above the High(10) for buy signal and vice versa for sell.", this is a bit confusing.

                      Inside the channel or slightly above.

                      This is telling me that if you add 1 tick to the upper channel price and then the close is at this price or below that this is what you are looking for.
                      This is exactly what I have written from how i understand it.

                      My comment is:
                      // close is 1 tick outside of the channel or within

                      Can you explain how this is incorrect?
                      Chelsea B.NinjaTrader Customer Service

                      Comment


                        #26
                        Originally posted by NinjaTrader_ChelseaB View Post
                        Hello outsource,

                        Without being able to see what you have written I wouldn't be able to comment.

                        However, when you say "It`s not exactly what i asked.I need the price to be inside the channel OR slightly(ticksize) above the High(10) for buy signal and vice versa for sell.", this is a bit confusing.

                        Inside the channel or slightly above.

                        This is telling me that if you add 1 tick to the upper channel price and then the close is at this price or below that this is what you are looking for.
                        This is exactly what I have written from how i understand it.

                        My comment is:
                        // close is 1 tick outside of the channel or within

                        Can you explain how this is incorrect?

                        Would it be different or would it be the same?

                        if (Close[0] <= SMA(High, 10)[0] + TickSize && Close >= SMA(Low, 8)[0] - TickSize)

                        if (Close[0] <= SMA(High, 10)[0] || Close[0] <=SMA(High, 10)[0] + TickSize && Close >= SMA(Low, 8)[0] || Close >=SMA(Low, 8)[0] - TickSize)
                        Last edited by outsource; 11-18-2015, 07:46 PM.

                        Comment


                          #27
                          Hello outsource,

                          No, these would not be the same.

                          if (Close[0] <= SMA(High, 10)[0] + TickSize && Close >= SMA(Low, 8)[0] - TickSize)

                          if the close is equal to or less than the sma high plus one tick and is also equal to or greater than the sma low minus one tick trigger


                          if (Close[0] <= SMA(High, 10)[0] || Close[0] <=SMA(High, 10)[0] + TickSize && Close >= SMA(Low, 8)[0] || Close >=SMA(Low, 8)[0] - TickSize)

                          if the close is less than or equal to the sma high then trigger
                          if the close is less than or equal to the high plus one tick and the close is greater than the sma low then trigger
                          if the close is greater than or equal to the sma low minus one tick then trigger


                          That said, can you respond to my question from post #25?

                          I am not understanding how the example logic i provided is not what you are asking for. Can you clarify this?
                          Last edited by NinjaTrader_ChelseaB; 11-19-2015, 11:42 AM.
                          Chelsea B.NinjaTrader Customer Service

                          Comment


                            #28
                            Originally posted by NinjaTrader_ChelseaB View Post
                            Hello outsource,

                            No, these would not be the same.

                            if (Close[0] <= SMA(High, 10)[0] + TickSize && Close >= SMA(Low, 8)[0] - TickSize)

                            if the close is equal to or less than the sma high plus one tick and is also equal to or greater than the sma low minus one tick trigger


                            if (Close[0] <= SMA(High, 10)[0] || Close[0] <=SMA(High, 10)[0] + TickSize && Close >= SMA(Low, 8)[0] || Close >=SMA(Low, 8)[0] - TickSize)

                            if the close is less than or equal to the sma high then trigger
                            if the close is less than or equal to the high plus one tick and the close is greater than the sma low then trigger
                            if the close is greater than or equal to the sma low minus one tick then trigger


                            That said, can you respond to my question from post #25?

                            I am not understanding how the example logic i provided is not what you are asking for. Can you clarify this?
                            Because i need this logic instead:

                            if (Close[0] <= SMA(High, 10)[0] || Close[0] <=SMA(High, 10)[0] + TickSize && Close >= SMA(Low, 8)[0] || Close >=SMA(Low, 8)[0] - TickSize)

                            Would this equation work in real life?

                            Comment


                              #29
                              Originally posted by outsource View Post
                              Because i need this logic instead:

                              if (Close[0] <= SMA(High, 10)[0] || Close[0] <=SMA(High, 10)[0] + TickSize && Close >= SMA(Low, 8)[0] || Close >=SMA(Low, 8)[0] - TickSize)

                              Would this equation work in real life?
                              Even though that is logical, it is sort of mathematically redundant. If you want to test for a value between 2 other values just test for that.
                              Code:
                              if (Close[0] <= SMA(High, 10)[0] + TickSize && Close >= SMA(Low, 8)[0]  - TickSize){/* ... */}
                              That takes care of both the edge and inner conditions.
                              Last edited by koganam; 11-19-2015, 06:32 PM.

                              Comment


                                #30
                                Originally posted by koganam View Post
                                Even though that is logical it is sort of mathematically redundant. If you want to test for a value between 2 other values just test for that.
                                Code:
                                if (Close[0] <= SMA(High, 10)[0] + TickSize && Close >= SMA(Low, 8)[0]  - TickSize){/* ... */}
                                That takes care of both the edge and inner conditions.
                                So this way it could be inside the channel or TickSize outside the channel,whatever appears,for both - either long or short,correct?

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by PaulMohn, Today, 12:36 PM
                                0 responses
                                2 views
                                0 likes
                                Last Post PaulMohn  
                                Started by love2code2trade, 04-17-2024, 01:45 PM
                                4 responses
                                38 views
                                0 likes
                                Last Post love2code2trade  
                                Started by alifarahani, Today, 09:40 AM
                                2 responses
                                14 views
                                0 likes
                                Last Post alifarahani  
                                Started by junkone, Today, 11:37 AM
                                3 responses
                                20 views
                                0 likes
                                Last Post NinjaTrader_ChelseaB  
                                Started by frankthearm, Yesterday, 09:08 AM
                                12 responses
                                44 views
                                0 likes
                                Last Post NinjaTrader_Clayton  
                                Working...
                                X