• 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

Setting an ExitLongStop

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

    Setting an ExitLongStop

    I have the following setup where I have certain condition that if met I enter a long position and also create a longstop variable at the previous low.

    Then outside of the condition I try to set the ExitLongStop as the Max of LongStop at the time of the fill (which doesn't change) and a moving average (which continues to change each OnBarUpdate).

    It does not seem to be picking up the LongStop variable I have created.
    Do I need to place this somewhere else in the code

    protectedoverridevoid OnBarUpdate()
    {

    // Condition set 1
    If ........

    {

    LongStop = Low[
    1];
    EnterLong(DefaultQuantity,
    "");
    }

    Stop = Math.Max(SMA(Low,
    8)[1],LongStop );
    ExitLongStop(Stop);
    }

    #2
    fiddy, would suggest printing the variables at both points and continued bars to see what exact outcome you get with this approach. If you have the Stop variable outside the entry condition it would continue to update on each bar. Would also suggest to check the entry does not evaluate to true again on continuous bars, so LongStop actually is getting reset to the Low all the time...
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Thanks for the suggestion
      I get the following msg
      **NT** A Sell stop order placed at '13/02/2013 5:00:00 AM' has been ignored since the stop price is greater than or equal to close price of the current bar. This is an invalid order and subsequent orders may also be ignored. Please fix your strategy.

      However When the initial Entry Order is placed the market is above the stop price, it is only during that bar that it goes below what would have been the stop level.

      Is there a way to get both orders placed simulataneously in the code so that I don't get this error.

      Comment


        #4
        fiddy, the order would only be expected to be sent if you have position then registered (otherwise it would be just ignored).

        To send the order on the fill of the entry without waiting for the position update you could submit from the more advanced OnExecution() method for example.

        http://www.ninjatrader.com/support/h...nexecution.htm
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Would the correct results show in backtesting mode if you use this method or will it only work in a live trading environment

          Comment


            #6
            That would generally work in live and backtesting mode. However before taking any strategy live I would suggest a few runs in our Market Replay environment.
            BertrandNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by rudccv, Today, 08:42 PM
            0 responses
            1 view
            0 likes
            Last Post rudccv
            by rudccv
             
            Started by Newtrader101, Today, 03:54 PM
            1 response
            15 views
            0 likes
            Last Post NinjaTrader_ShawnB  
            Started by williamzz, Today, 03:28 PM
            0 responses
            7 views
            0 likes
            Last Post williamzz  
            Started by Robert87, Today, 11:07 AM
            0 responses
            14 views
            0 likes
            Last Post Robert87  
            Started by phta123, Today, 10:24 AM
            0 responses
            17 views
            0 likes
            Last Post phta123
            by phta123
             
            Working...
            X