• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Average Trade

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

  • shawnj
    started a topic Average Trade

    Average Trade

    I'm trying to develop an indicator to use in a Market Analyzer that simply will display the average trade in the contract's native currency. Using the column names in Market Analyzer that would be Realized PnL divided by Traded Contracts. With posibly having an input option to include Unrealized PnL.

    If I use Performance.AllTrades.Count I get the following error:
    "The name Performance does exisit in the current context."

    So a couple of questions if I may:

    1) How do I get rid of this error?

    2) Is this the proper formula to get what I'm looking for:
    Performance.AllTrades.Performance.Currency.CumProf it/Performance.AllTrades.Count

    3) The best I can tell the code completion (the drop down list after typing a ".") does not seem to work?

    4) Is there no F1 help? I would assume I could click on the word Performance and hit F1 and go to some help that would explain everything Performance can do and how to use it.

    5) Where is there some help explaining everything Performance can do.

    6) Are there any special coding tips for indicators that are just going to be used in Market Analyer?

    7) Is there some way to set up the indicator such that it only updates anytime a trade is completed instead of tick-by-tick (or bar-by-bar)?

    Here is what I've got:

    [Description("Realized PL / Total Trades")]
    [Gui.Design.DisplayName("aaAvg Trade")]
    public class aaAvgTrade : Indicator
    {
    #region Variable;
    double avgTrade;
    #endregion

    protected override void Initialize()
    {
    avgTrade=0.0;
    Add(new Plot(Color.Orange, PlotStyle.Line, "AvgTrade"));
    CalculateOnBarClose = false;
    Overlay = false;
    PriceTypeSupported = false;
    }

    protected override void OnBarUpdate()
    {
    avgTrade = Performance.AllTrades.Count;

    if (avgTrade != 0)
    avgTrade =
    Performance.AllTrades.Performance.Currency.CumProf it / avgTrade;

    AvgTrade.Set(avgTrade);
    }

  • shawnj
    replied
    If you happen to consider it further, this would be the round turn average trade so using the column names of Market Analyzer it would be:

    Realized PnL / ( Traded Contracts * 0.5 )

    Leave a comment:


  • NinjaTrader_Ray
    replied
    Will put this on our list for future enhancement consideration.

    Leave a comment:


  • shawnj
    replied
    Then could I make a request to add "Average Trade" to the column choices in Market Analyzer?

    Leave a comment:


  • NinjaTrader_Ray
    replied
    The Performance object is not available in the Indicator class. There is no currently supported approach to get what you want done.

    4) Context sensitive help within NinjaScript Editor is not supported.

    6) Nothing that I can think of.

    7) Not at this time.

    Leave a comment:

Latest Posts

Collapse

Topics Statistics Last Post
Started by johnnybegoode, Today, 11:35 AM
1 response
9 views
0 likes
Last Post NinjaTrader_ChrisL  
Started by NickyD, Today, 09:07 AM
3 responses
14 views
0 likes
Last Post NickyD
by NickyD
 
Started by 7robert, Today, 06:46 AM
3 responses
62 views
0 likes
Last Post NinjaTrader_ChrisL  
Started by ElMagoR, Today, 07:49 AM
4 responses
31 views
0 likes
Last Post NinjaTrader_ChrisL  
Started by Nabil, 09-13-2019, 11:44 AM
5 responses
35 views
0 likes
Last Post Nabil
by Nabil
 
Working...
X