Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

2 ticks offset strategy

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

    2 ticks offset strategy

    Hi,
    I don't know C++ and need some help in implementing one strategy.
    I want to enter long 2 ticks below the ask generated by one of the Kwikpop indicators. This indicator = 1, only for the signal bar when it was generated.
    Of course, 2 ticks below the ask could be generated on the current bar, or on the next one, or the following one or never.
    So, it looks like I have to save the ask on the signal bar and then subtract 0.5. I'm not sure I'm doing it correctly.
    That's the excerpt:
    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    double x;

    ///condition set 1 (trying to get the current
    ///ask and save it but how?!)
    if (N [0] == 1)

    {

    x = GetCurrentAsk();
    }
    /// Condition set 2
    /// if the condition of 2 ticks below comes, let's say, only on the second
    /// bar after signal, then N[0] wouldn't be equal 1, but
    ///on the previous bar N[1] was equal 1.

    if (N[0] == 1
    ||
    N[1] == 1

    ||
    N[2] == 1)


    {
    EnterLongLimit(2,double.x-0.5);
    }
    Unfortuanately, there are compilations errors.
    I'd appreciate your reply.
    Alex. [email protected]


    #2
    Sorry, due to bandwidth reasons we are unable to provide support down to the level of coding or reviewing actual strategies/indicators. You might want to consider contacting a NinjaScript consultant: http://www.ninjatrader.com/webnew/pa...injaScript.htm

    Comment


      #3
      re: 2ticks offset strategy

      Hi Dierk,
      Thank you for your reply.

      I'm just trying to fix an error which is generated through Strategy Wizard.
      Try to take any strategy and go Long or Short with + or - offset through a Wizard. It seems to be straightforward but, unfortunately, the results are totally unpredictable and haphazard.
      I'd appreciate your reply.
      Alex.

      Comment


        #4
        >> the results are totally unpredictable and haphazar
        Please be specific. Can you provide a scenario on how to reproduce the problems you experience? Thanks

        Comment


          #5
          2 ticks offset strategy

          I'm using one of the Kwikpop indicators for NT which is NTKPPowerPops which is equal 1 for 'go long' signal bar and -1 on short signal bar. Everywhere else it's equal 0. So when I try to enter long 2 ticks below, these 2 ticks below may occur on a second bar after signal but there JPKPpowerpops is not equal 1 already, and buy signal isn't generated. When these 2 ticks below occur on the same bar where signal is generated then my coding seems to work but it happens not so often. When you try to do it through a strategy wizard it gives a buy signal 20-30 ticks away from the price.

          Comment


            #6
            From a programming standpoint,

            If you have something like:

            Low[0] - (2 * TickSize)

            You will get an offset of 2 ticks off of the low of a bar. If you are getting values that you are not expecting, I would add some Print() debug statements in your code to try to determine what is happening.
            RayNinjaTrader Customer Service

            Comment


              #7
              When a signal occurs it may not be the low of the bar ( I assumed that it's a Current Ask), so it looks like i have to save the price when a signal occurs. I did like this:

              'double x' and then, 'if NTKPPOWERPOPS[0] = 1, x = GetCurrentAsk()';(see coding below),

              but compiler doesn't take it, with strange 2 messages: you might need declare a classs, etc., and end of file needed.

              Comment


                #8
                - double clicking on the error will get you to the erroneous code
                - "end of file" errors usually are related to incorrect brackets (like '{}' or '()') .

                Comment


                  #9
                  2offset strategy

                  how to code in C++:
                  If N[0] = 1, 'save current ask'

                  Comment


                    #10
                    As pointed out below, unfortunately we are unable to provide support down to the level of coding or reviewing actual strategies/indicators. You might want to consider contacting a NinjaScript consultant: http://www.ninjatrader.com/webnew/pa...injaScript.htm

                    Thanks for your understanding.

                    Comment


                      #11
                      I did a quick google search for C# primers and found this:


                      May be it is of help...

                      Comment


                        #12
                        EnterLong delayed

                        Hi Dierk,
                        reading this thread, I have had an issue similar to Alex, inasmuch as an EnterLong instruction is not implemented immediately by NT.

                        It can be delayed one or even two bars after the command is issued by my strategy.
                        As Alex says, the result is umpredictable.

                        Why is the command not immediately submitted by NT, in the same bar as it is generated ?

                        thanks for your assistance,
                        Peter.

                        Comment


                          #13
                          Sorry I don't know. EnterLong should place an order right after bar close. It could be something related to multiple entries in the same direction. Please check out TraceOrders in order to understand what your strategy does: http://www.ninjatrader-support.com/H...aceOrders.html

                          Comment


                            #14
                            Thanks for the reply.
                            Interesting that NT waits till bar close before placing the order.

                            Even with CalculateOnBarClose = false ?

                            why's that?

                            Peter

                            Comment


                              #15
                              Order are placed right away if CalculateOnBar=false is set. I suggest trying with e.g. the SampleMACrossOver strategy.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by jordanq2, Today, 03:10 PM
                              0 responses
                              0 views
                              0 likes
                              Last Post jordanq2  
                              Started by traderqz, Today, 12:06 AM
                              10 responses
                              18 views
                              0 likes
                              Last Post traderqz  
                              Started by algospoke, 04-17-2024, 06:40 PM
                              5 responses
                              46 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Started by arvidvanstaey, Today, 02:19 PM
                              1 response
                              6 views
                              0 likes
                              Last Post NinjaTrader_Zachary  
                              Started by mmckinnm, Today, 01:34 PM
                              3 responses
                              5 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Working...
                              X