Importing a TS Strategy into MC with global variables

Questions about MultiCharts and user contributed studies.
The9000
Posts: 59
Joined: 24 Oct 2015
Has thanked: 2 times
Been thanked: 4 times

Importing a TS Strategy into MC with global variables

Postby The9000 » 25 Oct 2015

Hi,

I'm new to MC and have moved all of my TS code over with the exception of one strategy. It uses the Global Dictionary in TS to send data between two strategies. I did my due diligence and installed the elcollections and functions. I still get the same error when I try to compile it in MC.

Each chart uses 2 minute bars.

What this strategy does is it runs two (almost) identical strategies (A) and (B) in two different charts. Strategy A passes the value of it's equity curve to strategy B which then toggles the strategy on or off based on filter criteria. Below is an example of my code.

Put Strategy:

Code: Select all

Using elsystem.collections;

Vars: GlobalDictionary GD(null);

method override void InitializeComponent()
begin
GD = GlobalDictionary.Create(false,"IES");
end;

< standard strategy code - then at the bottom of the code the following builds an array with the equity curve and pitches it to the other strategy >

//------------------Set up Global Dictionary Pitcher------------------------
Inputs:
UniquePitcherName("A100"), //This can be changed to allow different variations of the same test
LRSlopeLen(30);

Array: a_NetPL[](0);
condition1 = Array_setmaxindex(a_NetPL,LRSlopeLen);

Vars: MainGDName(Symbol+"_"+numtostr(bartype,0)+"_"+numtostr(barinterval,0)+ UniquePitcherName+"_"),
FullGDName(""),
Dstr(""),
Tstr(""),
TotTds(0),
oLRSlope( 0 ),
oLRAngle( 0 ),
oLRIntercept( 0 ),
oLRValueRaw( 0 ) ;


Dstr = numtostr(D,0);
Tstr = numtostr(T,0);
FullGDName = MainGDName + Dstr + Tstr;
TotTds = TotalTrades;

If TotTds > TotTds[1] then begin
For value1 = LRSlopeLen downto 2 begin
a_NetPL[value1] = a_NetPL[value1-1];
end;
a_NetPL[1] = netprofit;
If TotTds >= LRSlopeLen then Value1 = LinRegArray( a_NetPL, LRSlopeLen, 0, oLRSlope, oLRAngle, oLRIntercept, oLRValueRaw ) ;
end;

GD.Items[FullGDName] = oLRSlope astype double;
Any ideas on how to make this work in MC?

User avatar
TJ
Posts: 7742
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: Importing a TS Strategy into MC with global variables

Postby TJ » 25 Oct 2015

Hi,
I'm new to MC and have moved all of my TS code over with the exception of one strategy.
::
Any ideas on how to make this work in MC?
This is not pure EasyLanguage.
This code contains TS's new proprietary OOP extension.

You will need to re-code this strategy.

The9000
Posts: 59
Joined: 24 Oct 2015
Has thanked: 2 times
Been thanked: 4 times

Re: Importing a TS Strategy into MC with global variables

Postby The9000 » 25 Oct 2015

Thanks for the fast reply. The code runs in TS 9.1. 9.5 has a bug in the Global Dictionary and it compiles fine however it doesn't pitch the data back and forth between the strategies.

Any suggestions on how to do this using MC friendly code using global variables?

The strategy runs on 2 minute bars.


Return to “MultiCharts”