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

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.
    Brandon H.NinjaTrader Customer Service

    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.
        Brandon H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by pmachiraju, 11-01-2023, 04:46 AM
        8 responses
        148 views
        0 likes
        Last Post rehmans
        by rehmans
         
        Started by mattbsea, Today, 05:44 PM
        0 responses
        5 views
        0 likes
        Last Post mattbsea  
        Started by RideMe, 04-07-2024, 04:54 PM
        6 responses
        33 views
        0 likes
        Last Post RideMe
        by RideMe
         
        Started by tkaboris, Today, 05:13 PM
        0 responses
        5 views
        0 likes
        Last Post tkaboris  
        Started by GussJ, 03-04-2020, 03:11 PM
        16 responses
        3,282 views
        0 likes
        Last Post Leafcutter  
        Working...
        X