How to get CumProfit of the day, not the whole chart? - futures io
futures io



How to get CumProfit of the day, not the whole chart?


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one redratsal with 3 posts (6 thanks)
    2. looks_two gztanwei with 2 posts (0 thanks)
    3. looks_3 Big Mike with 1 posts (0 thanks)
    4. looks_4 Quick Summary with 1 posts (0 thanks)
    1. trending_up 4,215 views
    2. thumb_up 6 thanks given
    3. group 1 followers
    1. forum 6 posts
    2. attach_file 0 attachments




Welcome to futures io: the largest futures trading community on the planet, with well over 125,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

 
Search this Thread
 

How to get CumProfit of the day, not the whole chart?

(login for full post details)
  #1 (permalink)
 gztanwei 
toronto
 
Experience: Beginner
Platform: NinjaTrader
 
Posts: 33 since Sep 2009
Thanks: 3 given, 11 received

Hi I am trying to set a daily profit and loss limit to my strategy. After the limit is hit, the strategy stops trading for the day.

Here I found this function to return cumulative realized profit.
Performance.AllTrades.TradesPerformance.Points.Cum Profit

But this function returns cumulated profit of all days on the chart, not daily profit...

I know I could work around it by setting the chart's data series to one day only. But I would really to have daily profit limit, so that I can eye on my strategy on a multiple-day chart.

Thank you!

Started this thread Reply With Quote

Can you help answer these questions
from other members on futures io?
TradingView help in improving Anchored Vwap
Platforms and Indicators
Experience with AGN (Introducing Broker)
Brokers
TD Sequential for NT or MW?
Platforms and Indicators
Eurex Denali vs dxFeed
Sierra Chart
Is there inherently more opportunity in smaller markets?
Traders Hideout
 
 
(login for full post details)
  #3 (permalink)
 redratsal 
Milan (I)
 
Experience: Advanced
Platform: Ninjatrader
Broker: Kinetick
Trading: FDAX,6E,CL,YM,NQ,ES
 
redratsal's Avatar
 
Posts: 1,653 since Oct 2010
Thanks: 1,215 given, 2,084 received


try this: Performance.RealtimeTrades.TradesPerformance.Currency.CumProfit

** if you stop your strategy and restart it the same day the daily cumprofit will restart from zero.

Visit my futures io Trade Journal Reply With Quote
 
(login for full post details)
  #4 (permalink)
 gztanwei 
toronto
 
Experience: Beginner
Platform: NinjaTrader
 
Posts: 33 since Sep 2009
Thanks: 3 given, 11 received


redratsal View Post
try this: Performance.RealtimeTrades.TradesPerformance.Currency.CumProfit

** if you stop your strategy and restart it the same day the daily cumprofit will restart from zero.

thanks. but this method does not work when I want to back test my strategy... I hope the strategy to stop every day on my chart, and start again the next day.

Started this thread Reply With Quote
 
(login for full post details)
  #5 (permalink)
 redratsal 
Milan (I)
 
Experience: Advanced
Platform: Ninjatrader
Broker: Kinetick
Trading: FDAX,6E,CL,YM,NQ,ES
 
redratsal's Avatar
 
Posts: 1,653 since Oct 2010
Thanks: 1,215 given, 2,084 received


gztanwei View Post
thanks. but this method does not work when I want to back test my strategy... I hope the strategy to stop every day on my chart, and start again the next day.

Ok you did not mention in your op it was for backtesting concern, if the data range is consistent what I do in this case is import the data into an excel file and filter the information separately (nt has some limits and sometimes you have to overcome manually).

Visit my futures io Trade Journal Reply With Quote
 
(login for full post details)
  #6 (permalink)
 Big Mike 
Site Administrator
Swing Trader
Data Scientist & DevOps
Manta, Ecuador
 
Experience: Advanced
Platform: Custom solution
Trading: Futures & Crypto
 
Big Mike's Avatar
 
Posts: 50,129 since Jun 2009
Thanks: 32,601 given, 98,784 received

Been years, so I am rusty. But I have definitely done this for both real time and backtesting.

There is another method you can call that is not RealtimeTrades. Can't remember what it is called, sorry.

And then on each new session, you need to simply check the prior value, and then 'reset' it by putting forward a new value that starts at zero each day.

Mike

We're here to help -- just ask

For the best trading education, watch our webinars
Searching for trading reviews? Review this list

Follow us on Twitter, YouTube, and Facebook

Support our community as an Elite Member:
https://futures.io/elite/

Visit other sites? Please spread the word about your experience with our community!
Follow me on Twitter Visit my futures io Trade Journal Reply With Quote
 
(login for full post details)
  #7 (permalink)
 redratsal 
Milan (I)
 
Experience: Advanced
Platform: Ninjatrader
Broker: Kinetick
Trading: FDAX,6E,CL,YM,NQ,ES
 
redratsal's Avatar
 
Posts: 1,653 since Oct 2010
Thanks: 1,215 given, 2,084 received

 
Code
 protected override void OnBarUpdate()
        
			// At the start of a new session
			if (Bars.FirstBarOfSession)
			{
				// Store the strategy's prior cumulated realized profit and number of trades
				priorTradesCount = Performance.AllTrades.Count;
				priorTradesCumProfit = Performance.AllTrades.TradesPerformance.Currency.CumProfit;
				
				/* NOTE: Using .AllTrades will include both historical virtual trades as well as real-time trades.
				If you want to only count profits from real-time trades please use .RealtimeTrades. */
			}
			
			/* Prevents further trading if the current session's realized profit exceeds $1000 or if realized losses exceed $400.
			Also prevent trading if 10 trades have already been made in this session. */
			if (Performance.AllTrades.TradesPerformance.Currency.CumProfit - priorTradesCumProfit >= 1000
				|| Performance.AllTrades.TradesPerformance.Currency.CumProfit - priorTradesCumProfit <= -400
				|| Performance.AllTrades.Count - priorTradesCount > 10)
			{
				/* TIP FOR EXPERIENCED CODERS: This only prevents trade logic in the context of the OnBarUpdate() method. If you are utilizing
				other methods like OnOrderUpdate() or OnMarketData() you will need to insert this code segment there as well. */
				
				// Returns out of the OnBarUpdate() method. This prevents any further evaluation of trade logic in the OnBarUpdate() method.
				return;
			}

Visit my futures io Trade Journal Reply With Quote
The following 6 users say Thank You to redratsal for this post:


futures io Trading Community Platforms and Indicators NinjaTrader > How to get CumProfit of the day, not the whole chart?


Last Updated on May 22, 2012


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
 

Our 12-year anniversary w/ $$,$$$ prizes (check soon)

August
     



Copyright © 2021 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada), info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts