Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Not exiting properly?

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

    Not exiting properly?

    I am running a system that is based on the cross of the Supertrend. To get into the trade, I have......

    // Condition set 1
    if (Variable0 == 0
    && CrossAbove(Close, SuperTrend(14, 2.618, true).UpTrend, 1))
    {
    EnterLongLimit(1000, GetCurrentBid(), "");
    Variable0 = 1;
    Print ("Variable = 1");
    }

    and then, I have 2 exits (1 on a cross of the other direction and 1 in case it doesn't exit given that condition, and the close is below the downtrend). Here are those conditions.....

    if (Position.MarketPosition == MarketPosition.Long
    && Variable0 == 1
    && (CrossBelow(Close, SuperTrend(14, 2.618, true).DownTrend, 1)))
    {
    ExitLong();
    Variable0 = 0;
    }

    With my backup in case that doesn't execute (because I have seen that happen) looks like this..........

    / Condition getout 0 if Variable0 = 1
    if (Position.MarketPosition == MarketPosition.Long
    && Variable0 == 1
    && (Close[0] < SuperTrend(14, 2.618, true).DownTrend[0]))
    {
    ExitLong();
    Variable0 = 0;
    }

    Now my question is this......why on earth would this position not exit (in picture)????
    Attached Files

    #2
    Edgeliner,

    If this is the same strategy from the other thread I can continue helping you here. It looks like you already had a "flag" going, which I recommended in the other thread.

    What is your CalculateOnBarClose setting here?
    Adam P.NinjaTrader Customer Service

    Comment


      #3
      Yes....the same one.......and, CalculateOnBarClose = true; Any ideas????

      Comment


        #4
        Edgeliner,

        It may be helpful to see a log/trace or some printed order outputs over the time you ran this or to test your code on my end. CancelOrder() can be used to cancel pending limit orders. For this order, you are referring to the one in the middle with the long red line?
        Adam P.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by CarlTrading, Yesterday, 11:51 AM
        0 responses
        19 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, Yesterday, 11:48 AM
        0 responses
        23 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 03-25-2026, 09:53 PM
        0 responses
        30 views
        0 likes
        Last Post CaptainJack  
        Started by CaptainJack, 03-25-2026, 09:51 PM
        0 responses
        17 views
        0 likes
        Last Post CaptainJack  
        Started by Mindset, 03-23-2026, 11:13 AM
        0 responses
        23 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Working...
        X