Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Errors closing positions

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

    Errors closing positions

    Hi, i am programming a simple strategy and Nt7.0.23 are having strange behaviors.
    I attached some screens capture where you can see it:






    The strategy code ist simple:

    Code:
    .
    .
    .
    
            protected override void OnBarUpdate()
            {
    
                mylong = "myconditionstolong";
                myshort= "myconditionstoshort";
                
                if (ellargo < Close[0]){ExitShort();EnterLong(DefaultQuantity, "");}
                if (elcorto > Close[0]){ExitLong();EnterShort(DefaultQuantity, "");}
                
                // Resets the stop loss to the original value when all positions are closed
                if (Position.MarketPosition == MarketPosition.Flat){
                    SetStopLoss(CalculationMode.Ticks, mistop);
                }
                
                // If a long position is open, allow for stop loss modification to breakeven
                else if (Position.MarketPosition == MarketPosition.Long){
                    if (Close[0] == Position.AvgPrice + 9 * TickSize){
                        SetStopLoss(CalculationMode.Price, Position.AvgPrice + 1 * TickSize);
                    }
                   if (Close[0] == Position.AvgPrice + 18 * TickSize){
                        SetStopLoss(CalculationMode.Price, Position.AvgPrice + 9 * TickSize);
                    } 
                    (etc ................)
    
                 }
    .
    .
    .
    .
    .

    #2
    marynja, please update to the latest version of NinjaTrader and see if the problem persists. We are on the second production release of NT7 (7.0.1000.2) at this point, so the error might've been fixed by now. You can update by going to Help -> Download Site.
    AustinNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by cmoran13, Yesterday, 01:02 PM
    0 responses
    27 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    18 views
    0 likes
    Last Post PaulMohn  
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    160 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    95 views
    1 like
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    148 views
    2 likes
    Last Post CaptainJack  
    Working...
    X