• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

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.

        http://screencast.com/t/QUtFcUFPk

        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.

          http://screencast.com/t/QUtFcUFPk

          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);
                                  
                              //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);
                          }
                          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)
                                   {
                                    DrawText("Delta" + CurrentBar, true, Convert.ToString(deltavolume), 0, High[0] + (textOffset*TickSize)/2, 0, textColor1, 
                                    textFont, StringAlignment.Center, outlineColor1, areaColor1, opacity1);
                                    barNum = CurrentBar ;  // Save the CurrentBar number
                                     }
                                                
                                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);
                            }
            
                                    if (barNum == CurrentBar) DrawArrowDown("MyArrowd"+CurrentBar, 0, High[0] + 2 * TickSize, Color.Red);   //scott mod
            
                            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 aligator, Today, 10:11 PM
              0 responses
              1 view
              0 likes
              Last Post aligator  
              Started by psquare, Today, 03:11 PM
              4 responses
              18 views
              0 likes
              Last Post psquare
              by psquare
               
              Started by ballboy11, Today, 03:20 PM
              1 response
              12 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by tonynt, Today, 02:18 PM
              1 response
              10 views
              0 likes
              Last Post NinjaTrader_JoshG  
              Started by denalek2419, Today, 01:46 PM
              3 responses
              12 views
              0 likes
              Last Post NinjaTrader_ChristopherJ  
              Working...
              X