GetAppInfo

From MultiCharts
Revision as of 16:43, 28 February 2012 by Sbokov (talk | contribs)
Jump to navigation Jump to search

Returns a numerical value, representing the specified attribute of the calling application.

Usage

GetAppInfo(Attribute)

Parameters

aiBarSpacing - returns a value indicating the bar spacing of a chart (i.e. the value found in the Format Window -> X-Time scale screen).
aiCalcReason - specifies return of the calculation reason (one of the 4 options below). GetAppInfo will return the value, indicating the reason of calculation initialization.
CalcReason_Default - calculation is to be initialized when the new bar/tick appeared.
CalcReason_MouseLClick – calculation is to be initialized after left-click on the chart.
CalcReason_MouseRClick - calculation is to be initialized after right-click on the chart.
CalcReason_Timer – the calculation is to be initialized after expiration of RecalcLastBarAfter timeout.
aiHighestDispValue - returns the highest price value that could be displayed on a chart.
aiLowestDispValue - returns the lowest price value that could be displayed on a chart.
aiLeftDispDateTime - returns the DateTime value of the leftmost bar displayed on a chart. The integer portion of the DateTime value specifies the number of days since January 1st, 1900, and the fractional portion of the DateTime value specifies the fraction of the day since midnight. See the category Date & Time Routines for the reserved words for working with DateTime values.
aiRightDispDateTime - returns the DateTime value of the rightmost bar displayed on a chart. The integer portion of the DateTime value specifies the number of days since January 1st, 1900, and the fractional portion of the DateTime value specifies the fraction of the day since midnight. See the category Date & Time Routines for the reserved words for working with DateTime values.
aiSpaceToRight - returns the right margin, in number of bars, of a chart.
aiOptimizing - returns a value of 1 if the calling application is currently performing an optimization, and a value of 0 in all other cases.
aiStrategyAuto - returns a value of 1 if the calling application is using Automated Trade Execution, and a value of 0 in all other cases.
aiStrategyAutoConf - returns a value of 1 if the calling application is using Automated Trade Execution with Order Confirmation turned off, and a 1 in all other cases.
aiIntrabarOrder - returns a value of 1 if the calling application is running the signal with intra-bar order generation turned on, and a value of 0 in all other cases.
aiAppId - returns an unique non-zero integer identifying the calling application.
aiRealTimeCalc - returns a value of 1 if the calling application is performing calculation based on real-time data. Will return a value of 0 in all other cases.

Notes

  • GetAppInfo(aiRealTimeCalc) will also return a value of 1 when it's called during PlayBack mode or if the script uses RecalcLastBarAfter.

For example:

if (LastBarOnChart_s = True) then begin

	Print(FormatTime("HH:mm:ss - ", ELTimeToDateTime_s(CurrentTime_s)), 
		"GetAppInfo(aiRealTimeCalc): ", GetAppInfo(aiRealTimeCalc));

	RecalcLastBarAfter(2);
end;

Will return a value of 0 on the initialisation of the indicator (i.e. when it's started), but after that a value of 1 after each forced recalculation.

07:17:54 - GetAppInfo(aiRealTimeCalc):    0.00
07:17:56 - GetAppInfo(aiRealTimeCalc):    1.00
07:17:58 - GetAppInfo(aiRealTimeCalc):    1.00
07:18:00 - GetAppInfo(aiRealTimeCalc):    1.00

Examples

GetAppInfo(aiBarSpacing)

Will return a value indicating the bar spacing of a chart.

GetAppInfo(aiStrategyAutoConf)

Will return a value of 0 if the calling application is using Automated Trade Execution with order confirmation turned off; otherwise aiStrategyAutoConf will return a value of 1.

GetAppInfo(aiRealTimeCalc)

Will return a value of 1 if the calling application’s calculations are based on real-time or PlayBack data; otherwise, will return a value of 0.

Using GetAppInfo for Chart Window information

The example below uses the Print keyword to print information about the current Chart Window to the PowerLanguage Editor output log:

// Example: Getting data about the chart window using GetAppInfo	
if LastBarOnChart_s = True then begin

	Print("The leftmost date on this chart is ", FormatDate("MM/dd/yyyy", GetAppInfo(aiLeftDispDateTime)),
		", and the rightmost date on this chart is ", FormatDate("MM/dd/yyyy", GetAppInfo(aiRightDispDateTime)));
		
	Print(NewLine, 
		"The leftmost bar closes at ", FormatTime("HH:mm:ss", GetAppInfo(aiLeftDispDateTime)), 
		" and the rightmost bar closes at ", FormatTime("HH:mm:ss", GetAppInfo(aiRightDispDateTime)) );
		
	Print(NewLine, 
		"The highest price on the Y axis (price scale) is ", NumToStr( GetAppInfo(aiHighestDispValue), 0),
		" and the lowest price on the same axis is ", NumToStr( GetAppInfo(aiLowestDispValue), 0));

end;

This would give an output similar to:

The leftmost date on this chart is 01/20/2012, and the rightmost date on this chart is 01/20/2012

The leftmost bar closes at 12:31:16 and the rightmost bar closes at 21:56:15

The highest price on the Y axis (price scale) is 2438 and the lowest price on the same axis is 2411

Using GetAppInfo to monitor an ATS

In the simplified example below, the GetAppInfo(aiStrategyAuto) is used to monitor the status of an Automated Trading Strategy. If the ATS is turned off, a sound alert is given.

// Example: using the GetAppInfo(aiStrategyAuto) to monitor for an Automated Trading
//		Strategy that gets turned off.

Variables:
   IntraBarPersist PrevATSStatus(0),   	// Holds the status of the ATS at the previous update
   atsStatus(0);						// Holds the current ATS status

if (LastBarOnChart_s = True) then begin

   atsStatus    = GetAppInfo(aiStrategyAuto);
   
   // If the current ATS Status is different from the previous, and the previous
   //      status was ON, give an sound alert.
   if (atsStatus <> PrevATSStatus) and (PrevATSStatus = 1) then begin
   
		PlaySound("C:\Temp\atsTurnedOff.wav");

   end;

   PrevATSStatus    = atsStatus;

   RecalcLastBarAfter(15);	// Update every 15 seconds, even if the data feed stops updating
   
end;