Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

resets my pnl

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

  • NinjaTrader_BrandonH
    replied
    Hello franatas,

    Thanks for your post.

    There are no supported methods or properties to check if a strategy is enabled within a NinjaScript strategy.

    If you want to set a variable to 0, you could consider setting it to 0 in OnStateChange() when the State == State.Configure.

    OnStateChange(): https://ninjatrader.com/support/help...ightsub=States

    If you want to skip the historical processing of data when enabling the script so the strategy does not calculate historical (virtual) trades when it is enabled, you could add if (State == State.Historical) return; to the top of your OnBarUpdate() logic.

    For example:

    Code:
    protected override void OnBarUpdate()
    ​{
        if (State == State.Historical)
            return;
    
        //rest of your OnBarUpdate() logic.
    }

    Leave a comment:


  • franatas
    started a topic resets my pnl

    resets my pnl

    if (Bars.IsFirstBarOfSession)
    PnlDiario = 0;


    if (DetenerEstrategia)
    return;

    //Condicion Perdida Maxima Diaria
    PnlDiario = SystemPerformance.AllTrades.TradesPerformance.Curr ency.CumProfit - PnlAcumulado;
    if (ActivarPerdida && (PnlDiario + Position.GetUnrealizedProfitLoss(PerformanceUnit.C urrency, Close[0])) <= -MaxPerdidaDiaria)
    {
    // Se llamará a un método personalizado diseñado para cerrar todas las posiciones abiertas y cancelar todas las órdenes de trabajo.
    StopStrategy();
    }

    using if (Bars.IsFirstBarOfSession) resets my pnl at the start of a new day. The problem comes because when starting the strategy, the NLP is located in the virtual NLP. If the strategy had been working all the time since the beginning of the day, then I need to reset my NLP at the time of starting the strategy.

    And how can I start a strategy without showing me the operations that he was able to do in the past?​

Latest Posts

Collapse

Topics Statistics Last Post
Started by several, 04-22-2025, 05:21 AM
2 responses
232 views
0 likes
Last Post Lukasxgtx  
Started by cherkoul, 06-12-2025, 11:21 PM
0 responses
15 views
0 likes
Last Post cherkoul  
Started by NTEducationTeam, 06-12-2025, 02:30 PM
0 responses
25 views
0 likes
Last Post NTEducationTeam  
Started by NTEducationTeam, 06-05-2025, 09:43 AM
0 responses
114 views
0 likes
Last Post NTEducationTeam  
Started by TheNQKidd, 06-03-2025, 02:51 PM
1 response
162 views
0 likes
Last Post NinjaTrader_ChelseaB  
Working...
X