Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Problem with a simple strategy

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

    Problem with a simple strategy

    I have been struggling with this problem for a couple of days, I simply want to execute a sell order when a price rises above the level of a upper bolinger band.
    GetCurrentBid()>=Bollinger(2,14).Upper[0]
    Every time I run this strategy, an average price some 8 points below the market appears and an unrealised dollar amount comes up.
    No orders or execution have been logged.
    Thinking NT could be corrupted I have uninstalled and reinstalled NT, but have exactly the same problem, could you advise.

    Thanks

    By the way there seems to be no problem when I backtest.

    #2
    Not sure I follow. You would have to debug to see if the condition you have evaluates to true and print out some statements to verify this etc...
    RayNinjaTrader Customer Service

    Comment


      #3
      I'm sorry I'm very new to NT and I'm not sure how to debug..... however, I have pinpointed the problem with the script below, the strategy is the line printed below, and it constantly throws up an average price, and an unrealised dollar amount from the price, yet there is no record of any orders or trades...

      Comment


        #4
        BTW this is the code i've entered, also another point, it seems to come up with the same average price every time i initiate this strategy...


        publicclass Test2 : Strategy
        {
        #region Variables
        // Wizard generated variables
        privateint myInput0 = 1; // Default setting for MyInput0
        // User defined variables (add any user defined variables below)
        #endregion

        ///<summary>
        /// This method is used to configure the strategy and is called once before any strategy method is called.
        ///</summary>
        protectedoverridevoid Initialize()
        {
        Add(Bollinger(1.2, 16));

        CalculateOnBarClose = false;
        }

        ///<summary>
        /// Called on each bar update event (incoming tick)
        ///</summary>
        protectedoverridevoid OnBarUpdate()
        {
        // Condition set 1
        if (GetCurrentBid() >= Bollinger(1.2, 16).Upper[0])
        {
        EnterShort(1, "");
        }

        // Condition set 2
        if (GetCurrentAsk() <= Bollinger(1.2, 16).Middle[0])
        {
        ExitShort("", "");
        Last edited by John833; 06-30-2008, 11:23 AM.

        Comment


          #5
          yes I have already done this 4 times, and i have also done a complete unistallation and reinstallation twice...

          I would not be asking for help unless I have exhausted all other options...

          Comment


            #6
            Hello John,

            Could you please use the following if statement:

            if (Close[0] > Bollinger(1.2, 16).Upper[0])

            Check if this will solve the issue.
            JasonNinjaTrader Customer Service

            Comment


              #7
              Thanks Jason, unfortunately the same thing happens.

              Comment


                #8
                To clarify...

                When you run a strategy in real-time, there may be a historical position calculcated. Likely this is your situation.

                You can read more here on this - http://www.ninjatrader-support.com/v...ead.php?t=4033

                Else, you can add the following code to your strategy for real-time operation,

                if (Historical) return;

                at the beginning of the OnBarUpdate() method.
                RayNinjaTrader Customer Service

                Comment


                  #9
                  I have the chart already up, no it doesn't show any executed orders and I don't have any other stategies running...

                  its strange as it works when i backtest...

                  Comment


                    #10
                    Thanks Ray, that seems to make sense, as I am a complete newbie could you explain how I would put that code in my script please...

                    Comment


                      #11
                      Are you using the strategy wizard? If yes, this can't be done. Unfortunately we can not provide assistance to the level of basic programming.
                      RayNinjaTrader Customer Service

                      Comment


                        #12
                        Thanks Ray, do you think you could point me in the right direction...

                        would the code look somethink like...

                        If (Historical) return;
                        protectedoverridevoid OnBarUpdate()
                        or
                        If (Historical) return; OnBarUpdate()


                        thanks.....

                        Comment


                          #13
                          Hi John,

                          Please enter the if statement as follows:

                          protected override void OnBarUpdate()
                          {
                          if (Historical) return;
                          JasonNinjaTrader Customer Service

                          Comment


                            #14
                            Jason / Ray thanks very much for your help. Everything seem to be working....!!!!

                            Cheers!

                            John

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by GussJ, 03-04-2020, 03:11 PM
                            16 responses
                            3,279 views
                            0 likes
                            Last Post Leafcutter  
                            Started by WHICKED, Today, 12:45 PM
                            2 responses
                            19 views
                            0 likes
                            Last Post WHICKED
                            by WHICKED
                             
                            Started by Tim-c, Today, 02:10 PM
                            1 response
                            8 views
                            0 likes
                            Last Post NinjaTrader_ChelseaB  
                            Started by Taddypole, Today, 02:47 PM
                            0 responses
                            5 views
                            0 likes
                            Last Post Taddypole  
                            Started by chbruno, 04-24-2024, 04:10 PM
                            4 responses
                            51 views
                            0 likes
                            Last Post chbruno
                            by chbruno
                             
                            Working...
                            X