NexusFi: Find Your Edge


Home Menu

 





Remove Levels from List Object


Discussion in NinjaTrader

Updated
    1. trending_up 3,716 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?
REcommedations for programming help
Sierra Chart
Increase in trading performance by 75%
The Elite Circle
Better Renko Gaps
The Elite Circle
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Trade idea based off three indicators.
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
34 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
18 thanks
GFIs1 1 DAX trade per day journal
16 thanks
Vinny E-Mini & Algobox Review TRADE ROOM
13 thanks
  #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