NexusFi: Find Your Edge


Home Menu

 





news filter code question


Discussion in NinjaTrader

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




 
Search this Thread
  #1 (permalink)
 ceramictilepro 
Roseville CA
 
Experience: Advanced
Platform: N7
Broker: Amp Futures/CQG
Trading: ES
Posts: 124 since Jun 2009
Thanks Given: 32
Thanks Received: 21

Hello,

I have an indicator not working correctly and am looking for help.

Looking to draw backcolor when the filter is in play.

example: news is at 1000, draw backcolor 950-1010

here is the code that starts drawing at 1000 (not 950) and stops at 1010

 
Code
if (ToTime(Time[0]) < (news +10) * 100 && ToTime(Time[0]) > (news -10) * 100)
any help would be appreciated.

thank you


Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Fabrication or Framework? Irans Denied MOU Explains the …
Prediction Markets & Event Contracts
BofA Projects $1.1 Trillion in Sports Event Contracts -- …
Prediction Markets & Event Contracts
Prediction Markets Expiry Day: Trump Eyes War Exit, $230 …
Prediction Markets & Event Contracts
US Treasury Weighs Direct Oil Futures Market Interventio …
Commodities
Zytrade: Devin Brady, CEO - Ask Me Anything (AMA)
Brokers
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Sober Journey With S&P
24 thanks
2026 Jlab journal
10 thanks
Lady Vols Primer: Trading Volatility Journal
7 thanks
Algo automated / semi-automated trading anyone?
6 thanks
Trying to learn Volume and price action correlation
5 thanks
  #3 (permalink)
 
cory's Avatar
 cory 
virginia
the coin hunter
 
Experience: Intermediate
Platform: ninja
Trading: NQ
Posts: 6,098 since Jun 2009
Thanks Given: 877
Thanks Received: 8,093



ceramictilepro View Post
Hello,

I have an indicator not working correctly and am looking for help.

Looking to draw backcolor when the filter is in play.

example: news is at 1000, draw backcolor 950-1010

here is the code that starts drawing at 1000 (not 950) and stops at 1010

 
Code
if (ToTime(Time[0]) < (news +10) * 100 && ToTime(Time[0]) > (news -10) * 100)
any help would be appreciated.

thank you

Variables
.....
private DateTime beforeNews;
private DateTime afterNews;

....
protected override void OnBarUpdate()
.....

beforeNews = ToTime(news);
beforeNews = beforeNews.AddMinutes(-10); // decrease by 10m
afterNews = ToTime(news);
afterNews = afterNews.AddMinutes(10); // increase by 10m

if (ToTime(Time[0]) < afterNews && ToTime(Time[0]) > beforeNews)


Reply With Quote
Thanked by:
  #4 (permalink)
 ceramictilepro 
Roseville CA
 
Experience: Advanced
Platform: N7
Broker: Amp Futures/CQG
Trading: ES
Posts: 124 since Jun 2009
Thanks Given: 32
Thanks Received: 21

thanks cory,

i was trying to be able and use just one private and have the code bracket the time.




cory View Post
Variables
.....
private DateTime beforeNews;
private DateTime afterNews;

....
protected override void OnBarUpdate()
.....

beforeNews = ToTime(news);
beforeNews = beforeNews.AddMinutes(-10); // decrease by 10m
afterNews = ToTime(news);
afterNews = afterNews.AddMinutes(10); // increase by 10m

if (ToTime(Time[0]) < afterNews && ToTime(Time[0]) > beforeNews)


Started this thread Reply With Quote
  #5 (permalink)
 ceramictilepro 
Roseville CA
 
Experience: Advanced
Platform: N7
Broker: Amp Futures/CQG
Trading: ES
Posts: 124 since Jun 2009
Thanks Given: 32
Thanks Received: 21


ceramictilepro View Post
thanks cory,

i was trying to be able and use just one private and have the code bracket the time.

here is what i have and it is not working, any ideas?

