Difference between revisions of "BEGINCMTRY"

From MultiCharts
Jump to navigation Jump to search
m
 
Line 1: Line 1:
The statements between this compiler directive and the reserved word #End are evaluated only when the '''Expert Commentary''' tool is used to select a bar on a chart or a cell in a grid. The reserved word #End must be used with this reserved word.
+
The statements between this compiler directive and the reserved word #End are evaluated only when the [[Category:Expert_Commentary|Expert Commentary]] tool is used to select a bar on a chart or a cell in a grid. The reserved word #End must be used with this reserved word.
  
'''Usage'''
+
== Usage ==
 
<syntaxhighlight>
 
<syntaxhighlight>
 
#BeginCmtry
 
#BeginCmtry
Line 8: Line 8:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
'''Notes'''
+
== Notes ==
All statements between the ''#BeginCmtry'' and ''#End'' are ignored, including calculation of MaxBarsBack, unless commentary is generated.
+
* All statements between the ''#BeginCmtry'' and ''#End'' are ignored, including calculation of MaxBarsBack, unless commentary is generated.
 
 
'''Example'''
 
  
 +
== Example ==
 
An indicator that calculates the 10-bar momentum of the closing price needs ten bars in order to start plotting results. If commentary is added to this indicator and the commentary uses a 50-bar average of the volume, then the MaxBarsBack setting is increased to fifty. However, the 50-bar average is only used for the commentary, so there is no need to have the indicator wait fifty bars before giving results unless Commentary is requested.
 
An indicator that calculates the 10-bar momentum of the closing price needs ten bars in order to start plotting results. If commentary is added to this indicator and the commentary uses a 50-bar average of the volume, then the MaxBarsBack setting is increased to fifty. However, the 50-bar average is only used for the commentary, so there is no need to have the indicator wait fifty bars before giving results unless Commentary is requested.
  

Latest revision as of 05:43, 3 April 2013

The statements between this compiler directive and the reserved word #End are evaluated only when the tool is used to select a bar on a chart or a cell in a grid. The reserved word #End must be used with this reserved word.

Usage

#BeginCmtry
Commentary("The indicator value here is " + NumtoStr(Plot1, 2));
#End;

Notes

  • All statements between the #BeginCmtry and #End are ignored, including calculation of MaxBarsBack, unless commentary is generated.

Example

An indicator that calculates the 10-bar momentum of the closing price needs ten bars in order to start plotting results. If commentary is added to this indicator and the commentary uses a 50-bar average of the volume, then the MaxBarsBack setting is increased to fifty. However, the 50-bar average is only used for the commentary, so there is no need to have the indicator wait fifty bars before giving results unless Commentary is requested.

To have the indicator plot after 10 bars and ignore the 50-bar requirement, the indicator can be written as follows:

Plot1( Close - Close[10], "Momentum");

#BeginCmtry;
 If Close - Close[10] > 0 Then
  Commentary("Momentum is positive, ")
 Else
  Commentary("Momentum is negative, ");
 If Volume > Average(Volume, 50) Then
  Commentary(" and volume is greater than average.") 
 Else
  Commentary(" and volume is lower than average.");
#End;

This indicator plots the momentum and the commentary states whether the momentum is positive or negative, and if the volume is over or under the 50-bar average of the volume. When the indicator is applied without using commentary, it will require only 10 bars to start calculating. When commentary is requested, the indicator is recalculated, the statements within the compiler directives are evaluated, and the new minimum number of bars required is 50. Any series functions within these reserved words are also ignored.