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 dmking, 11-12-2019, 12:31 PM
        4 responses
        4,140 views
        0 likes
        Last Post jasonw
        by jasonw
         
        Started by roblogic, Today, 04:31 PM
        0 responses
        5 views
        0 likes
        Last Post roblogic  
        Started by morrnel, 05-12-2024, 06:07 PM
        4 responses
        53 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by xepher101, 05-10-2024, 12:19 PM
        6 responses
        71 views
        0 likes
        Last Post xepher101  
        Started by gbourque, Today, 04:11 PM
        0 responses
        3 views
        0 likes
        Last Post gbourque  
        Working...
        X