Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
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
#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); }
}
// 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
}
}
// 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
}
}