NexusFi: Find Your Edge


Home Menu

 





Variable strategy order quantity


Discussion in NinjaTrader

Updated
    1. trending_up 3,422 views
    2. thumb_up 0 thanks given
    3. group 2 followers
    1. forum 2 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
Astrogirl
Milan/Italy
 
Posts: 51 since Oct 2013
Thanks Given: 25
Thanks Received: 12

Hello everyone!

The default quantity of my strategy is "1" but, in certain condition, i would change this value in "2".
What follows is the code I am actually using:

 
Code
protected override void OnBarUpdate()
{
                // Change the order quantity value when the profit factor drow down a certain level
                if (Performance.AllTrades.TradesPerformance.ProfitFactor < profit_factor_limit)
         
              {
                  DefaultQuantity = 2;
              }	
}
The matter is that it changes the default quantity of all trades and not only the one which respects the condition set...

Does anyone know why?


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
What we know about Binances $6.3bn hack - BBC News
Cryptocurrency
My Rant with AMP Futures
Trading Reviews and Vendors
requesting .nrd replay files from 2026 spy and qqq
The Elite Circle
Bitcoin’s 2022 low, 2025 high and 2026 low so far arou …
Cryptocurrency
AI for Traders — Agents, Memory, Tools & Real-Worl …
Elite Quantitative GenAI/LLM
 
  #3 (permalink)
 
gregid's Avatar
 gregid 
Wrocław, Poland
 
Experience: Intermediate
Platform: NinjaTrader, Racket
Trading: Ockham's razor
Posts: 649 since Aug 2009
Thanks Given: 320
Thanks Received: 623


In your case you don't change the DefaultQuantity. Instead you simply ask for quantity in the EnterLong() or short or any other Order Method.
As in:
 
Code
                            
EnterLong(2) 

Use the official help guide for reference:
NinjaTrader Version 7


Reply With Quote




Last Updated on October 20, 2013


© 2026 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 - Downloads - Top
no new posts