NexusFi: Find Your Edge


Home Menu

 





how to extract nearest support price from arraylist?


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one zacharydw00 with 5 posts (3 thanks)
    2. looks_two Trader.Jon with 3 posts (0 thanks)
    3. looks_3 Laserdan with 2 posts (2 thanks)
    4. looks_4 Big Mike with 2 posts (2 thanks)
    1. trending_up 5,664 views
    2. thumb_up 7 thanks given
    3. group 6 followers
    1. forum 15 posts
    2. attach_file 1 attachments




 
Search this Thread

how to extract nearest support price from arraylist?

  #1 (permalink)
 
zacharydw00's Avatar
 zacharydw00 
Idaho
 
Experience: Intermediate
Platform: NinjaTrader,ToS
Broker: Amp Futures, ToS
Trading: ES, E7, CL, GC
Posts: 149 since Aug 2009
Thanks Given: 87
Thanks Received: 180

Does anyone have code that can do this, or something similar?

I have the prices of support/resistance (S/R) lines stored in an ArrayList. When price is moving up, I want to find the nearest S/R line, in said ArrayList, that is currently below the Close price, once price gets 1 point above the nearest S/R line. And, the opposite when price is moving down.
See attached image for illustration.
Thanks guys.

Attached Thumbnails
Click image for larger version

Name:	How To Find nearest SR price in array.jpg
Views:	259
Size:	61.5 KB
ID:	20966  
Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
NexusFi Journal Challenge - April 2024
Feedback and Announcements
Are there any eval firms that allow you to sink to your …
Traders Hideout
My NT8 Volume Profile Split by Asian/Euro/Open
NinjaTrader
Better Renko Gaps
The Elite Circle
ZombieSqueeze
Platforms and Indicators
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
61 thanks
Funded Trader platforms
39 thanks
NexusFi site changelog and issues/problem reporting
26 thanks
Battlestations: Show us your trading desks!
26 thanks
The Program
18 thanks
  #3 (permalink)
 
Trader.Jon's Avatar
 Trader.Jon 
Near the BEuTiFULL Horse Shoe
 
Experience: Beginner
Platform: NinjaTrader
Broker: MBTrading Dukascopy ZenFire
Trading: $EURUSD when it is trending
Posts: 473 since Jul 2009
Thanks Given: 401
Thanks Received: 184



zacharydw00 View Post
Does anyone have code that can do this, or something similar?

I have the prices of support/resistance (S/R) lines stored in an ArrayList. When price is moving up, I want to find the nearest S/R line that is currently below the Close price, and the opposite when price is moving down.
See attached image for illustration.
Thanks guys.

Not exactly what you asked, and it _might_ do if you dont have a resolution : Swing Gap Links and Downloads Manager - [AUTOLINK]NinjaTrader[/AUTOLINK] Support Forum

use the MostRecentOccurance ... I might have other thoughts after a nites sleep

TJ

Reply With Quote
  #4 (permalink)
 
zacharydw00's Avatar
 zacharydw00 
Idaho
 
Experience: Intermediate
Platform: NinjaTrader,ToS
Broker: Amp Futures, ToS
Trading: ES, E7, CL, GC
Posts: 149 since Aug 2009
Thanks Given: 87
Thanks Received: 180


Trader.Jon View Post
Not exactly what you asked, and it _might_ do if you dont have a resolution : Swing Gap Links and Downloads Manager - [AUTOLINK]NinjaTrader[/AUTOLINK] Support Forum
use the MostRecentOccurance ... I might have other thoughts after a nites sleep TJ

That's funny... sending me a link to my own modified code. LOL
The Swing ind. only stores the most recent occurance. I have an ArrayList, which may have up to 15 stored prices, that I need to look through.

Started this thread Reply With Quote
  #5 (permalink)
 
cory's Avatar
 cory 
virginia
 
Experience: Intermediate
Platform: ninja
Trading: NQ
Posts: 6,098 since Jun 2009
Thanks Given: 877
Thanks Received: 8,090

loop thru your array, for support look for smallest negative price - s/r value, for resis look for smallest positive price - s/r value.

Reply With Quote
  #6 (permalink)
 
zacharydw00's Avatar
 zacharydw00 
