Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

DrawTextFixed(TextPosition.TopRight) not working

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

    #31
    Resize drawn object

    How about changing size of the drawn object?
    What I mean is that the user can resize the drawn object of his/her choice.
    How to do that?

    Comment


      #32
      luxurious_04, unfortunately this is not supported directly - try using for example a symbol font like Windings in a DrawText call so you can set the font size programmatically then.
      BertrandNinjaTrader Customer Service

      Comment


        #33
        How about this?

        I made an HMA cross indicator and then it will detect the cross above/below with my default period. And then my problem is when I try to change the period in the indicator's properties assuming that I already added it in the chart and then it will never detect the cross anymore coz it is different period with my default period in the source code.Now my question is-When I change the period in the parameter section of HMA in the chart can this new period I choose will be the one to be used in the computation/condition in my source code? Can this new period replace the my default period in the source code?

        Comment


          #34
          drawtext

          DrawText(Close[0].ToString ("0.00"),true,"Ç",0,Low[0] - TickSize,0,Color.White,textFont, StringAlignment.Center, Color.Black, BuyColor, 0);

          it will plot or drawtext

          Comment


            #35
            For the HMA cross indicator, you would need to setup a user defined input for the Period to use -



            For your last question: this call will DrawText but expressed by the font you've chosen to use (textFont parameter).
            BertrandNinjaTrader Customer Service

            Comment


              #36
              I'd already tried it and then there is no drawn text in 10 min chart..

              Here's my code:

              #region Using declarations
              using System;
              using System.ComponentModel;
              using System.Diagnostics;
              using System.Drawing;
              using System.Drawing.Drawing2D;
              using System.Xml.Serialization;
              using NinjaTrader.Cbi;
              using NinjaTrader.Data;
              using NinjaTrader.Gui.Chart;
              #endregion

              // This namespace holds all indicators and is required. Do not change it.
              namespace NinjaTrader.Indicator
              {
              /// <summary>
              /// Determine weather the CrossAbove/Below of ZeroLagMACD is equal to the CrossAbove/Below of HMA
              /// </summary>
              [Description("Determine weather the CrossAbove/Below of ZeroLagMACD is equal to the CrossAbove/Below of HMA")]
              public class CrossAlert : Indicator
              {
              #region Variables
              // Wizard generated variables

              //Variable for ZeroLagMACD
              private int fast = 12; // Default setting for Fast
              private int slow = 26; // Default setting for Slow
              private int smooth = 9; // Default setting for Smooth
              private int HMA_fastperiod = 15; // Default setting for HMA fast
              private int HMA_slowperiod=9; // Default setting for HMA slow
              private Color buycolor = Color.DarkGreen;
              private Color sellcolor = Color.Red;
              private bool enableAlert = false ;
              private int barAgo=2;
              private int markersize = 15;
              private System.Drawing.Font textFont;

              // User defined variables (add any user defined variables below)
              #endregion
              /// <summary>
              /// This method is used to configure the indicator and is called once before any bar data is loaded.
              /// </summary>
              protected override void Initialize()
              {
              textFont = new Font("Wingdings 3",markersize);
              //Overlay = true;
              PriceTypeSupported = true;
              CalculateOnBarClose = false;
              }

              /// <summary>
              /// Called on each bar update event (incoming tick)
              /// </summary>
              protected override void OnBarUpdate()
              {
              // Use this method for calculating your indicator values. Assign a value to each
              // plot below by replacing 'Close[0]' with your own formula.

              if (CurrentBar==0)
              return;
              for (BarAgo=0;BarAgo<2;BarAgo++)
              {
              if ((CrossAbove(HMA(HMA_FastPeriod),HMA(HMA_SlowPerio d),BarAgo) && (CrossAbove(ZeroLagMACD(Fast,Slow,Smooth),ZeroLagM ACD(Fast,Slow,Smooth).Avg,BarAgo))))
              {

              DrawText(Close[0].ToString ("0.00"),true,"Ç",0,Low[0] - TickSize,0,Color.White,textFont, StringAlignment.Center, Color.Black, BuyColor, 0);


              }
              else if ((CrossBelow(HMA(HMA_FastPeriod),HMA(HMA_SlowPerio d),BarAgo) && (CrossBelow(ZeroLagMACD(Fast,Slow,Smooth),ZeroLagM ACD(Fast,Slow,Smooth).Avg,BarAgo))))
              {
              DrawText(Close[0].ToString ("0.00"),true,"È",0,High[0] + TickSize,0,Color.White,textFont, StringAlignment.Center, Color.Black, SellColor, 0);
              }
              }

              }
              public override string ToString()
              {
              return Name + "(" + (enableAlert ? "Alerts ON" : "Alerts OFF") + ")" ;
              }

              #region Properties

              [Description("")]
              [GridCategory("Parameters")]
              public int Fast
              {
              get { return fast; }
              set { fast = Math.Max(1, value); }
              }

              [Description("")]
              [GridCategory("Parameters")]
              public int Slow
              {
              get { return slow; }
              set { slow = Math.Max(1, value); }
              }

              [Description("")]
              [GridCategory("Parameters")]
              public int Smooth
              {
              get { return smooth; }
              set { smooth = Math.Max(1, value); }
              }

              [Description("")]
              [GridCategory("Parameters")]
              public int BarAgo
              {
              get { return barAgo; }
              set { barAgo = Math.Max(1, value); }
              }


              [Description("")]
              [GridCategory("Parameters")]
              public int HMA_FastPeriod
              {
              get { return HMA_fastperiod; }
              set { HMA_fastperiod = Math.Max(1, value); }
              }

              [Description("")]
              [GridCategory("Parameters")]
              public int HMA_SlowPeriod
              {
              get { return HMA_slowperiod; }
              set { HMA_slowperiod = Math.Max(1, value); }
              }

              // Create our user definable color input
              [XmlIgnore()]
              [Description("Color for painted region")]
              [Category("Parameters")]
              public Color BuyColor
              {
              get { return buycolor; }
              set { buycolor = value; }
              }

              // Serialize our Color object
              [Browsable(false)]
              public string BuyColorSerialize
              {
              get { return NinjaTrader.Gui.Design.SerializableColor.ToString( buycolor); }
              set { buycolor = NinjaTrader.Gui.Design.SerializableColor.FromStrin g(value); }
              }

              [XmlIgnore()]
              [Description("Color for painted region")]
              [Category("Parameters")]
              public Color SellColor
              {
              get { return sellcolor; }
              set { sellcolor = value;}
              }

              [Browsable(false)]
              public string SellColorSerialize
              {
              get { return NinjaTrader.Gui.Design.SerializableColor.ToString( sellcolor); }
              set { sellcolor = NinjaTrader.Gui.Design.SerializableColor.FromStrin g(value); }
              }

              [XmlIgnore()]
              [Description("enable alert")]
              [Category("Parameters")]
              public bool EnableAlert
              {
              get { return enableAlert; }
              set { enableAlert = value; }
              }

              [Description("Marker Size")]
              [Category("Visual")]
              [Gui.Design.DisplayName("Marker Size")]
              public int MarkerSize
              {
              get { return markersize; }
              set { markersize = Math.Max(1,value); }
              }

              #endregion
              }
              }

              Comment


                #37
                Do you see any errors in the log tab showing up? Please add prints to your code to verify the conditions to DrawText() triggers as you would expect.
                BertrandNinjaTrader Customer Service

                Comment


                  #38
                  It will draw an arrow up if HMA and ZeroLagMACD crosses above.It will draw arrow down if HMA and ZeroLagMACD crosses below. Is there a wrong in my code? I don't why it will not draw in chart.

                  #region Variables
                  // Wizard generated variables

                  //Variable for ZeroLagMACD
                  private int fast = 12; // Default setting for Fast
                  private int slow = 26; // Default setting for Slow
                  private int smooth = 9; // Default setting for Smooth
                  private int HMA_fastperiod = 15; // Default setting for HMA fast
                  private int HMA_slowperiod=9; // Default setting for HMA slow
                  private Color buycolor = Color.DarkGreen;
                  private Color sellcolor = Color.Red;
                  private bool enableAlert = false ;
                  private int barAgo=2;
                  private int markersize = 15;
                  private System.Drawing.Font textFont;

                  // User defined variables (add any user defined variables below)
                  #endregion
                  /// <summary>
                  /// This method is used to configure the indicator and is called once before any bar data is loaded.
                  /// </summary>
                  protected override void Initialize()
                  {
                  textFont = new Font("Wingdings 3",markersize);
                  //Overlay = true;
                  PriceTypeSupported = true;
                  CalculateOnBarClose = false;
                  }

                  /// <summary>
                  /// Called on each bar update event (incoming tick)
                  /// </summary>
                  protected override void OnBarUpdate()
                  {
                  // Use this method for calculating your indicator values. Assign a value to each
                  // plot below by replacing 'Close[0]' with your own formula.

                  if (CurrentBar==0)
                  return;
                  for (BarAgo=0;BarAgo<2;BarAgo++)
                  {
                  if ((CrossAbove(HMA(HMA_FastPeriod),HMA(HMA_SlowPerio d),BarAgo) && (CrossAbove(ZeroLagMACD(Fast,Slow,Smooth),ZeroLagM ACD(Fast,Slow,Smooth).Avg,BarAgo))))
                  {
                  //Draw arrow up
                  DrawText(Close[0].ToString ("0.00"),true,"Ç",0,Low[0] - TickSize,0,Color.White,textFont, StringAlignment.Center, Color.Black, BuyColor, 0);
                  }
                  else if ((CrossBelow(HMA(HMA_FastPeriod),HMA(HMA_SlowPerio d),BarAgo) && (CrossBelow(ZeroLagMACD(Fast,Slow,Smooth),ZeroLagM ACD(Fast,Slow,Smooth).Avg,BarAgo))))
                  {
                  //Draw arrow down
                  DrawText(Close[0].ToString ("0.00"),true,"È",0,High[0] + TickSize,0,Color.White,textFont, StringAlignment.Center, Color.Black, SellColor, 0);
                  }
                  }

                  }
                  public override string ToString()
                  {
                  return Name + "(" + (enableAlert ? "Alerts ON" : "Alerts OFF") + ")" ;
                  }

                  #region Properties

                  [Description("")]
                  [GridCategory("Parameters")]
                  public int Fast
                  {
                  get { return fast; }
                  set { fast = Math.Max(1, value); }
                  }

                  [Description("")]
                  [GridCategory("Parameters")]
                  public int Slow
                  {
                  get { return slow; }
                  set { slow = Math.Max(1, value); }
                  }

                  [Description("")]
                  [GridCategory("Parameters")]
                  public int Smooth
                  {
                  get { return smooth; }
                  set { smooth = Math.Max(1, value); }
                  }

                  [Description("")]
                  [GridCategory("Parameters")]
                  public int BarAgo
                  {
                  get { return barAgo; }
                  set { barAgo = Math.Max(1, value); }
                  }


                  [Description("")]
                  [GridCategory("Parameters")]
                  public int HMA_FastPeriod
                  {
                  get { return HMA_fastperiod; }
                  set { HMA_fastperiod = Math.Max(1, value); }
                  }

                  [Description("")]
                  [GridCategory("Parameters")]
                  public int HMA_SlowPeriod
                  {
                  get { return HMA_slowperiod; }
                  set { HMA_slowperiod = Math.Max(1, value); }
                  }

                  // Create our user definable color input
                  [XmlIgnore()]
                  [Description("Color for painted region")]
                  [Category("Parameters")]
                  public Color BuyColor
                  {
                  get { return buycolor; }
                  set { buycolor = value; }
                  }

                  // Serialize our Color object
                  [Browsable(false)]
                  public string BuyColorSerialize
                  {
                  get { return NinjaTrader.Gui.Design.SerializableColor.ToString( buycolor); }
                  set { buycolor = NinjaTrader.Gui.Design.SerializableColor.FromStrin g(value); }
                  }

                  [XmlIgnore()]
                  [Description("Color for painted region")]
                  [Category("Parameters")]
                  public Color SellColor
                  {
                  get { return sellcolor; }
                  set { sellcolor = value;}
                  }

                  [Browsable(false)]
                  public string SellColorSerialize
                  {
                  get { return NinjaTrader.Gui.Design.SerializableColor.ToString( sellcolor); }
                  set { sellcolor = NinjaTrader.Gui.Design.SerializableColor.FromStrin g(value); }
                  }

                  [XmlIgnore()]
                  [Description("enable alert")]
                  [Category("Parameters")]
                  public bool EnableAlert
                  {
                  get { return enableAlert; }
                  set { enableAlert = value; }
                  }

                  [Description("Marker Size")]
                  [Category("Visual")]
                  [Gui.Design.DisplayName("Marker Size")]
                  public int MarkerSize
                  {
                  get { return markersize; }
                  set { markersize = Math.Max(1,value); }
                  }

                  #endregion
                  }
                  }
                  Last edited by luxurious_04; 08-18-2010, 09:35 PM.

                  Comment


                    #39
                    Your condition may just be too hard, as both would have to happen on the exact same bar as per your code - I would suggest to simplify to one rule for example only and then add the needed prints to see what evaluates to 'true' and what not.
                    BertrandNinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by carnitron, Today, 08:42 PM
                    0 responses
                    6 views
                    0 likes
                    Last Post carnitron  
                    Started by strategist007, Today, 07:51 PM
                    0 responses
                    8 views
                    0 likes
                    Last Post strategist007  
                    Started by StockTrader88, 03-06-2021, 08:58 AM
                    44 responses
                    3,974 views
                    3 likes
                    Last Post jhudas88  
                    Started by rbeckmann05, Today, 06:48 PM
                    0 responses
                    9 views
                    0 likes
                    Last Post rbeckmann05  
                    Started by rhyminkevin, Today, 04:58 PM
                    4 responses
                    58 views
                    0 likes
                    Last Post dp8282
                    by dp8282
                     
                    Working...
                    X