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 bortz, 11-06-2023, 08:04 AM
        47 responses
        1,603 views
        0 likes
        Last Post aligator  
        Started by jaybedreamin, Today, 05:56 PM
        0 responses
        8 views
        0 likes
        Last Post jaybedreamin  
        Started by DJ888, 04-16-2024, 06:09 PM
        6 responses
        18 views
        0 likes
        Last Post DJ888
        by DJ888
         
        Started by Jon17, Today, 04:33 PM
        0 responses
        4 views
        0 likes
        Last Post Jon17
        by Jon17
         
        Started by Javierw.ok, Today, 04:12 PM
        0 responses
        12 views
        0 likes
        Last Post Javierw.ok  
        Working...
        X