Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Indicator Develpoment or Strategy Builder?

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

    Indicator Develpoment or Strategy Builder?

    If I say,

    if(Close[2] > Open[2] && High[1] < High[2] && Close[1] < Open[1] && Close[0] < Open[0] && != Draw.Line)

    Have it draw a red line at the close of bar.

    Would I have to do this in strategy Builder, or can I make this happen in the Indicator Development?
    I just want lines drawn in the right conditions as a reminder to myself that it might be a trade I could take.
    Not to trigger trades, I do that.
    Attached Files

    #2
    Hello trdninstyle,

    Thank you for your post.

    You could achieve this in both ways - it is possible in the Strategy Builder as well as being possible from an indicator script. With either approach, you would need a bool variable that is false when the line has not been drawn and then you can set it to true when the line is drawn. Here is an example from the Strategy Builder page, and the logic from the "View Code" button could even be copied and pasted into an indicator's script.

    World's leading screen capture + recorder from Snagit + Screencast by Techsmith. Capture, edit and share professional-quality content seamlessly.


    View Code: https://www.screencast.com/t/1mxh1ZyocUK & https://www.screencast.com/t/ZmC4RcYxhQxl

    This is an example of Strategy Builder generated code that could also be used in an indicator script:
    if ((Close[2] > Open[2]) && (High[1] < High[2]) && (Close[1] < Open[1]) && (LineDrawn != true))
    {
    Draw.Line(this, @"MyCustomStrategy Line_1", false, 2, Close[2], 0, Close[0], Brushes.CornflowerBlue, DashStyleHelper.Solid, 2);
    }

    Please let us know if we may be of further assistance.​

    Comment


      #3
      This is truly truly helpful Emily and especially the screenshots! I guess I know what I'm doing tonight, working on this.

      Much much appreciated, thank you.

      Comment


        #4
        Okay, I guess not quite a walk in the park as I first thought it would be. I had a couple of hiccups here and there, but not too bad tho.. hopefully we can smooth this thing out.

        Here's a peak at my progress...
        Attached Files
        Last edited by trdninstyle; 10-11-2022, 06:39 PM.

        Comment


          #5
          I read over post Forum and noticed that you did put the script for me to copy/paste, so I went and did that.

          Just one thing came up.
          Attached Files

          Comment


            #6
            You created the bool as Linedrawn and you are using LineDrawn. These are not the same thing, use what you declared, Linedrawn.

            Comment


              #7
              Hello trdinstyle,

              Thank you for your note.

              As Tasker-182 has mentioned, it appears that there is a slight difference in capitalization. You will need to match the same capitalization in both areas, so you will have to adjust the variable in line 30 to be LineDrawn or adjust line 71 to be Linedrawn.

              Please feel free to reach out with any additional questions or concerns.

              Comment


                #8
                Hello Emily, matching the capitulation got it to compile. With your explanation I knew exactly what to do it wasn't lost on me.

                Okay, I adjusted the line it did draw from bar[2] & ended at bar[0] at a slant. I got it to be horizontal from bar[0] but it goes back towards bar [2] encompassing the three bars involved. I just want to flip the line to extend out instead of backwards.

                It's working pretty well though, I've had some more signals. How can I have the lines stay? So, I can review at end of day.
                Attached Files

                Comment


                  #9
                  Hello trdninstyle,

                  Thank you for your reply.

                  If you are looking to have a line drawn from the current bar and then have the line extend into the future, you would need to use an overload for Draw.Line that uses StartTime and EndTime rather than the barsAgo index. The different overloads are listed in the help guide page for Draw.Line, and you can also use the intelliprompt to guide you when writing the code:



                  If you want the lines to stay on your chart, then each line will need a unique tag. To do so, you could add the CurrentBar index to the tag. For example, rather than the tag being "BuySellTheClose" you could add the CurrentBar like this: "BuySellTheClose" + CurrentBar.ToString()

                  Please let us know if we may be of further assistance.

                  Comment


                    #10
                    Do you mean to place this.. "BuySellTheClose" + CurrentBar.ToString()

                    In where the blue wording is? "BuySellTheClose"

                    I'll go just one step at a time, get this part right first then I'll tackle the other part. Thanks for your patience.
                    Attached Files

                    Comment


                      #11
                      Originally posted by trdninstyle View Post
                      Do you mean to place this.. "BuySellTheClose" + CurrentBar.ToString()

                      In where the blue wording is? "BuySellTheClose"

                      I'll go just one step at a time, get this part right first then I'll tackle the other part. Thanks for your patience.
                      Hello trdinstyle,

                      Yes, that is correct.

                      If you append the CurrentBar as shown in your screenshot, you should be able to compile and reload NinjaScript on your chart (or add a new instance of the indicator) to see the difference. Each line will now have a unique tag, so the previous lines remain on your chart rather than the script re-drawing the same line with the same tag multiple times.

                      Thank you for your patience.

                      Comment


                        #12
                        Wow, it was that easy. No way! Thank You for your patience. By far.

                        They are definitely staying now. That 2nd setup was just a basic thing I came up with quick just to gain experience.
                        Last two pics are on moving the lines to the right, a time thing.

                        I'm sure that I'm making it harder than it is.

                        Attached Files

                        Comment


                          #13
                          Hello trdinstyle,

                          Thanks for the update.

                          I am glad to hear you were able to update the tag to get the lines to stay on your chart. To address your question about whether both conditions will happen, as you currently have it per your screenshot both Set 1 and Set 2 could be triggered. There is no need to add an additional condition or 'else' in between.

                          As far as drawing lines into the future, for your purposes I realized that using a negative barsAgo index should actually be more convenient than using a startTime and endTime. With that in mind, you could try the following in Set 1 to draw a line into the future:

                          if ((Close[2] > Open[2]) && {High[1] < High[2]) && (Close[1] < Open[1]))
                          {
                          Draw.Line(this, "BuySellTheClose" + CurrentBar.ToString(), 0, Close[0], -3, Close[0], Brushes.DarkRed);
                          }

                          If you notice, I removed the (LineDrawn != true) part of the condition. This is not needed unless you plan to toggle LineDrawn between true/false with other conditions to enable/disable the line being drawn. Based on your screenshots and descriptions, this does not seem to be your plan which means the LineDrawn variable is extra.
                          What I did in this example is I used 0 for the startBarsAgo and -3 for the endBarsAgo. This means the line will start at the current bar where the condition is triggered, and it will end at -3 barsAgo which is three bars into the future.

                          I hope this is helpful information. Please don't hesitate to respond with any other questions.

                          Comment


                            #14
                            Yes, I like that and just go -3 days ago, actually I put -5 to draw it out further. I did the same for set 2 but I must of did something wrong. Its only showing the last one.

                            You can answer back tomorrow if it's the end of the day.

                            I saw what I did. The " " in the wrong spot.

                            Draw.Line(this, "BuySellTheClose" + CurrentBar.ToString(), 0, Close[0], -5, Close[0], Brushes.DarkRed);

                            Thank you, get out of the office now u already worked too hard today.
                            Attached Files
                            Last edited by trdninstyle; 10-12-2022, 03:45 PM.

                            Comment


                              #15
                              How are u today? I got a little dangerous with these setups it looks more real world now. I went from a Line to a Rectangle.
                              I was wondering, how would I make the rectangles just a little wider? Like opened up. And about a 50% opacity?

                              I'll show u my intent of what I want to do. I have to go get a screenshot.
                              Attached Files

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              648 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              369 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              108 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              572 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              574 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X