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,861 / 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

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

Counter crossing the horizontal line

Hello All. I have a indicator on easylanguage. I want to implement it on ninjasript. In the picture of his project.

Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).


 
Code
input: count(3);
var: x(0), oldest(0), recycle(0), size(99);
array: id[99,3](0);  // 0=id, 1=price, 2=count, 3=age

once for x=0 to size begin
    id[x,0]=tl_new(d,t,0,d,t,0);
end;

if barstatus(1)=2 then begin
    oldest=0;
    for x=0 to size begin
        if L<=id[x,1] and H>=id[x,1] then begin
            id[x,2]=id[x,2]+1;
            if id[x,2]=count then begin
                id[x,1]=0;  id[x,2]=0;  id[x,3]=9999999;  tl_setend(id[x,0],d,t,0);  tl_setbegin(id[x,0],d,t,0);  // reset price, count and age
            end;
        end;
        if id[x,1]>0 then tl_setend(id[x,0],d,t,id[x,1]);
        id[x,3]=id[x,3]+1;
        if id[x,3]>oldest then begin
            oldest=id[x,3];  recycle=x;
        end;
    end;
    id[recycle,1]=c;  id[recycle,2]=0;  id[recycle,3]=0;  tl_setend(id[recycle,0],d,t,c);  tl_setbegin(id[recycle,0],d,t,c);
end;
He draws a horizontal line on the closing price of each bar. The horizontal line is displayed until it intersects the price of a certain number of times.

First, I tried to display a horizontal line at each price:
 
Code
for (int i=1; i<777; i++)
			{
				
				DrawHorizontalLine("tag1"+CurrentBar,Close[i], Color.Red);
			}
I could not get.

Please advise how I can do it, and how to work with the horizontal line tag, to appeal to her?

Thank.


Last edited by doitagaitforme; May 2nd, 2012 at 05:43 AM. Reason: missed the expression
Reply With Quote
 
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

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


At the moment my brain was able to generate the code. It compiles, but does not bring results, draws only one line. Maybe I need another array of lines? I will be happy with any prompts.

 
Code
protected override void OnBarUpdate()
        {

        int[] count=new int[5000];
        DrawHorizontalLine("tag1"+CurrentBar,Close[0], Color.Red);
        for (int i=0; i<5000; i++)
            {
                
                if ((Close[0]<=High[i]) || (Close[0]>=Low[i]))
                {
                    count[CurrentBar]=count[CurrentBar]++;
                    if (count[CurrentBar] == 3)
                    {
                        RemoveDrawObject("tag1"+CurrentBar);
                    }
                }
                
                
                
            }
            
        }


Last edited by doitagaitforme; May 2nd, 2012 at 05:16 AM.
Reply With Quote
 
  #4 (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,220 received


doitagaitforme View Post
Hello All. I have a indicator on easylanguage. I want to implement it on thinkstsript.

Do you mean NinjaScript for NinjaTrader? Or Thinkscript for ThinkOrSwim?

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
 
  #5 (permalink)
Elite Member
Rostov-na-Donu/ Russia
 
Futures Experience: Beginner
Platform: Metatrader
 
Posts: 15 since Jul 2010
Thanks: 7 given, 1 received


Big Mike View Post
Do you mean NinjaScript for NinjaTrader? Or Thinkscript for ThinkOrSwim?

Mike

I'm sorry, did not notice. Ninjascript.

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


doitagaitforme View Post
At the moment my brain was able to generate the code. It compiles, but does not bring results, draws only one line. Maybe I need another array of lines? I will be happy with any prompts.

It draws one line because you are erasing it with RemoveDrawObject.

DrawHorizontalLine draws a line extended to infinity in both left and right directions. It looks to me like you want to draw a finite line that stops after some number of price intersections.

I'd do something like this. In region "Using declarations" at the top, add
using System.Collections.Generic; // add array list capability

Then create an array list to store your lines:
 
Code
                            
#region Using declarations
using System.Collections.Generic// add array list capability
#endregion

...

private 
struct linedata {
   public 
string id;
   public 
int countstartbar;
   public 
double value;
}
private List<
linedatalines;

protected 
override void Initialize() {
    
lines = new List<linedata>();
    
CalculateOnBarClose true;
}

protected 
override void OnBarUpdate() {
   if (
CurrentBar == 0) return;
   
linedata ld = new linedata();
   
ld.id "ln"+CurrentBar.ToString();
   
ld.startbar CurrentBar-1;
   
ld.value Close[1];
   
ld.count 0;
   
lines.Add(ld);
   foreach(
linedata d in lines) {
      if (
d.value >= Low[0] && d.value <= High[0])
         ++
d.count;
      if (
d.count <= 3)
         
DrawLine(d.idCurrentBar-d.startbard.value0d.valueColor.RedDashStyle.Solid1);
      else
         
lines.RemoveAll(d); // don't need to track this line anymore
   
}

Warning, the above is from my head, untested. But it should give you an idea how to proceed.
-A


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

Thank you anachronist, I've seen is just the tip of the iceberg, now I need a thick book.

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

You don't need a thick book. Whenever I have a C# question, I just Google it, and most often I end up reading pages on Microsoft's online library. The List class is documented here, for example. A List in C# is simply an array of any data type; in the code above I made up a custom struct to hold data about each horizontal line, and created a List array of them. An array implemented as a List has variable length controlled by the Add() and Remove() methods. You can get the number of array elements at any time using the Count() method, and you can access elements in the array as a[0], a[1], etc. just like a conventional array.

-Alex

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

anachronist, I tried to compile your code from all the mistakes I do not understand only one: when referring to linedata.value CS0122 is inaccessible due to its protection level, the rest will deal less. Or maybe advise me what is the documentation of: protection level.

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


Eh, sorry about that. The word "public" must precede the declaration of "double value" in the struct definition. I'll correct it in my reply above. I think everything defaults to "private" in C# unless you explicitly declare it otherwise.

(Private properties in structs make no sense at all, so the default makes no sense, but that's a philosophical topic best discussed in another forum.)
-A

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)

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
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 08: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-12 in 0.11 seconds with 19 queries on phoenix via your IP 54.234.255.29