ADE Sync / Updating Help Needed

Questions about MultiCharts and user contributed studies.
eegroup
Posts: 78
Joined: 04 Aug 2008
Has thanked: 11 times
Been thanked: 9 times

ADE Sync / Updating Help Needed

Postby eegroup » 21 Sep 2017

We have a need to have the following setup:
  • * A Signal/Strategy loaded in SubChart 1, the same SubChart where the Instrument Price Bars are loaded (Daily Bar Resolution).
    * The Strategy will calculate an indicator value, which will be used to trigger trades in the Strategy and subsequently execute the trades.
    * Using ADE. the Strategy will load the calculated indicator values into an InfoMap into memory.
    * A separate Indicator will then retrieve those indicator values calculated by the Strategy from the InfoMap and then plot the Indicator values in SubChart2 (in the same workspace).

The Strategy can then be optimized. If the input parameters used to calculate the indicator values change (different length setting is selected from the optimization results), the Strategy will recalculate the indicator values and reload the InfoMap into memory with the new values.

And since the Strategy is always calculated first on a workspace, the InfoMap, with the calculated indicator values, is always available before the plotting Indicator requires them.

That much works perfectly. The issue is that when the length input parameters are changed (through optimization result selection or changed manually in the Input Parameters of the Strategy), the Indicator in SubChart 2 does not replot itself with new values.

Questions:

1. How do we force the Indicator to replot when new values have been placed into the InfoMap, or otherwise periodically, to ensure that the Indicator has plotted what the Strategy is currently seeing and executing trades against?

2. How do we force the Indicator to replot, at the very least., the last bar on the chart (intrabar) as real time data is being delivered to the workspace, which could most likely change the calculated Indicator value for the last bar on the chart?

3. If we are loading the InfoMap in memory with the Indicator values, is there any coding that we can add to the Indicator to ensure that it does not attempt to access the InfoMap until AFTER the Strategy has loaded the InfoMap with the calculated Indicator values, to prevent the occasional ADE error from occurring ("No data available for Class")?

We have attempted to use Recalculate and RecalcLastBarAfter without success, but there is obviously more needed than a simple application of either of those two commands.

Thank you for any help and assistance that can be provided. Very much appreciated.

Sample Strategy and Indicator are shown below.

Sample Strategy

Code: Select all

Inputs:
XAvgLength (92);

Variables:
XAvg (0),
XAvgDir (0),
Class ("XAverage"),
InfoMap (MapSN.New);

XAvg = XAverage(Close, XAvgLength);

If XAvg >= XAvg[1]
Then XAvgDir = 1
Else XAvgDir = -1;

Value1 = MapSN.Put(InfoMap, "XAvg", XAvg);
Value1 = MapSN.Put(InfoMap, "XAvgDir", XAvgDir);
Value1 = ADE.PutBarInfo(Class, GetSymbolName, ADE.BarInterval, ADE.BarID, InfoMap);

If XAvgDir[1] = -1
And XAvgDir = 1
Then Buy ("Buy") Next Bar At Market;

If XAvgDir[1] = 1
And XAvgDir = -1
Then SellShort ("Sell") Next Bar At Market;
Sample Indicator

Code: Select all

Variable:

Interval (0),
Class ("XAverage"),
InfoMap (MapSN.New),
MyXAvg (0),
MyXAvgDir (0),
XAvgColor (0);

Value1 = ADE.GetBarInfo(Class, GetSymbolName, Interval, ADE.BarID, InfoMap);

MyXAvg = MapSN.Get(InfoMap, "XAvg");
MyXAvgDir = MapSN.Get(InfoMap, "XAvgDir");

IF MyXAvgDir = 1
Then XAvgColor = darkgreen
Else XAvgColor = red;

PLOT1(MyXAvg, "XMA", XAvgColor);


Sample chart setup is attached. Strategy is loaded in SubChart 1. Indicator is a loaded in SubChart 2.
ADE Test Workspace.PNG
(62.81 KiB) Downloaded 403 times

Return to “MultiCharts”