Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Draw a line forward

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #16
    Pi, Ed,
    thank you very much for the quick response.

    Comment


      #17
      Originally posted by Tradexxx View Post
      hi 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
      Start by looking at this. You want to change the definition of LongSetup to be what you want to start the line.



      It might be instructive to read the whole (rather long) thread.

      Comment


        #18
        Originally posted by koganam View Post
        Start by looking at this. You want to change the definition of LongSetup to be what you want to start the line.



        It might be instructive to read the whole (rather long) thread.
        Thanks, Koganam, for pointing that out.

        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


          #19
          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


            #20
            Originally posted by Tradexxx View Post
            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?
            Because you refer to 1 bar ago, you have to add the following statement at the very first line of OnBarUpdate():

            if (CurrentBar < 1) return;
            ninZa
            NinjaTrader Ecosystem Vendor - ninZa.co

            Comment


              #21
              hi pi,

              i have seen it in the thread you forwarded yestarday - i used it - but: it's not working.
              Attached Files

              Comment


                #22
                Originally posted by Tradexxx View Post
                hi pi,

                i have seen it in the thread you forwarded yestarday - i used it - but: it's not working.
                You draw the line from 2 bars ago:

                DrawLine ("Line",false, 2, High [0] , -5, High [0], Color.Blue,DashStyle.Solid, 3);
                So you must include this at the first line of OnBarUpdate():

                if (CurrentBar < 2) return;
                ninZa
                NinjaTrader Ecosystem Vendor - ninZa.co

                Comment


                  #23
                  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


                    #24
                    Originally posted by Tradexxx View Post
                    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?
                    Please use a unique tag for each line. For example:

                    Declare outside OnBarUpdate():

                    int startBar;
                    if (condition happens) startBar = CurrentBar;
                    DrawLine("line" + startBar, ...);
                    Cheers.
                    Pi
                    ninZa
                    NinjaTrader Ecosystem Vendor - ninZa.co

                    Comment


                      #25
                      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


                        #26
                        Originally posted by arbuthnot View Post
                        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.
                        arbuthnot, it's great that we have such a helpful and passionate contributor like you here.

                        Thank you.
                        ninZa
                        NinjaTrader Ecosystem Vendor - ninZa.co

                        Comment


                          #27
                          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


                            #28
                            Originally posted by Tradexxx View Post
                            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 !!
                            You are welcome.
                            You will become an experienced coder in 3 months
                            ninZa
                            NinjaTrader Ecosystem Vendor - ninZa.co

                            Comment


                              #29
                              mhhhhh, i thought the condition is clear: H0 < H1, but he's still drawing on any candle..?
                              (pls. see the red arrows)
                              Attached Files
                              Last edited by Tradexxx; 02-26-2015, 09:00 AM.

                              Comment


                                #30
                                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
                                581 views
                                0 likes
                                Last Post Geovanny Suaza  
                                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                                0 responses
                                338 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by Mindset, 02-09-2026, 11:44 AM
                                0 responses
                                103 views
                                0 likes
                                Last Post Mindset
                                by Mindset
                                 
                                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                                0 responses
                                554 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by RFrosty, 01-28-2026, 06:49 PM
                                0 responses
                                552 views
                                1 like
                                Last Post RFrosty
                                by RFrosty
                                 
                                Working...
                                X