thank you

 
Code
 #region Variables
            //private int news = 07,00,00; // Default setting for BeginTime
		    //private DateTime news = 07,00,00;
		    private news 07,00,00;
		    private DateTime beforeNews;
            private DateTime afterNews;


        #endregion
		DataSeries _timeToTrade;
        protected override void Initialize()
        {
			_timeToTrade = new DataSeries(this);
            Overlay				= true;
			CalculateOnBarClose = false;
        }
        protected override void OnBarUpdate()
        {
		    
           beforeNews = ToTime(news);
            beforeNews = beforeNews.AddMinutes(-10); // decrease by 10m
            afterNews = ToTime(news);
            afterNews = afterNews.AddMinutes(10); // increase by 10m
			
			if (ToTime(Time[0]) < afterNews && ToTime(Time[0]) > beforeNews) 


            {
				_timeToTrade.Set(1);
				BackColor = Color.IndianRed;
			}
			else
				_timeToTrade.Set(0);
        }
        #region Properties
        [Browsable(false)]	// this line prevents the data series from being displayed in the indicator properties dialog, do not remove
        [XmlIgnore()]		// this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
        public DataSeries TimeToTrade
        {
            get { return _timeToTrade; }
        }
        [Description("Example 650 = 6:50 am  1 = No News")]
        [GridCategory("Don't Trade News 10 min Before or After")]
        public int News
        {
            get { return news; }
            set { news = Math.Max(1, value); }
        }


Started this thread Reply With Quote
  #6 (permalink)
 
cory's Avatar
 cory 
virginia
the coin hunter
 
Experience: Intermediate
Platform: ninja
Trading: NQ
Posts: 6,098 since Jun 2009
Thanks Given: 877
Thanks Received: 8,093

the devil is in the details;
 
Code
// This namespace holds all indicators and is required. Do not change it.
namespace NinjaTrader.Indicator
{
    /// <summary>
    /// Enter the description of your new custom indicator here
    /// </summary>
    [Description("Enter the description of your new custom indicator here")]
    public class newscolor : Indicator
    {
        #region Variables
    //private int news = 07,00,00; // Default setting for BeginTime
		    //private DateTime news = 07,00,00;
		    // private news 07,00,00;
		    private DateTime news;
		    private DateTime beforeNews;
            private DateTime afterNews;
		    DataSeries _timeToTrade;
        #endregion
	//	DataSeries _timeToTrade;
        /// <summary>
        /// This method is used to configure the indicator and is called once before any bar data is loaded.
        /// </summary>
        protected override void Initialize()
        {
            _timeToTrade = new DataSeries(this);
            Overlay				= true;
			CalculateOnBarClose = false;
			
			news = news.AddHours(7);  // initialize to 7AM
            beforeNews = news.AddMinutes(-10); // decrease by 10m;
            afterNews = news.AddMinutes(10); // increase by 10m
			
        }

        /// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()
        { 	
			if (ToTime(Time[0]) < ToTime(afterNews) && ToTime(Time[0]) > ToTime(beforeNews)) 
            {
				_timeToTrade.Set(1);
				BackColor = Color.IndianRed;
			}
			else
				_timeToTrade.Set(0);
		//	Print(CurrentBar+ " time to trade "+_timeToTrade[0]);	
        }

        #region Properties

        #endregion
    }
}


Reply With Quote
Thanked by:
  #7 (permalink)
 ceramictilepro 
Roseville CA
 
Experience: Advanced
Platform: N7
Broker: Amp Futures/CQG
Trading: ES
Posts: 124 since Jun 2009
Thanks Given: 32
Thanks Received: 21

lol, thanks buddy


cory View Post
the devil is in the details;
 
Code
// This namespace holds all indicators and is required. Do not change it.
namespace NinjaTrader.Indicator
{
    /// <summary>
    /// Enter the description of your new custom indicator here
    /// </summary>
    [Description("Enter the description of your new custom indicator here")]
    public class newscolor : Indicator
    {
        #region Variables
    //private int news = 07,00,00; // Default setting for BeginTime
		    //private DateTime news = 07,00,00;
		    // private news 07,00,00;
		    private DateTime news;
		    private DateTime beforeNews;
            private DateTime afterNews;
		    DataSeries _timeToTrade;
        #endregion
	//	DataSeries _timeToTrade;
        /// <summary>
        /// This method is used to configure the indicator and is called once before any bar data is loaded.
        /// </summary>
        protected override void Initialize()
        {
            _timeToTrade = new DataSeries(this);
            Overlay				= true;
			CalculateOnBarClose = false;
			
			news = news.AddHours(7);  // initialize to 7AM
            beforeNews = news.AddMinutes(-10); // decrease by 10m;
            afterNews = news.AddMinutes(10); // increase by 10m
			
        }

        /// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()
        { 	
			if (ToTime(Time[0]) < ToTime(afterNews) && ToTime(Time[0]) > ToTime(beforeNews)) 
            {
				_timeToTrade.Set(1);
				BackColor = Color.IndianRed;
			}
			else
				_timeToTrade.Set(0);
		//	Print(CurrentBar+ " time to trade "+_timeToTrade[0]);	
        }

        #region Properties

        #endregion
    }
}


Started this thread Reply With Quote




Last Updated on July 21, 2012


© 2026 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 - Downloads - Top
no new posts