I have commentary enabled. I want to output information differently according to whether the strategy was accessed 1) by clicking on an expert commentary bar or 2) on initial startup (i.e. NOT by clicking on an expert commentary bar)
For example, the first is easy:
if ( ExpertCommentary.Enabled == true && ExpertCommentary.AtCommentaryBar == true && Bars.Status == EBarState.Open) }
... do some stuff ....
However, how do I achieve number 2? I want to ouput something ONLY if the strategy was not re-initiated via a click on an expert commentary bar. For example, when it was initially started. However, we have expert commentary enabled, so ExpertCommentary.Enabled == true will not achieve what I want.
Test if code was NOT initiated by Expert Commentary?
-
- Posts: 60
- Joined: 03 Mar 2011
- Has thanked: 9 times
- Been thanked: 2 times
- JoshM
- Posts: 2195
- Joined: 20 May 2011
- Location: The Netherlands
- Has thanked: 1544 times
- Been thanked: 1565 times
- Contact:
Re: Test if code was NOT initiated by Expert Commentary?
Are you sure the first easy? Your current code only executes when someone clicks on a bar and that click coincides with the opening tick of that bar. Unless you have a 'slow' symbol, this requires quite some timing skills.I have commentary enabled. I want to output information differently according to whether the strategy was accessed 1) by clicking on an expert commentary bar or 2) on initial startup (i.e. NOT by clicking on an expert commentary bar)
For example, the first is easy:
if ( ExpertCommentary.Enabled == true && ExpertCommentary.AtCommentaryBar == true && Bars.Status == EBarState.Open) }
... do some stuff ....
Since indicators and signals are calculated from the leftmost bar to the most current bar, something that will only happen on initial startup is:
Code: Select all
if (Bars.CurrentBar == 1)
{
// Perform code for first bar
}
Code: Select all
protected override void Create()
{
// This method is called when the indicator is applied to the chart
}
protected override void StartCalc()
{
// This method is called when the calculation starts, (i.e. initially started, regardless of an ExpertCommentary window)
// So enter your code that only needs to execute once here
}
protected override void CalcBar()
{
// This method is called on each bar (historical) or each tick (real-time)
}
-
- Posts: 60
- Joined: 03 Mar 2011
- Has thanked: 9 times
- Been thanked: 2 times
Re: Test if code was NOT initiated by Expert Commentary?
Hmmn, I thought I might struggle to convey what I am trying to do. Let me rephrase. I am really interested in point number (2) above. Forget about point (1).
When I apply my Strategy/Indicator to a chart, I have a bunch of output - based on historical data - which is of interest to me. e.g the script loops over all the data in CalcBar() and I do
A) if ( Environment.IsRealTimeCalc == false ) Output.WriteLine("Lots and Lots of Info about all my historic bars")
However, the script also has some other information which is output from ExpertCommentary. E.g. I click on a bar, and I get some ExpertCommentary:
B) ExpertCommentary.WriteLine("Some Info specific to this bar")...
However, everytime I click on an ExpertCommentary bar (to see the commentary at that bar), the script once again loops over all the histrocal data - and I get all the output from (A) above! However, I don't want to get that ouput again, each time I click on a bar. I just want to see all the info from (A) once, when I first apply the indicator/strategy to the chart (or re-compile, etc).
I hope this makes more sense!?
When I apply my Strategy/Indicator to a chart, I have a bunch of output - based on historical data - which is of interest to me. e.g the script loops over all the data in CalcBar() and I do
A) if ( Environment.IsRealTimeCalc == false ) Output.WriteLine("Lots and Lots of Info about all my historic bars")
However, the script also has some other information which is output from ExpertCommentary. E.g. I click on a bar, and I get some ExpertCommentary:
B) ExpertCommentary.WriteLine("Some Info specific to this bar")...
However, everytime I click on an ExpertCommentary bar (to see the commentary at that bar), the script once again loops over all the histrocal data - and I get all the output from (A) above! However, I don't want to get that ouput again, each time I click on a bar. I just want to see all the info from (A) once, when I first apply the indicator/strategy to the chart (or re-compile, etc).
I hope this makes more sense!?