Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Entering on one condition Exiting on another

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

    Entering on one condition Exiting on another

    Hello,
    I'm having an issue with entering with one indicator and exiting with another. Once an order has been placed the exiting condition will be ignored if the opposing entry conditions are met. Here is the code:
    protectedoverridevoid OnBarUpdate()
    {
    if (RValueCharts(5).VClose[0] >= 3.8)
    {
    EnterLong(DefaultQuantity,
    "RunnerLong");
    }
    if (CrossAbove(DM(14).DiPlus, DM(14).DiMinus, 1))
    {
    ExitLong(
    "", "RunnerLong");
    }

    if (RValueCharts(5).VClose[0] <= -3.8)
    {
    EnterShort(DefaultQuantity,
    "RunnerShort");
    }
    if (CrossBelow(DM(14).DiMinus, DM(14).DiPlus, 1))
    {
    ExitShort(
    "", "RunnerShort");
    }

    I have not specified a "reverse" when the opposing entry conditions are met, yet that is happening. Any suggestions?

    #2
    Hello RickStevenson,

    Entries will reverse a position.

    What you can do is add a market position check to your entries - only enter when flat.

    Code:
     
    if (RValueCharts(5).VClose[0] >= 3.8 && Position.MarketPosition == MarketPosition.Flat)
    {
    EnterLong(DefaultQuantity, "RunnerLong");
    }
     
    if (RValueCharts(5).VClose[0] <= -3.8 && Position.MarketPosition == MarketPosition.Flat)
    {
    EnterShort(DefaultQuantity, "RunnerShort");
    }
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Thank you Ryan. I did as you suggested, but the exit condition is still being ignored to a degree. I have tagged my exit's to the entries with "Runner". When the trades are exiting they're not on the right bar and they're titled "Sell" and "Buy to Cover". Somehow the exiting conditions are not being identified correctly.

      Comment


        #4
        Make sure you've compiled any changes (Right Click > Compile) and reaply any instances of the strategy. If you're still having trouble, let us know exactly where you're looking. A screenshot will be helpful.

        To send a screenshot press Alt + PRINT SCREEN to take a screen shot of the selected window. Then go to Start--> Accessories--> Paint, and press CRTL + V to paste the image. Lastly, save as a jpeg file and post the attachement to this thread.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          I figured it out. Once I added what you suggested I realized that I also had my wire crossed on the Exit conditions. Good now. Thanks for the help.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          558 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          324 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          101 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          545 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          547 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X