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

performance metric question

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

    performance metric question

    Hello,
    I'm studying performance metric. I would for first step understand how to print a particular performance metric value on output.
    For this pourpose, I wrote a sample strategy where i would print the cumulative profit of each trade on the output.( I used cumulative profit just because it's already in the platform performance metric sample!!!)
    I added the NT sample sumcumprofit (... but I could use another permormance metric, I'm not interseting in cumprofit) in the strategy but i don't know how to print the cum profit value.
    Can you give me some advice please? Thank you in advance!



    public class PrintPerformancemetric : Strategy
    {

    NinjaTrader.NinjaScript.PerformanceMetrics.SampleC umProfit myProfit;

    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = @"Enter the description for your new custom Strategy here.";
    Name = "PrintPerformancemetric";
    Calculate = Calculate.OnBarClose;
    EntriesPerDirection = 1;
    EntryHandling = EntryHandling.AllEntries;
    IsExitOnSessionCloseStrategy = true;
    ExitOnSessionCloseSeconds = 30;
    IsFillLimitOnTouch = false;
    MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix;
    OrderFillResolution = OrderFillResolution.Standard;
    Slippage = 0;
    StartBehavior = StartBehavior.WaitUntilFlat;
    TimeInForce = TimeInForce.Gtc;
    TraceOrders = false;
    RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose;
    StopTargetHandling = StopTargetHandling.PerEntryExecution;
    BarsRequiredToTrade = 20;
    // Disable this property for performance gains in Strategy Analyzer optimizations
    // See the Help Guide for additional information
    IsInstantiatedOnEachOptimizationIteration = true;
    }
    else if (State == State.Configure)
    {
    myProfit = new NinjaTrader.NinjaScript.PerformanceMetrics.SampleC umProfit();
    AddPerformanceMetric(new NinjaTrader.NinjaScript.PerformanceMetrics.SampleC umProfit());

    SetProfitTarget(CalculationMode.Ticks, 20);
    SetStopLoss(CalculationMode.Ticks, 20);

    }
    }

    protected override void OnBarUpdate()
    {
    if(CurrentBar<10)
    return;

    if(High[0]>High[1])
    EnterLong();

    // I would print samplecumprofit of each trade on the output...

    }
    Last edited by zteck; 11-07-2017, 09:05 AM.

    #2
    Hello zteck,

    Thank you for your note.

    The link below if added to your script will print the SampleCumProfit to the Output window.


    I have provided a screen shot demonstrating this.

    Please let us know if you need further assistance.
    Attached Files
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      Thank you so much for the help ALanP!!!
      I haveanother question about performance metric... How can I see a performance metric on the strategy analyzer grid?

      Comment


        #4
        Hello zteck,

        You would enable these under Tools>Options.

        At the following link, please see next to Custom performance metric(s),


        Please let us know if you need further assistance.
        Alan P.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by adeelshahzad, Today, 03:54 AM
        5 responses
        30 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Started by stafe, 04-15-2024, 08:34 PM
        7 responses
        31 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by merzo, 06-25-2023, 02:19 AM
        10 responses
        823 views
        1 like
        Last Post NinjaTrader_ChristopherJ  
        Started by frankthearm, Today, 09:08 AM
        5 responses
        18 views
        0 likes
        Last Post NinjaTrader_Clayton  
        Started by jeronymite, 04-12-2024, 04:26 PM
        3 responses
        43 views
        0 likes
        Last Post jeronymite  
        Working...
        X