×

Sign up and get MultiCharts free

Use its powerful simulation mode with data included out of the box. Just fill out the form and start honing your trading skills with a few clicks.

Changes - MultiCharts
Open main menu

Changes

GetAppInfo

4,809 bytes added, 31 January
Returns a numerical value, representing the specified attribute of the calling application.
==== Usage ====
<syntaxhighlight>GetAppInfo(Attribute)</syntaxhighlight>
==== Parameters ==== [[aiBarSpacing]] - specifies return of the number of spaces between the bars on a chart GetAppInfo will return a value, indicating the bar spacing of a chart.
[[aiHighestDispValue]] - specifies return of :'''aiApplicationType''' — identifies the highest price value that could be displayed in the current chart window GetAppInfo will return the highest price value that could be displayed on a chart. calling application:<br>:*Unknown = 0:*Chart = 1:*Scanner = 2:*Portfolio Trader = 10
[[aiLowestDispValue]] - specifies return :'''aiBarSpacing''' — returns a value indicating the bar spacing of a chart (i.e. the lowest price value that could be displayed found in the current chart window GetAppInfo will return the lowest price value that could be displayed on a chart''Format Window'' -> ''X-Time scale screen'').
[[aiLeftDispDateTime]] - specifies return of the date and time of the leftmost bar displayed in the current chart window GetAppInfo will return the DateTime value of the leftmost bar displayed on :'''aiCalcReason''' — returns a chart; the integer portion of the DateTime numerical value specifies the number of days since January 1st, 1900, and indicating the fractional portion reason of the DateTime value specifies the fraction of the day since midnightcalculation initialization (i.e. returns 0 when calculation was triggered by a new bar/tick(CalcReason_Default)):
[[aiRightDispDateTime]] - specifies return of the date and time of :: '''0 (CalcReason_Default)''' — calculation is to be initialized when the rightmost new bar displayed in /tick appeared.:: '''1 (CalcReason_MouseLClick)''' — calculation is to be initialized after left-click on the current chart window GetAppInfo will return .:: '''2 (CalcReason_MouseRClick)''' — calculation is to be initialized after right-click on the DateTime value of the rightmost bar displayed on a chart; the integer portion . :: '''3 (CalcReason_Timer)''' — calculation is to be initialized after expiration of RecalcLastBarAfter timeout.:: '''4 (CalcReason_MPChange)''' — calculation is to be initialized after market position for the DateTime value specifies instrument has been changed (for signals only). :: '''5 (CalcReason_OrderFilled)''' — calculation is to be initialized after order filled event (for signals only).:: '''6 (CalcReason_OrderRejected)''' — calculation is to be initialized after order rejected event (for signals only). :: '''7 (CalcReason_UserClosePosition)''' — calculation is to be initialized after the number of days since January 1st, 1900, and user clicks the fractional portion of Close Position button in Portfolio Trader. :'''aiHighestDispValue''' — returns the DateTime highest price value specifies the fraction of the day since midnightthat could be displayed on a chart.
[[aiSpaceToRight]] - specifies return of :'''aiLowestDispValue''' — returns the right margin, in bars, of the current chart window GetAppInfo will return the right margin, in bars, of lowest price value that could be displayed on a chart.
[[aiOptimizing]] - specifies return :'''aiLeftDispDateTime''' — returns the DateTime value of the leftmost bar displayed on a numerical chart. The integer portion of the DateTime valuespecifies the number of days since January 1st, indicating whether 1900, and the calling application is currently performing an optimization GetAppInfo will return a value fractional portion of 1 only if the calling application is currently performing an optimization, and a DateTime value specifies the fraction of 0 in all other casesthe day since midnight. See the category [[:Category:Date_and_Time_Routines|Date & Time Routines]] for the reserved words for working with DateTime values.
[[aiStrategyAuto]] - specifies return :'''aiRightDispDateTime''' — returns the DateTime value of the rightmost bar displayed on a numerical chart. The integer portion of the DateTime valuespecifies the number of days since January 1st, indicating whether 1900, and the calling application is using Automated Trade Execution GetAppInfo will return a value fractional portion of 1 only if the calling application is using Automated Trade Execution, and a DateTime value specifies the fraction of 0 in all other casesthe day since midnight. See the category [[:Category:Date_and_Time_Routines|Date & Time Routines]] for the reserved words for working with DateTime values.
[[aiStrategyAutoConf]] :'''aiRow''' - specifies return of Identifies the symbol's row number in Scanner. Returns a numerical positive non-zero value, indicating whether the calling from a Scanner application is using Automated Trade Execution with order confirmation turned off GetAppInfo will return a value of else returns 0 only if the calling application is using Automated Trade Execution with order confirmation turned off, and a value of 1 in all other cases.
[[aiIntrabarOrder]] - specifies return :'''aiSpaceToRight''' — returns the right margin, in number of a numerical valuebars, indicating whether the calling application is running the signal with intra-bar order generation turned on GetAppInfo will return a value of 1 only if the calling application is running the signal with intra-bar order generation turned on, and a value of 0 in all other caseschart.
[[aiAppId]] - specifies return of :'''aiOptimizing''' — returns a numerical value, used to identify of 1 if the calling application GetAppInfo will return is currently performing an optimization, and a unique non-zero integer identifying the calling applicationvalue of 0 in all other cases.
[[aiRealTimeCalc]] - specifies return of a numerical value, indicating whether the calling application’s calculations are based on real-time data GetAppInfo will return :'''aiStrategyAuto''' — returns a value of 1 only if the calling application’s calculations are based on real-time dataapplication is using [[Understanding_Automated_Trade_Execution|Automated Trade Execution]], and a value of 0 in all other cases. ==== Example ====<syntaxhighlight>GetAppInfo(aiBarSpacing) will return a value, indicating the bar spacing of a chart
GetAppInfo(:'''aiStrategyAutoConf) will return ''' — returns a value of 0 1 if the calling application is using [[Understanding_Automated_Trade_Execution|Automated Trade Execution ]] '''with order confirmation ''' Order Confirmation turned off; otherwise, will return and a value of 1 in all other cases.
:'''aiIntrabarOrder''' — returns a value of 1 if the calling application is running the signal with [[IntraBarOrderGeneration|intra-bar order generation]] turned on, and a value of 0 in all other cases. :'''aiAppId''' — returns a 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. :'''aiChartShiftPercent''' — returns the ChartShift value in percents from Format Window -> X - Time Scale. The value is updated on the fly. :<div style="background-color: #E5F6FF;">aiSimulatedTradingMode is available in MultiCharts 15 Open Beta.</div>:'''aiSimulatedTradingMode''' — returns a numerical value, indicating Simulated trading mode:::'''0''' – No Simulated Trading is running.::'''1''' – Standard Simulated Trading mode is enabled.::'''2''' – Advanced Simulated Trading mode is enabled. == 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:<syntaxhighlight>if (LastBarOnChart_s = True) then begin  Print(FormatTime("HH:mm:ss - ", ELTimeToDateTime_s(CurrentTime_s)), "GetAppInfo(aiRealTimeCalc): ", GetAppInfo(aiRealTimeCalc));  RecalcLastBarAfter(2);end;</syntaxhighlight>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.<syntaxhighlight>07:17:54 - GetAppInfo(aiRealTimeCalc): 0.0007:17:56 - GetAppInfo(aiRealTimeCalc): 1.0007:17:58 - GetAppInfo(aiRealTimeCalc): 1.0007:18:00 - GetAppInfo(aiRealTimeCalc): 1.00</syntaxhighlight> == Examples ==<syntaxhighlight>GetAppInfo(aiBarSpacing)</syntaxhighlight>Will return a value indicating the bar spacing of a chart. <syntaxhighlight>GetAppInfo(aiStrategyAutoConf)</syntaxhighlight>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. <syntaxhighlight>GetAppInfo(aiRealTimeCalc)</syntaxhighlight>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. <syntaxhighlight>[ProcessMouseEvents = true]; switch (getappinfo(aicalcreason)) begin case CalcReason_MouseLClick : if MouseClickCtrlPressed then begin var: var0(0), var1(0); repeat if 0 = var0 then begin var0 = MouseClickDateTime; break; end; until(false); end; end; var1 = datetime2eltime(var0); print("Time of the Bar = ", var1);</syntaxhighlight>Will return the time of the bar after left click on it pressing '''Ctrl''' button on the keyboard. === Using GetAppInfo for Chart Window information ===The example below uses the [[Print]] keyword to print information about the current [[Chart_Window|Chart Window]] to the PowerLanguage Editor output log:<syntaxhighlight>// 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;</syntaxhighlight>This would give an output similar to:<syntaxhighlight>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</syntaxhighlight> === Using GetAppInfo to monitor an ATS ===In the simplified example below, the GetAppInfo(aiStrategyAuto) is used to monitor the status of an [[:Category:AutoTrading|Automated Trading Strategy]]. If the ATS is turned off, a sound alert is given. <syntaxhighlight>// 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; </syntaxhighlight>
[[Category:Environment Information]]