+1 888 340 6572

Cross: Difference between revisions

From MultiCharts
No edit summary
No edit summary
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
Returns a value of [[True]] if, on the current bar, the plot of a numerical expression A crossed the plot of a numerical expression B in the specified direction.  
Returns a value of [[True]] if, on the current bar, the plot of a numerical expression A crossed the plot of a numerical expression B in the specified direction.  


[[Above, Over, Below,]] or [[Under]] parameters specify the direction of the cross; [[Above]] and [[Over]] are transposable and specify an upward (lesser to a greater value) direction, and [[Below]] and [[Under]] are transposable and specify a downward (greater to a lesser value) direction.
== Usage ==
<syntaxhighlight>Plot1 Cross Direction Plot2</syntaxhighlight>
 
or:


The plot of A is defined as having crossed [[Above]] or [[Over]] the plot of B if the value of A is greater than the value of B and one of the following is true:
<syntaxhighlight>E1 Cross Direction E2</syntaxhighlight>


a) The value of A was less than the value of B on the bar immediately preceding the current bar
Where:


or
:'''E''' - a numerical expression.


b) The values of A and B were equal for a consecutive sequence of one or more bars immediately preceding the current bar and the value of A was less than the value of B on the bar immediately preceding this sequence of bars.  
:'''Direction''' - a required parameter which specifies the direction of the cross.
::[[Above]], [[Over]], [[Below]] or [[Under]] parameters are used to specify the direction of the cross.


The plot of A is defined as having crossed [[Below]] or [[Under]] the plot of B if the value of A is less than the value of B and one of the following is true:  
== Notes ==
* [[Above]] and [[Over]] are transposable and specify an upward (lesser to a greater value) direction, and [[Below]] and [[Under]] are transposable and specify a downward (greater to a lesser value) direction.
* The plot of A is defined as having crossed [[Above]] or [[Over]] the plot of B if the value of A is greater than the value of B and one of the following is true:  


a) The value of A was more than the value of B on the bar immediately preceding the current bar,  
::The value of A was less than the value of B on the bar immediately preceding the current bar,  
::'''or'''
::The values of A and B were equal for a consecutive sequence of one or more bars immediately preceding the current bar and the value of A was less than the value of B on the bar immediately preceding this sequence of bars.


or
* The plot of A is defined as having crossed [[Below]] or [[Under]] the plot of B if the value of A is less than the value of B and one of the following is true:


b) The values of A and B were equal for a consecutive sequence of one or more bars immediately preceding the current bar and the value of A was more than the value of B on the bar immediately preceding this sequence of bars.  
::The value of A was more than the value of B on the bar immediately preceding the current bar,
::'''or'''
::The values of A and B were equal for a consecutive sequence of one or more bars immediately preceding the current bar and the value of A was more than the value of B on the bar immediately preceding this sequence of bars.  
   
   
==== Usage ====
== Examples ==
<syntaxhighlight>E1 Cross Direction E2</syntaxhighlight>
Trigger an alert on the bar where the Close price crosses above 1350.00:
or:  
<syntaxhighlight>Plot1 Cross Direction Plot2</syntaxhighlight>


Where: [[E]] - a numerical expression
<syntaxhighlight>Plot1(Close);
 
[[Direction]] - a required parameter; specifies the direction of the cross
==== Example ====
<syntaxhighlight>Trigger an alert on the bar where the Close price crosses above 1350.00:


Plot1(Close);
If Plot1 Cross Above 1350.50 Then
If Plot1 Cross Above 1350.50 Then
Alert("Price has crossed above 1350.00");</syntaxhighlight>
    Alert("Price has crossed above 1350.00");</syntaxhighlight>


To open a long position if the close crosses above the 20-period moving average:
<syntaxhighlight>
if Close cross above Average(Close, 20) then
Buy 2 contracts next bar at market;
</syntaxhighlight>


[[Category:Comparisons and Loops]]
[[Category:Comparisons and Loops]]

Latest revision as of 10:02, 19 February 2012

Returns a value of True if, on the current bar, the plot of a numerical expression A crossed the plot of a numerical expression B in the specified direction.

Usage

Plot1 Cross Direction Plot2

or:

E1 Cross Direction E2

Where:

E - a numerical expression.
Direction - a required parameter which specifies the direction of the cross.
Above, Over, Below or Under parameters are used to specify the direction of the cross.

Notes

  • Above and Over are transposable and specify an upward (lesser to a greater value) direction, and Below and Under are transposable and specify a downward (greater to a lesser value) direction.
  • The plot of A is defined as having crossed Above or Over the plot of B if the value of A is greater than the value of B and one of the following is true:
The value of A was less than the value of B on the bar immediately preceding the current bar,
or
The values of A and B were equal for a consecutive sequence of one or more bars immediately preceding the current bar and the value of A was less than the value of B on the bar immediately preceding this sequence of bars.
  • The plot of A is defined as having crossed Below or Under the plot of B if the value of A is less than the value of B and one of the following is true:
The value of A was more than the value of B on the bar immediately preceding the current bar,
or
The values of A and B were equal for a consecutive sequence of one or more bars immediately preceding the current bar and the value of A was more than the value of B on the bar immediately preceding this sequence of bars.

Examples

Trigger an alert on the bar where the Close price crosses above 1350.00:

Plot1(Close);

If Plot1 Cross Above 1350.50 Then
    Alert("Price has crossed above 1350.00");

To open a long position if the close crosses above the 20-period moving average:

if Close cross above Average(Close, 20) then
	Buy 2 contracts next bar at market;