Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 sy2023, 09-15-2023, 08:51 PM
2 responses
234 views
0 likes
Last Post Crusade12  
Started by kiss987, 05-16-2018, 02:19 AM
14 responses
2,870 views
0 likes
Last Post bobperez  
Started by jalley, 03-22-2021, 12:17 PM
4 responses
133 views
0 likes
Last Post bobperez  
Started by HGTrader, Today, 02:13 PM
6 responses
13 views
0 likes
Last Post HGTrader  
Started by rbeckmann05, Today, 03:45 PM
0 responses
7 views
0 likes
Last Post rbeckmann05  
Working...
X