Custom Codes with Datafields

Is it possible to create a custom code for a specific security using a datafield. For example if I wanted to have a code of the TTM P/E (Trail_12M_EPS) of the Russell 1000 Value index (RLV Index BLBM) and one of the Russell 1000 Growth (RLG Index BLBM) so that I can create a ratio of the two data streams....

Hi Duke,

Sure can! Once the Trail_12M_EPS field has been added as an External Datafield you can use the following as a custom code by nesting the GetData variable in the Datafield function:

//Get the  required symbols
V1 = GETDATA(CODE=RLV INDEX:BLMB);
G1 = GETDATA(CODE=RLG INDEX:BLMB);
//Nest the variables in the Datafield function
RLVTTM = DATAFIELD(V1, FIELD=TRAIL_12M_EPS);
RLGTTM = DATAFIELD(G1, FIELD=TRAIL_12M_EPS);
//Calc the ratio
RLVTTM / RLGTTM

Note that the EPS data seems to move the most at the end of the month, hence the shape of the ratio chart, but with RLV TTM currently at 59.65 and RLG at 50.6 the current ratio of 1.18 is correct:

Capture