NexusFi: Find Your Edge


Home Menu

 





Need to draw a dot above certain bars


Discussion in NinjaTrader

Updated
    1. trending_up 5,808 views
    2. thumb_up 0 thanks given
    3. group 2 followers
    1. forum 2 posts
    2. attach_file 1 attachments




 
Search this Thread

Need to draw a dot above certain bars

  #1 (permalink)
 bwlinux 
Houston, TX
 
Experience: Intermediate
Platform: Ninja Trader
Trading: ES, TF
Posts: 2 since Dec 2010
Thanks Given: 0
Thanks Received: 0

I'm trying to draw a Dot above/below really large price bars on a 5 minute chart to help me identify a pattern of divergence on my smaller time frame chart. The problem is that it only draws the dot on the last big bar. I'd like it to leave the dot on ALL past big bars as I have other indicators that also change the bar color.

 
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>
    /// Alerts you to really large price bars
    /// </summary>
    [Description("Alerts you to really large price bars")]
    public class BigBarAlert : Indicator
    {
        #region Variables
            private int myBigBar = 50; // Default setting for MyInput0
            private int LastBarSize=0; // what's the size of the bar from hi to low.
            private string myAlert="alert1.wav"; // The alert wav file
            private bool myAudibleAlert=false;  //Whether to play the sound file
            private bool myPopUpAlert=false; //Whether to pop up an alert window
            private bool myChangeBarColor=true; //Whether to change big bar to gold
            private int myBarDirection=0; //0= Open/Close the same, -1 Close is below open, 1 Close is above Open 
        #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()
        {
            Overlay                = true;
        }

        /// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()
        {

            LastBarSize = (int)((High[0]-Low[0]) / TickSize); // gets range of bar and converts it to ticks for each market

            if (LastBarSize >= myBigBar) 
            {
            
                if (Close[0] > Open[0]) 
                { 
                    myBarDirection=1;
                } else if (Close[0] < Open[0]) 
                { 
                    myBarDirection=-1;
                } else {
                    myBarDirection=0;
                }
                
                if (myBarDirection==1) 
                {
                    DrawDot("BigBarDot",true, 0, High[0] + (TickSize * 5),Color.Gold);
                } else if (myBarDirection==-1)
                {
                    DrawDot("BigBarDot",true, 0, Low[0] - (TickSize * 5),Color.Gold);    
                }
                
                if (myChangeBarColor)
                {
                    BarColor = Color.Gold;
                }
                
                if (myAudibleAlert)
                {
                    PlaySound(@"C:\Program Files\NinjaTrader 7\sounds\" + myAlert);
                    // Print ("Play alert file" + LastBarSize.ToString() );
                    
                }
            }
        }

        #region Properties
        [XmlIgnore()]        // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
        
        
        
        [Description("Big Bar in ticks, 100 max")]
        [GridCategory("Parameters")]
        public int Big_Bar
        {
            get { return myBigBar; }
            set { myBigBar = Math.Max(1, value); }
        }
        
        [Description("Alert via sound")]
        [GridCategory("Parameters")]
        public bool Audible_Alert
        {
            get { return myAudibleAlert; }
            set { myAudibleAlert = value; }
        }
        
        [Description("Alert sound file")]
        [GridCategory("Parameters")]
        public string Audible_Alert_File
        {
            get { return myAlert; }
            set { myAlert = value; }
        }
        
        [Description("Change the big bar's color")]
        [GridCategory("Parameters")]
        public bool Change_Bar_Color
        {
            get { return myChangeBarColor; }
            set { myChangeBarColor = value; }
        }
        #endregion
        
    }
}
I have tried using a Plot instead but that seems to be something you only want to do for each and every bar. Any help from the gurus is greatly appreciated.

Attached Thumbnails
Click image for larger version

Name:	Capture.JPG
Views:	342
Size:	87.0 KB
ID:	26967  
Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
NexusFi Journal Challenge - April 2024
Feedback and Announcements
My NT8 Volume Profile Split by Asian/Euro/Open
NinjaTrader
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
The space time continuum and the dynamics of a financial …
Emini and Emicro Index
Are there any eval firms that allow you to sink to your …
Traders Hideout
 
  #3 (permalink)
 MooreTech 
Orlando, Florida
 
Experience: Advanced
Platform: NinjaTrader, TradeStation, MultiCharts, eSignal, MetaTrader
Trading: ES
Posts: 57 since Aug 2010
Thanks Given: 6
Thanks Received: 73


You must give all of your Drawing Objects a unique name. Try changing:
 
Code
                            
DrawDot("BigBarDot",true0High[0] + (TickSize 5),Color.Gold); 

To:

 
Code
                            
DrawDot(CurrentBar.ToString() + "BigBarDot",true0High[0] + (TickSize 5),Color.Gold); 


Follow me on Twitter Reply With Quote




Last Updated on December 15, 2010


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts