Counter crossing the horizontal line - NinjaTrader Programming | futures io social day trading
futures io futures trading


Counter crossing the horizontal line
Updated: Views / Replies:1,864 / 12
Created: by doitagaitforme Attachments:0

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
 
Thread Tools Search this Thread
 

Counter crossing the horizontal line

  #11 (permalink)
Elite Member
Rostov-na-Donu/ Russia
 
Futures Experience: Beginner
Platform: Metatrader
 
Posts: 15 since Jul 2010
Thanks: 7 given, 1 received

Hi anachronist. At this point, your code I transformed as follows:

 
Code
 protected override void OnBarUpdate()
        {
        
			if (CurrentBar == 0) return;
   			linedata ld = new linedata();
   			ld.id = "ld"+CurrentBar.ToString();
   			ld.startbar = CurrentBar-1;
   			ld.value = Close[1];
   			ld.count = 0;
   			lines.Add(ld);
   			foreach(linedata id in lines) {
      		        if (ld.value >= Low[0] && ld.value <= High[0])
         	       ++ld.count;
      		       if (ld.count <= 3)
         	
			DrawLine(ld.id, false, CurrentBar-ld.startbar, ld.value, -90000, ld.value, Color.Red, DashStyle.Solid, 1);
     			 else
         			lines.RemoveAll(ld); // don't need to track this line anymore 
				
					
   }

I can not understand what the problem is the last line after "else" (CS1502 and CS1503). I tried to replace lines.RemoveAll(ld) in lines.Remove(ld). The indicator is compiled, but when you add the indicator ninja crash.

I have it compiled without any conditions "else". The lines ended on the next bar. So I changed to zero -90 000, so they went further to the right.


Last edited by doitagaitforme; May 3rd, 2012 at 09:18 AM.
Reply With Quote
 
  #12 (permalink)
Elite Member
San Jose, CA
 
Futures Experience: Advanced
Platform: NinjaTrader
Favorite Futures: all
 
anachronist's Avatar
 
Posts: 27 since Apr 2012
Thanks: 0 given, 16 received

OK, here's what I came up with, now that I got a chance to test it myself.

Warning, if you try to run this on too much data, NinjaTrader will appear to freeze up, because it adds a new line on every single bar (each new close). I'd keep it under 1000 bars.
 
Code
                            
#region Using declarations
// add this
using System.Collections.Generic// needed for List class
#endregion

//...

        #region Variables
        // parameters
        
private int maxcount 3// Default setting for Count
        // other
        
private class linedata {
            public 
string id;
            public 
int countstartbar;
            public 
double value;
            public 
linedata(int currentbardouble val) {
                
id "ln"+currentbar.ToString();
                
startbar currentbar 1;
                
value val;
                
count 0;
            }
        }
        private List<
linedatalinesto_remove;
        
#endregion

        /// <summary>
        /// This method is used to configure the indicator and is called once before any bar data is loaded.
        /// </summary>
        
protected override void Initialize()
        {
            
lines = new List<linedata>();
            
to_remove = new List<linedata>();
            
Overlay true;
            
CalculateOnBarClose true;
        }

        
/// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        
protected override void OnBarUpdate()
        {
            if (
CurrentBar == 0) return;
            
lines.Add(new linedata(CurrentBarClose[1]));
            
to_remove.Clear();
            foreach(
linedata d in lines) {
                if (
d.value >= Low[0] && d.value <= High[0])
                    ++
d.count;
                if (
d.count <= maxcount)
                    
DrawLine(d.idfalseCurrentBar-d.startbard.value0d.valueColor.RedDashStyle.Solid1);
                if (
d.count >= maxcount// we can stop extending this line
                    
to_remove.Add(d);    // add line to removal queue
            
}
            foreach(
linedata d in to_remove// empty the removal queue
                
lines.Remove(d);
        } 
I suspected that there might be a problem with removing elements from a list during a loop traversing that same list, so instead I collected the elements to remove in another list for cleanup outside the first loop.

And here's a picture:
Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).


Last edited by anachronist; May 3rd, 2012 at 07:43 PM.
Reply With Quote
The following 3 users say Thank You to anachronist for this post:
 
  #13 (permalink)
Elite Member
Rostov-na-Donu/ Russia
 
Futures Experience: Beginner
Platform: Metatrader
 
Posts: 15 since Jul 2010
Thanks: 7 given, 1 received


but will arrive with you the eternal profit

Reply With Quote

Reply



futures io > > > > > Counter crossing the horizontal line

Thread Tools Search this Thread
Search this Thread:

Advanced Search



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

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Where did Horizontal Price Line Indie Go? tdaman NinjaTrader 12 January 5th, 2012 02:29 PM
Extend horizontal line plot pr0crast ThinkOrSwim Programming 2 March 28th, 2011 10:42 PM
Drawing horizontal line wiithout changing grid distance. komalsid NinjaTrader 4 December 27th, 2010 03:50 PM
can you get a horizontal line at the current high of the volume indicator anniebee321 NinjaTrader 4 December 10th, 2010 06:18 PM
Horizontal line with text vast NinjaTrader Programming 2 February 4th, 2010 04:46 PM


All times are GMT -4. The time now is 04:10 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-15 in 0.08 seconds with 19 queries on phoenix via your IP 54.90.92.204