PDA

View Full Version : TradesPerformance


ATI user
04-09-2008, 05:40 AM
I am running 6.5.1000.1 and using this sample code.

It does not pickup any PnL in Market Replay nor real time feed. My cs is making trades and this code just prints 0 for TradesCumProfit

TradesCumProfit =
Performance.AllTrades.TradesPerformance.Currency.C umProfit
+ Position.GetProfitLoss(Close[0], PerformanceUnit.Currency);

Print ( TradesCumProfit = "+TradesCumProfit );

NinjaTrader_Ray
04-09-2008, 07:12 AM
Josh will double check by tomorrow.

ATI user
04-09-2008, 09:05 AM
thanks Ray

Possibly related....prior to NT 6.5.1000.1 my cs would detect is a trade was 'Stopped' via the ControlCenter/Strategy tab... by using the code:

if ( atmStrategyIdBreak.Length > 0
&& GetAtmStrategyMarketPosition(atmStrategyIdBreak) == Cbi.MarketPosition.Flat )

today I closed an atm strategy (which was initiated via my cs) via the strategies tab and the cs still thinks it has a trade on (i.e. it keeps updating unrealizedPnL as if the trade is still active)...therefore, Length must still be > 0 and position is not flat....even though in Strategies tab and Positions tab show the strategy and position closed.

was something changed in this area since Beta 10?....as I have not changed my code

thanks.

NinjaTrader_Josh
04-09-2008, 08:49 PM
Hi ATI_User,

I am not sure if your code is correct because it does not compile. When I use an alternate code snippet I get PnL responses that are the ones that you would expect.

Please try my attached test sample.

About your atmstrategy question: Can you provide a simple as possible sample that demonstrates what you are seeing? Thanks.

ATI user
04-09-2008, 09:21 PM
Hey Josh

I ran your strategy and of course it prints PnL properly.

I copied your code into my strategy (even though the code I was using is identical) and although my cs places trades, your code still prints zero.

The only difference I can see is that you use Enter Long/Enter Short and my cs uses:

AtmStrategyCreate(Action.Sell, OrderType.Market, 0, 0, TimeInForce.Day, orderIdBreak, AtmTemplateM, atmStrategyIdBreak);

could this be the difference? i.e. the code only picks up PnL for backtesting?

In other words, do I need to pass IDs to TradesPerformance somehow?

Thanks

ATI

ps...my code in the initial post did not compile as a " was left out of the print statement.

ATI user
04-09-2008, 09:45 PM
Josh

Plug this in to your sample and your will see it only prints 0

Note: you will need to create an atm strategy named "AutoATM" of course.


if (CrossAbove(SMA(Fast), SMA(Slow), 1))
{
Print(Time[0] + " Submit Long");
BackColor = Color.Green;
// EnterLong();
AtmStrategyCreate(Action.Buy, OrderType.Market, 0, 0, TimeInForce.Day, GetAtmStrategyUniqueId(),"AutoATM", GetAtmStrategyUniqueId());
}
else if (CrossBelow(SMA(Fast), SMA(Slow), 1))
{
Print(Time[0] + " Submit Short");
BackColor = Color.Red;
// EnterShort();
AtmStrategyCreate(Action.Sell, OrderType.Market, 0, 0, TimeInForce.Day, GetAtmStrategyUniqueId(),"AutoATM", GetAtmStrategyUniqueId());
}
TradesCumProfit = Performance.AllTrades.TradesPerformance.Currency.C umProfit + Position.GetProfitLoss(Close[0], PerformanceUnit.Currency);
Print(Time[0] + " " + TradesCumProfit);

NinjaTrader_Josh
04-10-2008, 01:36 AM
Yup the TradesPerformance is not designed to work with ATMs. You will want to use these instead: http://www.ninjatrader-support.com/HelpGuideV6/helpguide.html?AsmStrategyUnrealizedProfitLoss
http://www.ninjatrader-support.com/HelpGuideV6/helpguide.html?AsmStrategyRealizedProfitLoss

ATI user
04-10-2008, 05:42 AM
Right...that is what I have been using.

Thought maybe the other one might work better.

Thanks anyway.

makra081
03-01-2009, 02:15 PM
I use a strategy what creates ATM strategies, which are only valid for one trade.

Follow up trades show up under the Strategie Tab as separate ATM strategies.

In my case how can I read CumProf or Account Cash Value via Script?

I understand TradesPerformance does not work ?

NinjaTrader_Josh
03-02-2009, 07:27 AM
You have to be tracking it manually for each of your ATM strategies and aggregate a total.

makra081
03-02-2009, 07:28 AM
TY for your reply