NexusFi: Find Your Edge


Home Menu

 





news filter code question


Discussion in NinjaTrader

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




 
Search this Thread

news filter code question

  #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?
Is there a way to simulate CONTINUOUS CONTRACT?
NinjaTrader
Trade idea based off three indicators.
Traders Hideout
What broker to use for trading palladium futures
Commodities
Quantum physics & Trading dynamics
The Elite Circle
Footprint for strategy Builder
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Funded Trader platforms
39 thanks
Spoo-nalysis ES e-mini futures S&P 500
16 thanks
GFIs1 1 DAX trade per day journal
15 thanks
The Trading Pit "Futures VIP" Account Journal
15 thanks
Trading with Intuition
14 thanks
  #3 (permalink)
 
cory's Avatar
 cory 
virginia
 
Experience: Intermediate
Platform: ninja
Trading: NQ
Posts: 6,098 since Jun 2009
Thanks Given: 877
Thanks Received: 8,090



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
 
Experience: Intermediate
Platform: ninja
Trading: NQ
Posts: 6,098 since Jun 2009
Thanks Given: 877
Thanks Received: 8,090

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


© 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