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

Plot moving with candle

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

    Plot moving with candle

    Hi,

    I have a draw text plotting on certain candles. When it plots it prints 10 ticks away from either the high or low of the candle, how do I make it so that it moves with the candle? Sometimes the candle will move more than 10 ticks after the print of the text, then the candle ends up covering it.

    #2
    Hello ScottieDog,

    Thanks for your post about drawtext.

    Based on your description you have an indicator that will print on the chart above/below a candle as it is in the process of forming. This would imply you are using the CalculateOnBarClose = false.

    The way to make the DrawText move with the candle would be to effectively redraw the text with each tic in that candle. You can do this autonomously by using the same "tag" and a new "Y" axis location.

    Please let me know if I can be of further assistance.
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Paul View Post
      Hello ScottieDog,

      Thanks for your post about drawtext.

      Based on your description you have an indicator that will print on the chart above/below a candle as it is in the process of forming. This would imply you are using the CalculateOnBarClose = false.

      The way to make the DrawText move with the candle would be to effectively redraw the text with each tic in that candle. You can do this autonomously by using the same "tag" and a new "Y" axis location.

      Please let me know if I can be of further assistance.
      How do I do this? I am learning to code, and can only do basic things. Is there a link with instructions?

      Comment


        #4
        Hello ScottieDog,

        Thanks for your reply. To help I have created a short video showing one way to do this.

        I used an EMA crossing another EMA as a trigger to use DrawText.

        Free online storage and sharing with Screencast.com. 2 GB of storage and 2 GB of bandwidth per month for free. We won't compress, alter or take ownership of your content.


        Please let me know if you need further assistance.
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Paul View Post
          Hello ScottieDog,

          Thanks for your reply. To help I have created a short video showing one way to do this.

          I used an EMA crossing another EMA as a trigger to use DrawText.

          Free online storage and sharing with Screencast.com. 2 GB of storage and 2 GB of bandwidth per month for free. We won't compress, alter or take ownership of your content.


          Please let me know if you need further assistance.
          Hi,

          I can see how you´ve done it on your video, I just can´t see where to add it inside my code. I´ve declared the int no problem, but not sure where I should put the barNum == CurrentBar

          I want to add the (currently commented out) DrawDownArrow, and to have it move with the bar....

          When I uncomment the line for the DrawDownArrow I get an error message of "Statement Excepted".

          This is my code...

          Code:
          {
                      if (deltavolume > 0)
                      {
                          UpVolume.Set(deltavolume);
                          DownVolume.Set(0);
                                          
                          if (textType == AlertTypes.Delta)
                          {
                              if (Close[0] < Open[0] && deltavolume > threshold)
                                  DrawText("Delta" + CurrentBar, true, Convert.ToString(deltavolume), 0, High[0] + (textOffset*TickSize)/2, 0, textColor1, 
                                  textFont, StringAlignment.Center, outlineColor1, areaColor1, opacity1);
                                  
                           [COLOR=Red]   //DrawArrowDown("MyArrowd"+CurrentBar, 0, High[0]+2* TickSize, Color.Red);   //scott mod[/COLOR]
                              
                              else if (Close[0] >= Open[0]) 
                                  DrawText("Delta" + CurrentBar, true, Convert.ToString("NEUTRAL"), 0, High[0] + (textOffset*TickSize)/2, 0, Color.Transparent,
                                  textFont, StringAlignment.Center, Color.Transparent, Color.Transparent, 0);
                          }
                          else if (textType == AlertTypes.Label)
                          {
                              if (Close[0] < Open[0] && deltavolume > threshold)
                                  DrawText("Delta" + CurrentBar, true, Convert.ToString(plotLabel1), 0, High[0] + (textOffset*TickSize)/2, 0, textColor1, 
                                  textFont, StringAlignment.Center, outlineColor1, areaColor1, opacity1);
                                  
                              else if (Close[0] >= Open[0]) 
                                  DrawText("Delta" + CurrentBar, true, Convert.ToString("NEUTRAL"), 0, High[0] + (textOffset*TickSize)/2, 0, Color.Transparent,
                                  textFont, StringAlignment.Center, Color.Transparent, Color.Transparent, 0);
                          }
                          else if (textType == AlertTypes.Sound)
                          {
                              if (Close[0] < Open[0] && deltavolume > threshold)
                              {
                                  try
                                  {    DrawText("Delta" + CurrentBar, true, Convert.ToString(deltavolume), 0, High[0] + (textOffset*TickSize)/2, 0, textColor1, 
                                      textFont, StringAlignment.Center, outlineColor1, areaColor1, opacity1); //scott mod
                                      Alert("DownAlert", soundAlertPriority, "DownAlert", downFile, rearmTime, Color.Navy, Color.Crimson);
                                      
                                  }
                                  catch {}
                              }
                          }
                      }

          Comment


            #6
            Hello ScottieDog,

            Thanks for your reply and follow-up question. In the code section you attached there are a lot of things happening. Basically if the deltavolume is >0 several things could happen in the various subsequent If/else-If statements.

            Where you are placing the DrawArrow will only happen when deltavolume >0 and textType ==AlertTypes.Delta and Close[0] < Open[0] && deltavolume > threshold) So if you have another alert type selected then the draw arrow won't happen. You can of course change the code we add to the other sections if you wish but I just wanted to be clear that this is an example. As I don't have the entire code I cannot test on my end but this should get you started in the right direction. If you do decide to expand the concept then make sure you use different integer variables for each different section, IE: barNum1, barNum2, etc.

            In the code section below I have added changes in red.

            Code:
            {
                        if (deltavolume > 0)
                        {
                            UpVolume.Set(deltavolume);
                            DownVolume.Set(0);
                                            
                            if (textType == AlertTypes.Delta)
                            {
                                if (Close[0] < Open[0] && deltavolume > threshold)
            [COLOR="red"]                       {[/COLOR]
                                    DrawText("Delta" + CurrentBar, true, Convert.ToString(deltavolume), 0, High[0] + (textOffset*TickSize)/2, 0, textColor1, 
                                    textFont, StringAlignment.Center, outlineColor1, areaColor1, opacity1);
                                   [COLOR="Red"] barNum = CurrentBar ;  // Save the CurrentBar number[/COLOR]
            [COLOR="Red"]                         }[/COLOR]
                                                
                                else if (Close[0] >= Open[0]) 
                                    DrawText("Delta" + CurrentBar, true, Convert.ToString("NEUTRAL"), 0, High[0] + (textOffset*TickSize)/2, 0, Color.Transparent,
                                    textFont, StringAlignment.Center, Color.Transparent, Color.Transparent, 0);
                            }
            
            [COLOR="red"]                        if (barNum == CurrentBar) DrawArrowDown("MyArrowd"+CurrentBar, 0, High[0] + 2 * TickSize, Color.Red);   //scott mod[/COLOR]
            
                            else if (textType == AlertTypes.Label)
                            {
                                if (Close[0] < Open[0] && deltavolume > threshold)
                                    DrawText("Delta" + CurrentBar, true, Convert.ToString(plotLabel1), 0, High[0] + (textOffset*TickSize)/2, 0, textColor1, 
                                    textFont, StringAlignment.Center, outlineColor1, areaColor1, opacity1);
                                    
                                else if (Close[0] >= Open[0]) 
                                    DrawText("Delta" + CurrentBar, true, Convert.ToString("NEUTRAL"), 0, High[0] + (textOffset*TickSize)/2, 0, Color.Transparent,
                                    textFont, StringAlignment.Center, Color.Transparent, Color.Transparent, 0);
                            }
                            else if (textType == AlertTypes.Sound)
                            {
                                if (Close[0] < Open[0] && deltavolume > threshold)
                                {
                                    try
                                    {    DrawText("Delta" + CurrentBar, true, Convert.ToString(deltavolume), 0, High[0] + (textOffset*TickSize)/2, 0, textColor1, 
                                        textFont, StringAlignment.Center, outlineColor1, areaColor1, opacity1); //scott mod
                                        Alert("DownAlert", soundAlertPriority, "DownAlert", downFile, rearmTime, Color.Navy, Color.Crimson);
                                        
                                    }
                                    catch {}
                                }
                            }
                        }
            Please let me know if you have further questions.
            Paul H.NinjaTrader Customer Service

            Comment


              #7
              Try this

              if (textType == AlertTypes.Delta)
              {
              if (Close[0] < Open[0] && deltavolume > threshold)
              {
              DrawText("Delta" + CurrentBar, true, Convert.ToString(deltavolume), 0, High[0] + (textOffset*TickSize)/2, 0, textColor1, textFont, StringAlignment.Center, outlineColor1, areaColor1, opacity1);
              DrawArrowDown("MyArrowd"+CurrentBar, 0, High[0]+2* TickSize, Color.Red); //scott mod
              }
              else if (Close[0] >= Open[0])
              DrawText("Delta" + CurrentBar, true, Convert.ToString("NEUTRAL"), 0, High[0] + (textOffset*TickSize)/2, 0, Color.Transparent, textFont, StringAlignment.Center, Color.Transparent, Color.Transparent, 0);
              }
              Last edited by eDanny; 06-25-2014, 11:49 AM.
              eDanny
              NinjaTrader Ecosystem Vendor - Integrity Traders

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by algospoke, 04-17-2024, 06:40 PM
              6 responses
              49 views
              0 likes
              Last Post algospoke  
              Started by arvidvanstaey, Today, 02:19 PM
              4 responses
              11 views
              0 likes
              Last Post arvidvanstaey  
              Started by samish18, 04-17-2024, 08:57 AM
              16 responses
              61 views
              0 likes
              Last Post samish18  
              Started by jordanq2, Today, 03:10 PM
              2 responses
              10 views
              0 likes
              Last Post jordanq2  
              Started by traderqz, Today, 12:06 AM
              10 responses
              21 views
              0 likes
              Last Post traderqz  
              Working...
              X