Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Drawing arrow and text

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

    Drawing arrow and text

    Hello!

    I am trying to draw arrows and texts (name of the arrows) on the bars base on time and prices, not on barAgo.
    I am failing to have all arrows as well as the names of all these arrows. Sometimes I have the arrow without the name, sometimes I have none of them. With the code I have, I have backtested on a 5 minutes char and on a 2k ticks chart, but I am realizing that the result is worse on the 2k ticks chart. I have less arrows there, even when the conditions are fullfilled. On both timeframes, some arrows appears and the names of the bars are missing.
    I have also realized that the recurency of the arrow and the text related to "Hammer" is high. It is the only text and the only arrow working without problem.

    What could be the problem?

    I have following code:

    HTML Code:
    Draw.Text(this, "TextHarami", false, "BullHarami", Time[shift1], Low[shift1]- 8*TickSize, 0, Brushes.Lime, myFont, TextAlignment.Center, Brushes.Transparent, null, 1);
    Draw.ArrowUp(this, "arrowHarami"+CurrentBar, true, Time[shift1], Low[shift1] - 2*TickSize, Brushes.Lime);
    
    Draw.Text(this, "BullEngulf", false, "BullEngulf", Time[shift1], Low[shift1]- 8*TickSize, 0, Brushes.DodgerBlue, myFont, TextAlignment.Center, Brushes.Transparent, null, 1);
    Draw.ArrowUp(this, "arrowBullEngulf"+CurrentBar, true, Time[shift1], Low[shift1] - 2*TickSize, Brushes.DodgerBlue);
    
    Draw.Text(this, "Hammer", false, "Hammer", Time[shift1], Low[shift1]- 8*TickSize, 0, Brushes.OrangeRed, myFont, TextAlignment.Center, Brushes.Transparent, null, 1);
    Draw.ArrowUp(this, "arrowHammer"+CurrentBar, true, Time[shift1], Low[shift1] - 2*TickSize, Brushes.OrangeRed);​
    Thanks in advance!

    #2
    Hello Stanfillirenfro,

    Thanks for your post.

    Ultimately, if a script is not behaving as you expect it to then it is necessary to add debugging prints to the script to see exactly how the script is processing logic and drawing objects.

    Below is a link to a forum post that demonstrates how to use prints to understand behavior.

    https://ninjatrader.com/support/foru...121#post791121

    See the attached example script and screenshot demonstrating drawing an arrow and text using the Draw.Text() and Draw.ArrowUp() methods with a DateTime overload.

    And, see the help guide documentation below.

    Draw.Text(): https://ninjatrader.com/support/help.../draw_text.htm
    Draw.ArrowUp(): https://ninjatrader.com/support/help...aw_arrowup.htm

    Let me know if I may assist further.​
    Attached Files
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3
      Many thanks NinjaTrader_BrandonH for your help.
      I was thinking that "+CurrentBar" should be added only while drawing an arrow. Thanks!
      I am using the following print() function everytime an arrow has to be drawn, but in the output window of the print() function, I have only one name from the top to the bottom, that of BullEngulf.
      Even for "Hammer" for which the arrow and the name are ploted on the chart do not appear on the output window.
      The print() function does not help me localising the problem. I have to mention hat I have on the whole screen one arrow as well as its name on the chart, but not more. The code seems to be correct, but something is blocking other arrows to be drawn.

      Any further help?

      HTML Code:
      Print("BullEngulf" +  "BullEngulf" + " Time " + ":  " + Time[shift1]);
      Thanks in advance!

      Comment


        #4
        Hello Stanfillirenfro,

        Thanks for your note.

        In your Print statement, you are setting 2 strings for 'BullEngulf' so these strings will print to the Output window instead of 1 string, "BullEngulf", and the variable, BullEngulf.

        You would need to print out the BullEngulf variable instead of a string "BullEngulf". For example, the print might look something like this.

        Code:
        Print("BullEngulf" + BullEngulf + " Time " + Time[shift1]);
        Please see this help guide page about debugging a NinjaScript: https://ninjatrader.com/support/help...script_cod.htm

        I would also suggest thoroughly reviewing the forum thread linked in post # 2 which also talks about how to use prints to debug your script to determine how it is behaving.

        Let me know if I may assist further.
        <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

        Comment


          #5
          Many thanks NinjaTrader_BrandonH for your help.

          Having "BullEngulf" printed wtice was exppected. The first one is the name ("tag") and the second is the string variable (see attachement). The problem is not to have it printed twice, but that I do not have other names printed. I have at least three print() functions and I was expecting others names too to be printed.

          I think the problem should be the my code (for my indicator).
          I will go through it again more deeply.

          Thanks again.

          Attached Files

          Comment


            #6
            Hello Stanfillirenfro,

            Thanks for your note.

            To clarify, how are you calling the prints in your script?

            Are you calling the prints within a condition?

            If a print does not appear in the Output window then the condition to trigger the Print statement is likely not becoming true.

            In this case, you would need to add prints (outside the condition) that print the values of every variable used in the condition to see how that condition is evaluating.

            Let me know if I may assist further.
            <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

            Comment


              #7
              Many thanks NinjaTrader_BrandonH for your help.

              Yes I am caling the print functions in the conditions. The condition on "Hammer" ist working perfectly. For Engulf I have only one arrow. Nothing for others. I will go through my code again and check all. Meanwhile I will implement your advice on the print function. I will revert to you again.

              Thanks again.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              672 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              379 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              111 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              577 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              582 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X