NexusFi: Find Your Edge


Home Menu

 





Flatten everything once unrealized P/L reaches a certain number


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one runit with 13 posts (0 thanks)
    2. looks_two sam028 with 7 posts (7 thanks)
    3. looks_3 pstrusi with 2 posts (0 thanks)
    4. looks_4 DevelopingNT with 1 posts (0 thanks)
    1. trending_up 5,352 views
    2. thumb_up 8 thanks given
    3. group 5 followers
    1. forum 22 posts
    2. attach_file 1 attachments




 
Search this Thread

Flatten everything once unrealized P/L reaches a certain number

  #21 (permalink)
pstrusi
Lalin Pontevedra Spain
 
Posts: 20 since Sep 2013
Thanks Given: 10
Thanks Received: 9


runit View Post
That would work if I had one underlying open at the same time.

If I have more than one, I want the NET unrealized P/l to be a certain number, and then flatten all of my positions. If say, it's $100, that could mean one position is +200 and one is -100 - net unrealized p/l +100, and i need to close them all at the same time.

I understand. There's no a direct command for that in NT, but you might create some method by yourself. A brief draft idea about it could be:

1. In NinjaTrader7 you can use "GetAccountValue(AccountItem.NetLiquidation)" vs its previous day's value, then..
2. the Algo should be able to determine what positions are opened to close them. There's an unsupported old snippet that perhaps could give you some starting point if you have some programming experience:

 
Code
foreach (var instrument in BarsArray)
				{
					foreach (Account acct in Cbi.Globals.Accounts)
					{
						if (acct.Positions != null)
						{
							PositionCollection positions = acct.Positions;
							foreach (Position pos in positions)
							{
								if (BarsInProgress == 0 && pos.Account.Name == "XXXX" && pos.Instrument.FullName == "ES 12-19")
								{
									// determine what position is active and close it
								}
							}
						}
					}
				}

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
MC PL editor upgrade
MultiCharts
How to apply profiles
Traders Hideout
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
Better Renko Gaps
The Elite Circle
Cheap historycal L1 data for stocks
Stocks and ETFs
 
  #22 (permalink)
 runit 
Toronto, Ontario/Canada
 
Experience: Intermediate
Platform: TOS
Trading: stocks
Posts: 38 since Dec 2014
Thanks Given: 10
Thanks Received: 3


pstrusi View Post
I understand. There's no a direct command for that in NT, but you might create some method by yourself. A brief draft idea about it could be:

1. In NinjaTrader7 you can use "GetAccountValue(AccountItem.NetLiquidation)" vs its previous day's value, then..
2. the Algo should be able to determine what positions are opened to close them. There's an unsupported old snippet that perhaps could give you some starting point if you have some programming experience:

 
Code
foreach (var instrument in BarsArray)
				{
					foreach (Account acct in Cbi.Globals.Accounts)
					{
						if (acct.Positions != null)
						{
							PositionCollection positions = acct.Positions;
							foreach (Position pos in positions)
							{
								if (BarsInProgress == 0 && pos.Account.Name == "XXXX" && pos.Instrument.FullName == "ES 12-19")
								{
									// determine what position is active and close it
								}
							}
						}
					}
				}

Thank you, I appreciate the draft, but have zero programming experience. Perhaps somebody else can contribute using some of the suggestions in this thread?

Started this thread Reply With Quote
  #23 (permalink)
 
CannonTrading's Avatar
 CannonTrading   is a Vendor
 
Posts: 216 since Mar 2013
Thanks Given: 77
Thanks Received: 183



runit View Post
Is it possible to automatically set NT8 to flatten all of my account positions once the unrealized P/L reaches a certain $ value? And if so, does the platform need to continue running on the computer?

Thank you!

Probably no help...but I do this with my CQG terminal. Love it when it hits my daily profit target, hate it when it hit my daily loss limit.....

PM with any questions about Cannon Trading (800) 454-9572 (310) 859-9572. Trading commodity futures, forex and options involves substantial risk of loss. The recommendations contained in this post are of opinion only and do not guarantee any profits. These are risky markets and only risk capital should be used. Past performance is not necessarily indicative of future results.
Follow me on Twitter Reply With Quote
Thanked by:




Last Updated on December 3, 2019


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
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.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts