thank you very much for the quick response.
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Draw a line forward
Collapse
X
-
Start by looking at this. You want to change the definition of LongSetup to be what you want to start the line.Originally posted by Tradexxx View Posthi pi,
pls. have in mind i'm newbee in creating a indicator.
after having read hundreds of threads / tutorial etc,. i walked through the indicator from arbuthnot.
-> it looks like he's using a kind of "counter" to extend the drawn line and i'm wondering if there's no easier way to do that. something like: draw a line untill it's broken by price?
-> i can't find any description how to use the counter?
-> everything starts with a "period" - why is this neccessary?
-> even if i change the period, the indicator isn't working in the right way - some highs are not recognised by the indicator.
perhaps you can assist me?
probably i have to change my mind...
(my additional question is the result of going two steps back and start in another way - but if there's no other way to create a horizontal line - it's invalid....)
thanks a lot
It might be instructive to read the whole (rather long) thread.
Comment
-
Thanks, Koganam, for pointing that out.Originally posted by koganam View Post
What's interesting with this (and many other indicator/coding queries) is to consider different solutions to the same question and trying to find which solution does the job most efficiently in terms, ultimately, of CPU time.
Cheers, Ed
Comment
-
hello together,
i'm trying to follow these things up - step by step.
first step: try to draw a line / ray etc....
result: indicator isn't drawing anything.
perhaps you can have a look at it?Attached Files
Comment
-
Because you refer to 1 bar ago, you have to add the following statement at the very first line of OnBarUpdate():Originally posted by Tradexxx View Posthello together,
i'm trying to follow these things up - step by step.
first step: try to draw a line / ray etc....
result: indicator isn't drawing anything.
perhaps you can have a look at it?
if (CurrentBar < 1) return;
Comment
-
hi pi,
i have seen it in the thread you forwarded yestarday - i used it - but: it's not working.Attached Files
Comment
-
You draw the line from 2 bars ago:Originally posted by Tradexxx View Posthi pi,
i have seen it in the thread you forwarded yestarday - i used it - but: it's not working.
So you must include this at the first line of OnBarUpdate():DrawLine ("Line",false, 2, High [0] , -5, High [0], Color.Blue,DashStyle.Solid, 3);
if (CurrentBar < 2) return;
Comment
-
ok - line is available. thank you!!
but: the line is only available on the last candles, and moves away if there are new candles with new conditions. (even if i fill in a period time / extend the current bar size)
that's different to the used wizzard indicator before. the code is simillar, but the result using the wizzard created indicator was that the lines were available everywhere were the conditions are fulfillt.
what have i done wrong?
Comment
-
Please use a unique tag for each line. For example:Originally posted by Tradexxx View Postok - line is available. thank you!!
but: the line is only available on the last candles, and moves away if there are new candles with new conditions. (even if i fill in a period time / extend the current bar size)
that's different to the used wizzard indicator before. the code is simillar, but the result using the wizzard created indicator was that the lines were available everywhere were the conditions are fulfillt.
what have i done wrong?
Declare outside OnBarUpdate():
int startBar;Cheers.if (condition happens) startBar = CurrentBar;
DrawLine("line" + startBar, ...);
Pi
Comment
-
As Ninza said, you need:
if (CurrentBar < 2) return;
I think something else needs to be added to the DrawLine statement. Every tag relating to a chart drawing must have a unique name, or nothing will be drawn. One of the usual ways of doing this is to add "+CurrentBar" to the tag, so in your case, the tags will have names: Line2, Line3, Line4, etc.
DrawLine ("Line"+CurrentBar,false, 2, High [0] , -5, High [0], Color.Blue,DashStyle.Solid, 3);
I checked, this now works!
If you can wait to the weekend, Trade, then I hopefully have time to explain the thinking behind my indicator. To achieve what you wanted (which is roughly what I did in my ind) needs a good degree of coding experience.
I'm sure Ninza agrees with me in thinking that it's great that you're experimenting and trying to learn as much as possible.
Comment
-
arbuthnot, it's great that we have such a helpful and passionate contributor like you here.Originally posted by arbuthnot View PostAs Ninza said, you need:
if (CurrentBar < 2) return;
I think something else needs to be added to the DrawLine statement. Every tag relating to a chart drawing must have a unique name, or nothing will be drawn. One of the usual ways of doing this is to add "+CurrentBar" to the tag, so in your case, the tags will have names: Line2, Line3, Line4, etc.
DrawLine ("Line"+CurrentBar,false, 2, High [0] , -5, High [0], Color.Blue,DashStyle.Solid, 3);
I checked, this now works!
If you can wait to the weekend, Trade, then I hopefully have time to explain the thinking behind my indicator. To achieve what you wanted (which is roughly what I did in my ind) needs a good degree of coding experience.
I'm sure Ninza agrees with me in thinking that it's great that you're experimenting and trying to learn as much as possible.
Thank you.
Comment
-
hi pi, hi ed,
i'm very thankful for your assitance. it's great!
i tried both version - and: they're working :-)
as the weekend isn't that far away - i'll experiment further and i'm sure, i'll have some additonal questions
again: thank you both very much !!
Comment
-
You are welcome.Originally posted by Tradexxx View Posthi pi, hi ed,
i'm very thankful for your assitance. it's great!
i tried both version - and: they're working :-)
as the weekend isn't that far away - i'll experiment further and i'm sure, i'll have some additonal questions
again: thank you both very much !!
You will become an experienced coder in 3 months
Comment
-
Hi Trade
Just worked out the problem!
1) you have a semi-colon after the if statement:
if(High [0] > High [1]) ;
Remove the ';'
semi-colons are only placed after 'actions'.
2) The Properties section should be empty as you haven't added any plots in Initialize()
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
574 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
332 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
101 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
553 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
551 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment