• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

tick size for Initialize()

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

    tick size for Initialize()

    Hello! What should I use to return ticket size of instrument (futures), that could be used in Initialize().
    Example:
    SetStopLoss("Long Entry 1", CalculationMode.Ticks, MyDouble*TickSize, false);

    MyDouble=0.0123. It should be in ticks for Stop target, =123.

    Unfortunately TickSize doesn't work in Initialize().

    #2
    I have no idea if this will work, but maybe try using TickSize in OnStartUp()?

    Comment


      #3
      To all,

      Yes, TickSize should not be used in Initialize(). Unfortunately there aren't any supported work arounds available, but someone may have a solution here.
      Adam P.NinjaTrader Customer Service

      Comment


        #4
        Originally posted by Radical View Post
        I have no idea if this will work, but maybe try using TickSize in OnStartUp()?
        Please write here how I can do it? These two versions don't work, because I don't know how to assign TickSize to ts ---> ts = TickSize

        protected override void OnStartUp()
        {
        private object ts = TickSize;
        }

        protected override void OnStartUp()
        {
        ts = TickSize;
        }

        Comment


          #5
          rat-tat! rat-tat! rat-tat! Please don't leave me alone

          Comment


            #6
            Try 'double ts = TickSize;' in OnStartUp()

            Comment


              #7
              before "protected override void Initialize()" I inserted
              "protected override void OnStartUp()
              {
              double ts = TickSize;
              }
              But error "The name `ts` does not exist in the current context"
              Where should I declair `ts`? In "#region Properties"? as private double or just as double?

              Comment


                #8
                alexstox,

                Where are you using the variable ts? I suspect you would need to declare :

                private double ts;

                in the "variables" section to make it accessible by the other methods.

                A variable declared within a method like OnStartup() or OnBarUpdate() will only be accessible in OnStartup() or OnBarUpdate() respectively the way you are declaring it.

                Please let me know if I may assist further.
                Adam P.NinjaTrader Customer Service

                Comment


                  #9
                  public class LWMP : Strategy
                  {
                  #region Variables
                  private double TS = TickSize;
                  #endregion

                  error: An object reference is required for the non-static field, method, or property `NinjaTrader.Strategy.StrategyBase.TickSize.Get`


                  P.S. The problem is I can't get TickSize in Initialize(), but there are conditions that use it.
                  For example:
                  protected override void Initialize()
                  {
                  SetProfitTarget("Long Entry 1", CalculationMode.Ticks, 2*A_big/TS);
                  Last edited by alexstox; 04-18-2012, 08:11 AM.

                  Comment


                    #10
                    alexstox,

                    This is the issue : private double TS = TickSize;

                    Here :

                    Code:
                    public class LWMP : Strategy
                    {
                    #region Variables
                    private double TS = TickSize; 
                    #endregion
                    
                    //other code and methods
                    
                    }
                    The TickSize variable is only accessible in the OnBarUpdate() method, though some people seem to get it to work in OnStartup() which is unsupported currently.

                    Basically, you need to declare your variable :

                    Code:
                    public class LWMP : Strategy
                    {
                    #region Variables
                    private double TS; 
                    #endregion
                    
                    // other code and methods
                    
                    }
                    Then assign it in another method like :

                    Code:
                    private override void OnBarUpdate()
                    {
                    
                    TS = TickSize;
                    
                    //other code
                    
                    }
                    Please let me know if I may assist further.
                    Last edited by NinjaTrader_AdamP; 04-18-2012, 08:13 AM.
                    Adam P.NinjaTrader Customer Service

                    Comment


                      #11
                      The problem is I can't get TickSize in Initialize(), but there are conditions that use it.
                      For example:
                      protected override void Initialize()
                      {
                      SetProfitTarget("Long Entry 1", CalculationMode.Ticks, 2*A_big/TS);

                      When I do like you wrote - Backtest work bad, incorrect. When I just use 0.0001 instead of TS - everything is OK. So, what can you advise? How can I use TickSize in Profit and Stop targets? I need it to be divide by TickSize to get {2*0.0112/0.0001=224} ticks for targets.

                      Comment


                        #12
                        alexstox,

                        Unfortunately TickSize is not accessible in the Initialize() method.

                        http://www.ninjatrader.com/support/h...l?ticksize.htm

                        Please keep in mind you can also specify a stop loss in the OnBarUpdate() method, where TickSize would be accessible, and it will apply this stop loss to your orders.

                        http://www.ninjatrader.com/support/f...ead.php?t=3222

                        Please let me know if I may assist further.
                        Adam P.NinjaTrader Customer Service

                        Comment


                          #13
                          A bit off top...

                          But,how to achieve -/+ ticksize within the same condition?

                          So for Value[0][0] > Value[0][1] +/- ticksize

                          So,it would be true n ticks above OR n ticks below

                          Thanks to All

                          Comment


                            #14
                            Originally posted by outsource View Post
                            A bit off top...

                            But,how to achieve -/+ ticksize within the same condition?

                            So for Value[0][0] > Value[0][1] +/- ticksize

                            So,it would be true n ticks above OR n ticks below

                            Thanks to All
                            Don't do it in initialize??

                            Comment


                              #15
                              Originally posted by outsource View Post
                              A bit off top...

                              But,how to achieve -/+ ticksize within the same condition?

                              So for Value[0][0] > Value[0][1] +/- ticksize

                              So,it would be true n ticks above OR n ticks below

                              Thanks to All
                              By separating them.
                              Code:
                              Value[0][0] < Value[0][1] - TickSize  || Value[0][0] > Value[0][1] + TickSize

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by bomanpbm, Yesterday, 09:27 PM
                              0 responses
                              2 views
                              0 likes
                              Last Post bomanpbm  
                              Started by tgn55, Yesterday, 08:47 AM
                              0 responses
                              8 views
                              0 likes
                              Last Post tgn55
                              by tgn55
                               
                              Started by ballboy11, 05-04-2019, 10:26 AM
                              6 responses
                              58 views
                              0 likes
                              Last Post Kermit
                              by Kermit
                               
                              Started by mrlucky1x, 06-14-2019, 10:01 PM
                              0 responses
                              15 views
                              0 likes
                              Last Post mrlucky1x  
                              Started by roger556, 06-14-2019, 09:22 PM
                              0 responses
                              8 views
                              0 likes
                              Last Post roger556  
                              Working...
                              X