Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

trade does not show data

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

    trade does not show data

    Hello,When I try to get the trade values these do not work, the systemPerformance.AllTrades.Count or the SystemPerformance.AllTrades.LosingTrades.Count never works
    code strategy.
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Xml.Serialization;
    using NinjaTrader.Cbi;
    using NinjaTrader.Gui;
    using NinjaTrader.Gui.Chart;
    using NinjaTrader.Gui.SuperDom;
    using NinjaTrader.Data;
    using NinjaTrader.NinjaScript;
    using NinjaTrader.Core.FloatingPoint;
    using NinjaTrader.NinjaScript.DrawingTools;
    using NinjaTrader.NinjaScript.Indicators;
    using NinjaTrader.Gui.NinjaScript;

    namespace NinjaTrader.NinjaScript.Strategies
    {

    class TreadeDayScript : Strategy
    {
    private const string SystemVersion = "V1.0";
    private const string StrategyName = "TradeDay";
    private const string StrategyDesc = "";
    private int cantidadaTrades = 0;
    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    setDefault();
    }
    }
    private void setDefault() {
    Description = StrategyDesc;
    Name = StrategyName + SystemVersion;
    Calculate = Calculate.OnBarClose;
    BarsRequiredToTrade = 0;
    Slippage = 0;
    StartBehavior = StartBehavior.WaitUntilFlat;
    IsExitOnSessionCloseStrategy = false;
    ExitOnSessionCloseSeconds = 30;
    TraceOrders = false;
    }

    protected override void OnBarUpdate()
    {
    nombreInstrumento();
    valoresBars();
    //base.OnBarUpdate();
    cantidadaTrades=SystemPerformance.AllTrades.Count;
    MyTranfer.MyInt = cantidadaTrades;
    tradeGanadores();
    tradePerdedores();
    }
    private void nombreInstrumento()
    {
    MyTranfer.nameInstrument = Instrument.FullName;
    }
    private void tradeGanadores()
    {
    if (SystemPerformance.AllTrades.WinningTrades.Count > 0)
    {
    Trade firstTrade = SystemPerformance.AllTrades.WinningTrades[0];
    MyTranfer.Winner=firstTrade.ProfitPercent;
    }

    }
    private void tradePerdedores()
    {
    if (SystemPerformance.AllTrades.LosingTrades.Count > 0)
    {
    Trade firstTradeLosing = SystemPerformance.AllTrades.LosingTrades[0];
    MyTranfer.Loser=firstTradeLosing.ProfitPercent;
    }

    }
    private void valoresBars()
    {
    MyTranfer.priceLow=CurrentDayOHL().CurrentLow[0];
    MyTranfer.priceHeigth=CurrentDayOHL().CurrentHigh[0];
    }


    }
    }
    Starts
    12-10-2020
    Ends
    12-10-2020

    #2
    Hello GerardoAC,

    Welcome to the NinjaTrader forums.

    Does your strategy place trades? The SystemPerformance object holds all trades and trade performance data generated by a strategy.

    When a trade is placed, the position does not update immediately. SystemPerformance will be updated after the position is updated and OnPositionUpdate runs.

    Please note that you will NOT receive position updates for manually placed orders or orders managed by other strategies. This is seen in the Notes section in the OnPosition help guide documentation.

    Below is the help guide documentation for OnPositionUpdate.


    Please let us know if we may further assist.
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3

      It is necessary to use OnPositionUpdate to be able to see the result of the trade performed, I need to get the winning and losing trades of the day.

      Comment


        #4
        Hello GerardoAC,

        Thank you for your note.

        OnPositionUpdate does not have to be used in order to see the results from SystemPerformance. As seen in the SystemPerformance help guide documentation linked below, SystemPerformance could be used in OnBarUpdate() to get AllTrades, LongTrades, RealTimeTrades, and ShortTrades for the trades placed by your strategy.

        SystemPerformance - https://ninjatrader.com/support/help...erformance.htm

        Please let us know if you have further questions.
        <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Yesterday, 05:17 AM
        0 responses
        56 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        132 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        73 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        45 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        49 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X