NexusFi: Find Your Edge


Home Menu

 





Remove Levels from List Object


Discussion in NinjaTrader

Updated
    1. trending_up 4,567 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?
Thanks Mike. Godspeed.
The Elite Circle
Warsh Drops Easing Bias, December Hike Now Above 50% -- …
Prediction Markets & Event Contracts
Datafeed for Atas
Platforms and Indicators
Netherlands & Germany Surge as World Cup Field Narro …
Prediction Markets & Event Contracts
Iran Lebanon Problem Kills Switzerland Talks, Brent at $ …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Want your NinjaTrader indicator created, free?
5 thanks
Afternoon-close session
1 thanks
Franks Trading Journey
1 thanks
Denied 20K payouts: Alpha Futures
1 thanks
FootPrintV2 Chart for NT8
1 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