NexusFi: Find Your Edge


Home Menu

 





Remove Levels from List Object


Discussion in NinjaTrader

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




 
Search this Thread

Remove Levels from List Object

  #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 Twitter Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Deepmoney LLM
Elite Quantitative GenAI/LLM
Better Renko Gaps
The Elite Circle
New Micros: Ultra 10-Year & Ultra T-Bond -- Live Now
Treasury Notes and Bonds
Online prop firm The Funded Trader (TFT) going under?
Traders Hideout
 
  #2 (permalink)
 
roonius's Avatar
 roonius   is a Vendor
 
Posts: 131 since Jun 2009
Thanks Given: 20
Thanks Received: 295


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 Twitter 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 Twitter Started this thread Reply With Quote




Last Updated on July 24, 2009


© 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