Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

DrawText on CurrentOHL

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

    DrawText on CurrentOHL

    i'm trying to draw some text at the current OHL values. please take a look at the code (bold) and advise. thx!

    Code:
    currentHigh  =  Math.Max(currentHigh, High[0]);
       currentLow  =  Math.Min(currentLow, Low[0]);
       if (ShowOpen)
       {
        if (!PlotCurrentValue || !sameDay)
         CurrentOpen.Set(currentOpen);
        else
         for (int idx = 0; idx < CurrentOpen.Count; idx++)
          CurrentOpen.Set(idx, currentOpen);
       }
       if (ShowHigh)
       {
        if (!PlotCurrentValue || currentHigh != High[0])
         CurrentHigh.Set(currentHigh);
    //[B]i think the text should go here but it will not compile[/B]
     
     
        else
         for (int idx = 0; idx < CurrentHigh.Count; idx++)
          CurrentHigh.Set(idx, currentHigh);
         //DrawDot("MyDot", true, -2, High[0] + 2 * TickSize, Color.Blue);
         [B]DrawText("MyText", "Current High", 0, High[0] + 2 * TickSize, Color.Blue);[/B]
        //[B]it works here but plots at current bar and not the high of current day[/B]   
    }
       if (ShowLow)
       {
        if (!PlotCurrentValue || currentLow != Low[0])
         CurrentLow.Set(currentLow);
        else
         for (int idx = 0; idx < CurrentLow.Count; idx++)
          CurrentLow.Set(idx, currentLow);
       }
     
       currentDate  =  Bars.GetTradingDayFromLocal(Time[0]); 
            }

    #2
    Hello,

    When you dont give a drawing object a new name. Instead of drawing a new dot or text. It modifies the current named one already on the chart.

    To create a new text object you have to use a new name. A common way to do this is seen below:

    DrawText("MyText" + CurrentBar, "Current High", 0, High[0] + 2 * TickSize, Color.Blue);
    //it works here but plots at current bar and not the high of current day

    Let me know if I can be of further assistance.

    Comment


      #3
      where would the DrawText go?

      Hi Brett,

      hmmm. i think i made an error. what i was referring to was to DrawText on the "Current Day High" the same way the indicator "CurrentDayOHL" plots lines.

      i just wanted to add some text at those levels
      hope that clears and thx!

      Originally posted by duck_CA View Post
      i'm trying to draw some text at the current OHL values. please take a look at the code (bold) and advise. thx!

      Code:
      currentHigh  =  Math.Max(currentHigh, High[0]);
         currentLow  =  Math.Min(currentLow, Low[0]);
         if (ShowOpen)
         {
          if (!PlotCurrentValue || !sameDay)
           CurrentOpen.Set(currentOpen);
          else
           for (int idx = 0; idx < CurrentOpen.Count; idx++)
            CurrentOpen.Set(idx, currentOpen);
         }
         if (ShowHigh)
         {
          if (!PlotCurrentValue || currentHigh != High[0])
           CurrentHigh.Set(currentHigh);
      //[B]i think the text should go here but it will not compile[/B]
       
       
          else
           for (int idx = 0; idx < CurrentHigh.Count; idx++)
            CurrentHigh.Set(idx, currentHigh);
           //DrawDot("MyDot", true, -2, High[0] + 2 * TickSize, Color.Blue);
           [B]DrawText("MyText", "Current High", 0, High[0] + 2 * TickSize, Color.Blue);[/B]
          //[B]it works here but plots at current bar and not the high of current day[/B]   
      }
         if (ShowLow)
         {
          if (!PlotCurrentValue || currentLow != Low[0])
           CurrentLow.Set(currentLow);
          else
           for (int idx = 0; idx < CurrentLow.Count; idx++)
            CurrentLow.Set(idx, currentLow);
         }
       
         currentDate  =  Bars.GetTradingDayFromLocal(Time[0]); 
              }

      Comment


        #4
        Hello,

        If I understand you correctly.

        In this case I would just add + idx instead of + Current Bar.

        Let me know if I can be of further assistance.

        Comment


          #5
          Hello,

          This is dependant on if your code is setup correctly.

          To add text do CurrentDayOHL instead of adding it through the strategy. I would add it to the indicator if it was me.

          Let me know if I can be of further assistance.

          Comment


            #6
            where would that line of code go?

            i got an error when using that to replace where the bold text is in the prior message.

            please advise

            Originally posted by NinjaTrader_Brett View Post
            Hello,

            If I understand you correctly.

            In this case I would just add + idx instead of + Current Bar.

            Let me know if I can be of further assistance.

            Comment


              #7
              Hello,

              Need to add curly braces.

              for (int idx = 0; idx < CurrentHigh.Count; idx++)
              {
              CurrentHigh.Set(idx, currentHigh);
              //DrawDot("MyDot", true, -2, High[0] + 2 * TickSize, Color.Blue);
              DrawText("MyText", "Current High", 0, High[0] + 2 * TickSize, Color.Blue);

              }

              This will DrawText each time Current high changes. You may want to try +idx here. and also + CurrentBar. Most likely you will want +CurrentBar.

              I do not know if this is what you want.

              Comment


                #8
                no luck yet

                none of these seem to draw text at the current high of day
                Code:
                if (ShowHigh)
                   {
                    if (!PlotCurrentValue || currentHigh != High[0])
                    { 
                     CurrentHigh.Set(currentHigh);
                        //DrawText("MyText" + idx, "Current High", -12, High[0] + 2 * TickSize, Color.Blue);
                        //DrawText("MyText" + idx, "Current High", 1, High[0] + 2 * TickSize, Color.Blue);
                     DrawText("MyText" +CurrentBar, "Current High", 1, High[0] + 2 * TickSize, Color.Blue);
                    }
                    else
                     for (int idx = 0; idx < CurrentHigh.Count; idx++)
                     {
                      CurrentHigh.Set(idx, currentHigh);
                     //DrawDot("MyDot", true, -2, High[0] + 2 * TickSize, Color.Blue);
                     //DrawText("MyText" +CurrentBar, "Current High", 1, High[0] + 2 * TickSize, Color.Blue);
                     //DrawText("MyText" + idx, "Current High", 1, High[0] + 2 * TickSize, Color.Blue); 
                     }



                Originally posted by NinjaTrader_Brett View Post
                Hello,

                Need to add curly braces.

                for (int idx = 0; idx < CurrentHigh.Count; idx++)
                {
                CurrentHigh.Set(idx, currentHigh);
                //DrawDot("MyDot", true, -2, High[0] + 2 * TickSize, Color.Blue);
                DrawText("MyText", "Current High", 0, High[0] + 2 * TickSize, Color.Blue);

                }

                This will DrawText each time Current high changes. You may want to try +idx here. and also + CurrentBar. Most likely you will want +CurrentBar.

                I do not know if this is what you want.

                Comment


                  #9
                  Am I missing something here?

                  if (!PlotCurrentValue || currentHigh != High[0])
                  will never evaluate to true if PlotCurrentValue is true. I presume that you do want to PlotCurrentValue, so I am presuming that it is set to true?

                  Comment


                    #10
                    Got it!

                    Code:
                    if (ShowHigh)
                    {
                        DrawText("current high", "Tdy's High", 0, currentHigh, Color.Blue);
                    }
                        if (!PlotCurrentValue || currentHigh != High[0])
                        {  [B]then continue unchanged code from here...[/B]

                    Comment


                      #11
                      Hello,

                      From a NinjaScript support standpoint I can help you diagnose something if it is not working correctly as you expect. However I cannot create the code for you.

                      Your suffering here from code logic that does not do what you need. As far as creating the code to do this I unfortuanley cannot do. For this you would need to contact a NinjaScript consultant.

                      NinjaScript Consultants:



                      If you have some code that you think should work but is not working you can send the entire code to support at ninjatrader dot com and reference this forum post and put ATTN: brett in the subject line and I can give it a quick run and make a recommendation. However I cannot write the code for you.

                      Comment


                        #12
                        np...thx for you help!

                        i understand. have a great wknd!


                        Originally posted by NinjaTrader_Brett View Post
                        Hello,

                        From a NinjaScript support standpoint I can help you diagnose something if it is not working correctly as you expect. However I cannot create the code for you.

                        Your suffering here from code logic that does not do what you need. As far as creating the code to do this I unfortuanley cannot do. For this you would need to contact a NinjaScript consultant.

                        NinjaScript Consultants:



                        If you have some code that you think should work but is not working you can send the entire code to support at ninjatrader dot com and reference this forum post and put ATTN: brett in the subject line and I can give it a quick run and make a recommendation. However I cannot write the code for you.

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by DJ888, 04-16-2024, 06:09 PM
                        6 responses
                        18 views
                        0 likes
                        Last Post DJ888
                        by DJ888
                         
                        Started by Jon17, Today, 04:33 PM
                        0 responses
                        1 view
                        0 likes
                        Last Post Jon17
                        by Jon17
                         
                        Started by Javierw.ok, Today, 04:12 PM
                        0 responses
                        6 views
                        0 likes
                        Last Post Javierw.ok  
                        Started by timmbbo, Today, 08:59 AM
                        2 responses
                        10 views
                        0 likes
                        Last Post bltdavid  
                        Started by alifarahani, Today, 09:40 AM
                        6 responses
                        41 views
                        0 likes
                        Last Post alifarahani  
                        Working...
                        X