NexusFi: Find Your Edge


Home Menu

 





Remove Levels from List Object


Discussion in NinjaTrader

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




 
Search this Thread
  #1 (permalink)
 Laserdan 
North Carolina
 
Experience: Beginner
Platform: Ninja Trader
Broker: Ninja Trader Broker / Continuum
Trading: ES
Posts: 57 since Jun 2009
Thanks Given: 4
Thanks Received: 57

I need some help, Here is a slimmed down version of what I am trying to do:

 
Code
// In Variables Section
List<double>listLongOrderLevels = new List<double>();
//end Variable Section

//In OnBarUpdate
//Conditions to find price
listLongOrderLevels.Add(prc)
 
//Logic to Find Nearest price level
privatedouble FindNearestLongLevel () 
{
//Compare current price with levels in List object, Return Closest price
}
//Ready to place Order
x = FindNearestLongLevel();
EnterLongLimit(x);

Now i need to remove the levels from the list object only after the order is filled. I will have to override the OnExecution method.
 
Code
protectedoverridevoid OnExecution(IExecution execution)
{
listLongOrderLevels.Remove(execution.Price);
}
There is where the problem comes, it removes the level if a stop or target is also on it

So here is what I want to do, each level in the list object is executed only once, then removed AFTER filled. Also I want only one order at a time, due to margin limits. Can someone please help me?


Follow me on X Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
SEC Chairman Calls for New Golden Age of SEC-CFTC Regula …
Traders Hideout
More Than Capable: Hegseths War Warning Validates $114M …
Prediction Markets & Event Contracts
Day 96 Missiles Hit Kuwait and Bahrain: June 15 Peace at …
Prediction Markets & Event Contracts
Iran War Prediction Markets: Ceasefire 16%, Ground Invas …
Prediction Markets & Event Contracts
Iran Ceasefire Surges to 19.5% on US 15-Point Plan -- 82 …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Sober Journey With S&P
21 thanks
2026 Jlab journal
10 thanks
Algo automated / semi-automated trading anyone?
6 thanks
Lady Vols Primer: Trading Volatility Journal
6 thanks
2026 Fire Horse
5 thanks
  #2 (permalink)
 
roonius's Avatar
 roonius   is a Vendor
 
Posts: 131 since Jun 2009
Thanks Given: 20
Thanks Received: 298


Laserdan View Post
I need some help, Here is a slimmed down version of what I am trying to do:

There is where the problem comes, it removes the level if a stop or target is also on it

So here is what I want to do, each level in the list object is executed only once, then removed AFTER filled. Also I want only one order at a time, due to margin limits. Can someone please help me?

You would need to introduce IOrder:
Something like this:



 
Code
// In Variables Section
List<double>listLongOrderLevels = new List<double>();
IOrder entryorder;
//end Variable Section

//In OnBarUpdate
//Conditions to find price
listLongOrderLevels.Add(prc)
 
//Logic to Find Nearest price level
privatedouble FindNearestLongLevel () 
{
//Compare current price with levels in List object, Return Closest price
}
//Ready to place Order
x = FindNearestLongLevel();
entryorder = EnterLongLimit(x);


protectedoverridevoid OnExecution(IExecution execution)
{
if (entryorder != null && execution.Order.Token == entryOrder.Token)
 listLongOrderLevels.Remove(execution.Price);
}


Reply With Quote
  #3 (permalink)
 Laserdan 
North Carolina
 
Experience: Beginner
Platform: Ninja Trader
Broker: Ninja Trader Broker / Continuum
Trading: ES
Posts: 57 since Jun 2009
Thanks Given: 4
Thanks Received: 57


Thanks, I will see where it takes me...I knew it was something like that.


Follow me on X Started this thread Reply With Quote
  #4 (permalink)
 Laserdan 
North Carolina
 
Experience: Beginner
Platform: Ninja Trader
Broker: Ninja Trader Broker / Continuum
Trading: ES
Posts: 57 since Jun 2009
Thanks Given: 4
Thanks Received: 57

Once again, thanks roonius..wrks like a charm. Now on to the next phase...


Follow me on X Started this thread Reply With Quote




Last Updated on July 24, 2009


© 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