how to extract nearest support price from arraylist? - NinjaTrader Programming | futures io social day trading
futures io futures trading


how to extract nearest support price from arraylist?
Updated: Views / Replies:3,033 / 15
Created: by zacharydw00 Attachments:1

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 1  
 
Thread Tools Search this Thread
 

how to extract nearest support price from arraylist?

  #11 (permalink)
Site Administrator
Manta, Ecuador
 
Futures Experience: Advanced
Platform: My own custom solution
Favorite Futures: E-mini ES S&P 500
 
Big Mike's Avatar
 
Posts: 46,238 since Jun 2009
Thanks: 29,350 given, 83,217 received


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, 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.

A very long time ago I wrote a strategy to trade Murrey Math lines, and I wrote some functions to get all the levels. I'm willing to share the strategy, but only for elite members (which this thread is not). Can be easily adapted to Pivots.

Here is the thread:
https://futures.io/elite-group-trading-methods/5701-murrey-math-automated-strategy-ninjatrader.html

Mike

Due to time constraints, please do not PM me if your question can be resolved or answered on the forum.

Need help?
1) Stop changing things. No new indicators, charts, or methods. Be consistent with what is in front of you first.
2) Start a journal and post to it daily with the trades you made to show your strengths and weaknesses.
3) Set goals for yourself to reach daily. Make them about how you trade, not how much money you make.
4) Accept responsibility for your actions. Stop looking elsewhere to explain away poor performance.
5) Where to start as a trader? Watch this webinar and read this thread for hundreds of questions and answers.
6)
Help using the forum? Watch this video to learn general tips on using the site.

If you want
to support our community, become an Elite Member.

Reply With Quote
The following 2 users say Thank You to Big Mike for this post:
 
  #12 (permalink)
Elite Member
Idaho
 
Futures Experience: Intermediate
Platform: NinjaTrader,ToS
Broker/Data: Amp Futures, ToS
Favorite Futures: ES, E7, CL, GC
 
zacharydw00's Avatar
 
Posts: 139 since Aug 2009
Thanks: 81 given, 164 received

Got It

Here's the code I ended up with. (including all the debugging Print statements & a Plot statement)
price is typically going to be Close[0]
srOffset is how far price need to be away from any S/R lines. IE. if there is an S/R at 90 & 100, the trend is up, and you want price to confirm above 110 before using S/R @ 100 then set srOffset = 10, when price gets to 100, 90 will be returned.
Trend = true for up trend, false for down trend.
srList hold the list of S/R line values.
 
Code
        private double FindSRline(double price, double srOffset, bool Trend, ArrayList srList)
        {
            srNearest = 0;
            if (Trend)        // UP Trend
            {                        //Print (Time[0].ToString()+" \tCurrentBar =  "+CurrentBar+"\tTrend  = UP  \tsrListCnt  = "+(srList.Count));
                for (i=0; i < srList.Count; i++)                            // Search from Lowest price in srList
                {                    //Print ("srList["+i+"]+1  = "+Math.Round((double)srList[i]+srOffset,2).ToString("0000.00")+"   \tprice  = "+price.ToString("0000.00"));
                    if (price >= (double)srList[i]+srOffset)                // Find Close above SRline+offset
                    {     srNearest = (double)srList[i];        }
                    else 
                    {                //Print ("break; srNearest = srList["+(i)+"]  = "+srNearest.ToString("0000.00"));
                         break;                                             // Stop if price is below SRline+offset
                    }
                }
//                if (srNearest > 0)     Values[srListMax].Set(srNearest);                    // Plot srNearest for TESTING
            }
            else        // DOWN Trend
            {                        //Print (Time[0].ToString()+" \tCurrentBar =  "+CurrentBar+"\tTrend  = DOWN  \tsrListCnt  = "+(srList.Count));
                for (i=srList.Count-1; i >= 0; i--)                            // Search from Highest price in srList
                {                    //Print ("srList["+i+"]+1  = "+Math.Round((double)srList[i]+srOffset,2).ToString("0000.00")+"   \tprice  = "+price.ToString("0000.00"));
                    if (price <= (double)srList[i]-srOffset)                // Find Close below SRline-offset
                    {     srNearest = (double)srList[i];        }
                    else 
                    {                //Print ("break; srNearest = srList["+(i)+"]  = "+srNearest.ToString("0000.00"));
                         break;                                             // Stop if price is above SRline-offset
                    }
                }
//                if (srNearest > 0)     Values[srPlot].Set(srNearest);                    // Plot srNearest for TESTING
            }
//Print ("srNearest = srList["+i+"]  = "+srNearest.ToString("0000.00"));
                
            return srNearest ;
        }
Thanks for the suggestions guys.

Milk-a-What?
Reply With Quote
The following 2 users say Thank You to zacharydw00 for this post:
 
  #13 (permalink)