Idaho
 
Experience: Intermediate
Platform: NinjaTrader,ToS
Broker: Amp Futures, ToS
Trading: ES, E7, CL, GC
Posts: 149 since Aug 2009
Thanks Given: 87
Thanks Received: 180

Thanks cory. I get the concept. The details are another thing.

Any code givers... any one... any one... Bueller.... any body

Started this thread Reply With Quote
  #7 (permalink)
 
Trader.Jon's Avatar
 Trader.Jon 
Near the BEuTiFULL Horse Shoe
 
Experience: Beginner
Platform: NinjaTrader
Broker: MBTrading Dukascopy ZenFire
Trading: $EURUSD when it is trending
Posts: 473 since Jul 2009
Thanks Given: 401
Thanks Received: 184


zacharydw00 View Post
That's funny... sending me a link to my own modified code. LOL
The Swing ind. only stores the most recent occurance. I have an ArrayList, which may have up to 15 stored prices, that I need to look through.

MostRecentOccurence (MRO(SwingGap)[0]) ...MRO(SwingGap)[15] gets those values, me thinks

Reply With Quote
  #8 (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

In variables section declare a list object...they are more efficient than arrays and do not need to be initialized with a size. Or just use arrays, no matter. Methods are the same.

List<double>listSR = new List<double>();
privatedouble SRNextHigh = 0;
privatedouble SRNextLow = 0;


 
Code
protected void FindNextSR()
{
 
listSR.Sort();
for (int x = 0; x < listSR.Count; x++)
{
if (listSR[x] > Close[0])
{
SRNextHigh = listSR[x];
if (x != 0) SRNextLow = listSR[x - 1];
Print(SRNextHigh + " High   Close=" + Close[0] + "   Low " + SRNextLow);
break;
}
if (listSR[x] > Close[0]) SRNextLow = 0;
if (listSR[x] < Close[0]) SRNextHigh = 0;
}
}
This routine will go thru the list object and put the next supprt (SRNextLow) below the Close of the current bar, and the next resistance (SRNextHigh) above the current close

if there are no support values above, it sets SRNextHigh to 0
if there are no support values below, it sets SRNextLow to 0

items may be added to the List object using .add method

Hope this helps

PS. dont forget to add a ref to
using System.Collections.Generic;

Laserdan
Follow me on Twitter Reply With Quote
Thanked by:
  #9 (permalink)
 bukkan 
Calcutta, India
 
Experience: Intermediate
Platform: ArthaChitra
Posts: 278 since Jun 2009
Thanks Given: 161
Thanks Received: 271

most recent occurrence. wouldnt that be the last value of the List.

like

 
Code
 List<double>listSR = new List<double>();



 
Code
double SR = listSR[listSR.Count - 1];


Reply With Quote
  #10 (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


This way you don't need to worry about which way price is moving. The current bar close is always sandwiched between the two SR lines (one above and one below).


Laserdan View Post
In variables section declare a list object...they are more efficient than arrays and do not need to be initialized with a size. Or just use arrays, no matter. Methods are the same.

List<double>listSR = new List<double>();
privatedouble SRNextHigh = 0;
privatedouble SRNextLow = 0;


 
Code
protected void FindNextSR()
{
 
listSR.Sort();
for (int x = 0; x < listSR.Count; x++)
{
if (listSR[x] > Close[0])
{
SRNextHigh = listSR[x];
if (x != 0) SRNextLow = listSR[x - 1];
Print(SRNextHigh + " High   Close=" + Close[0] + "   Low " + SRNextLow);
break;
}
if (listSR[x] > Close[0]) SRNextLow = 0;
if (listSR[x] < Close[0]) SRNextHigh = 0;
}
}
This routine will go thru the list object and put the next supprt (SRNextLow) below the Close of the current bar, and the next resistance (SRNextHigh) above the current close

if there are no support values above, it sets SRNextHigh to 0
if there are no support values below, it sets SRNextLow to 0

items may be added to the List object using .add method

Hope this helps

PS. dont forget to add a ref to
using System.Collections.Generic;


Laserdan
Follow me on Twitter Reply With Quote
Thanked by:




Last Updated on January 1, 2012


© 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