Difference between revisions of "RecalcLastBarAfter"

From MultiCharts
Jump to navigation Jump to search
Line 1: Line 1:
 
Initializes the calculation after expiration of the timeout, set in seconds.  
 
Initializes the calculation after expiration of the timeout, set in seconds.  
+
 
 +
RecalcLastBarAfter is used for the slow markets in which new ticks come in infrequently. Normally, calculation of the studies is performed in events when the immediate tick has come to a chart.
 +
 
 +
When the tick has not come since the moment of the last calculation and during timeout (sec) a new calculation is being initialized.
 +
 
 +
When the tick has been received before timeout expiration, time counter is reset and countdown for RecalcLastBarAfter(Timeout) starts anew.
 +
 
 
==== Usage ====
 
==== Usage ====
  
Line 7: Line 13:
 
Where: [[Timeout - the number of seconds.]]  
 
Where: [[Timeout - the number of seconds.]]  
 
   
 
   
==== Example ====
+
== Example ==
<syntaxhighlight>RecalcLastBarAfter is used for the slow markets. Calculation of the studies is performed in events
 
when the immediate tick has come to a chart.
 
  
When the tick has not come since the moment of the last calculation and during timeout (sec) a new
+
<syntaxhighlight>
calculation is being initialized.
+
if (LastBarOnChart_s = True) then begin
  
When the tick has been received before timeout expiration, time counter is reset and countdown for
+
  Print("Current time: ", FormatTime("HH:mm:ss", ELTimeToDateTime_s(CurrentTime_s)), ".");
RecalcLastBarAfter(Timeout) starts anew</syntaxhighlight>
+
 
+
  RecalcLastBarAfter(5);
 +
 
 +
end;
 +
</syntaxhighlight>
 +
 
 +
Returns the following:
 +
 
 +
<syntaxhighlight>
 +
Current time: 13:29:10.
 +
Current time: 13:29:15.
 +
Current time: 13:29:20.
 +
Current time: 13:29:25.
 +
Current time: 13:29:30.
 +
Current time: 13:29:35.
 +
Current time: 13:29:40.
 +
</syntaxhighlight>
 +
 
 +
Also note that in this example the RecalcLastBarAfter statement is only active if the condition returns true, meaning that if the current bar isn't the [[LastBarOnChart]], the RecalcLastBarAfter statement is not executed.
  
 
[[Category:Execution Control]]
 
[[Category:Execution Control]]

Revision as of 12:39, 27 January 2012

Initializes the calculation after expiration of the timeout, set in seconds.

RecalcLastBarAfter is used for the slow markets in which new ticks come in infrequently. Normally, calculation of the studies is performed in events when the immediate tick has come to a chart.

When the tick has not come since the moment of the last calculation and during timeout (sec) a new calculation is being initialized.

When the tick has been received before timeout expiration, time counter is reset and countdown for RecalcLastBarAfter(Timeout) starts anew.

Usage

RecalcLastBarAfter(Timeout)

Where: Timeout - the number of seconds.

Example

if (LastBarOnChart_s = True) then begin

   Print("Current time: ", FormatTime("HH:mm:ss", ELTimeToDateTime_s(CurrentTime_s)), ".");
   
   RecalcLastBarAfter(5);
   
end;

Returns the following:

Current time: 13:29:10.
Current time: 13:29:15.
Current time: 13:29:20.
Current time: 13:29:25.
Current time: 13:29:30.
Current time: 13:29:35.
Current time: 13:29:40.

Also note that in this example the RecalcLastBarAfter statement is only active if the condition returns true, meaning that if the current bar isn't the LastBarOnChart, the RecalcLastBarAfter statement is not executed.