Elite Member
Near the BEuTiFULL Horse Shoe
 
Futures Experience: Beginner
Platform: NinjaTrader
Broker/Data: MBTrading Dukascopy ZenFire
Favorite Futures: $EURUSD when it is trending
 
Trader.Jon's Avatar
 
Posts: 500 since Jul 2009
Thanks: 401 given, 176 received

L@@Ks interesting


Would you please expand a little on srlist, how you formulate that?

I am curious on how you determine trend for this.

Thanks for this code, it definitely will be studied for use!

Jon

Reply With Quote
 
  #14 (permalink)
Elite Member
Idaho
 
Futures Experience: Intermediate
Platform: NinjaTrader,ToS
Broker/Data: Amp Futures, ToS
Favorite Futures: ES, E7, CL, GC
 
zacharydw00's Avatar
 
Posts: 139 since Aug 2009
Thanks: 81 given, 164 received


Trader.Jon View Post
1) Would you please expand a little on srlist, how you formulate that?
2) I am curious on how you determine trend for this.
Thanks for this code, it definitely will be studied for use!
Jon

1) srList is an "array" (specifically an ArrayList, Google it) that stores all the s/r (Support/Resistance) price values. It's up to you to determine these values and store them in an ArrayList. As a side note. Static values would be horizontal s/r lines. If you want to use dynamic s/r lines, such as a 200, 100, & 50 SMA for s/r, then you would have to update the srList array on every bar.

2} Trend could be determined by the slope of an MA, LinRegSlope ind., DM ind., or whatever your favorite sloping indicator is. If the slope is up then Trend would equal true.

Good Luck.

Milk-a-What?
Reply With Quote
The following user says Thank You to zacharydw00 for this post:
 
  #15 (permalink)
Trading Apprentice
Maharashtra,INDIA
 
Futures Experience: Beginner
Platform: Amibroker
Favorite Futures: Equties,Gold
 
Posts: 3 since Aug 2010
Thanks: 8 given, 1 received


Laserdan View Post
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).

Hello senior members,
can we code the above function into amibroker ?.
i.e=
my value=300;
h1=310,h2=320,h3=325,h4=312,h5=318......
out of h1,h2,h3 i want to find out which value is nearest to my value i.e 300
Thank you

Reply With Quote
 
  #16 (permalink)
Site Administrator
Manta, Ecuador
 
Futures Experience: Advanced
Platform: My own custom solution
Favorite Futures: E-mini ES S&P 500
 
Big Mike's Avatar
 
Posts: 46,238 since Jun 2009
Thanks: 29,350 given, 83,217 received


dar17 View Post
Hello senior members,
can we code the above function into amibroker ?.
i.e=
my value=300;
h1=310,h2=320,h3=325,h4=312,h5=318......
out of h1,h2,h3 i want to find out which value is nearest to my value i.e 300
Thank you

You need to ask in the Amibroker section of the forum:
AmiBroker - Big Mike's Trading Forum

Unfortunately, not many participants there. Please ask your Amibroker friends to come join us and start sharing. You should also share what you have.

Mike

Due to time constraints, please do not PM me if your question can be resolved or answered on the forum.

Need help?
1) Stop changing things. No new indicators, charts, or methods. Be consistent with what is in front of you first.
2) Start a journal and post to it daily with the trades you made to show your strengths and weaknesses.
3) Set goals for yourself to reach daily. Make them about how you trade, not how much money you make.
4) Accept responsibility for your actions. Stop looking elsewhere to explain away poor performance.
5) Where to start as a trader? Watch this webinar and read this thread for hundreds of questions and answers.
6)
Help using the forum? Watch this video to learn general tips on using the site.

If you want
to support our community, become an Elite Member.

Reply With Quote

Reply



futures io > > > > > how to extract nearest support price from arraylist?

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Linda Bradford Raschke: Reading The Tape

Elite only

Adam Grimes: TBA

Elite only

NinjaTrader: TBA

January

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Alert as price crosses resistance and support... Houston Jr NinjaTrader Programming 7 July 23rd, 2011 01:07 PM
Settlement Price vs. Closing Price srgtroy The Elite Circle 3 June 26th, 2011 02:15 AM
I'm trying to print the values from an ArrayList kaywai NinjaTrader Programming 13 May 13th, 2011 10:33 AM
What's better, Price alone, or Price + Volume Profiling? josh Traders Hideout 14 March 11th, 2011 10:51 PM
Keepin' It Simple: Support and Resistance, Volume, Price Action pmccandless Traders Hideout 11 April 16th, 2010 08:05 PM


All times are GMT -4. The time now is 05:01 PM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts
Page generated 2017-12-11 in 0.10 seconds with 20 queries on phoenix via your IP 54.226.132.197