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 helpwanted, Today, 03:06 AM
        1 response
        5 views
        0 likes
        Last Post sarafuenonly123  
        Started by Brevo, Today, 01:45 AM
        0 responses
        7 views
        0 likes
        Last Post Brevo
        by Brevo
         
        Started by aussugardefender, Today, 01:07 AM
        0 responses
        5 views
        0 likes
        Last Post aussugardefender  
        Started by pvincent, 06-23-2022, 12:53 PM
        14 responses
        242 views
        0 likes
        Last Post Nyman
        by Nyman
         
        Started by TraderG23, 12-08-2023, 07:56 AM
        9 responses
        384 views
        1 like
        Last Post Gavini
        by Gavini
         
        Working...
        X