using elsystem;
input:
int FuturesOnly_Or_FuturesAndOptions_1_or_2( 1 ) [
DisplayName = "FuturesOnly_Or_FuturesAndOptions_1_or_2",
ToolTip = "Enter 1 to use the 'futures only' report; enter 2 to use the 'futures and options' report."],
weeks_back(34);
variables:
bool Initialized( false ),
string FieldNamePrefix( "" ),
string CommLongFieldNme( "" ),
string CommShortFieldNme( "" ),
string NonCommLongFieldNme( "" ),
string NonCommShortFieldNme( "" ),
string SpecLongFieldNme( "" ),
string SpecShortFieldNme( "" ),
double CommLong( 0 ),
double oCommLongErr( 0 ),
double CommShort( 0 ),
double oCommShortErr( 0 ),
double NonCommLong( 0 ),
double oNonCommLongErr( 0 ),
double NonCommShort( 0 ),
double oNonCommShortErr( 0 ),
double SpecLong( 0 ),
double oSpecLongErr( 0 ),
double SpecShort( 0 ),
double oSpecShortErr( 0 ),
double CommNet( 0 ),
double NonCommNet( 0 ),
double SpecNet( 0 ),
double Min_Net_C (0),
double Max_Net_C (0),
double COM_Index (0),
double LS_Index (0),
double SS_Index (0),
double Min_Net_LS(0),
double Max_Net_LS(0),
double Min_Net_SS(0),
double Max_Net_SS(0);
if Initialized = false then
begin
if Category > 0 then
throw Exception.Create( !( "Commitments of Traders studies can be applied only to futures symbols." ) );
Initialized = true;
if FuturesOnly_Or_FuturesAndOptions_1_or_2 = 1 then
FieldNamePrefix = "COTF-"
else
FieldNamePrefix = "COTC-";
CommLongFieldNme = FieldNamePrefix + "12";
CommShortFieldNme = FieldNamePrefix + "13";
NonCommLongFieldNme = FieldNamePrefix + "9";
NonCommShortFieldNme = FieldNamePrefix + "10";
SpecLongFieldNme = FieldNamePrefix + "16";
SpecShortFieldNme = FieldNamePrefix + "17";
end;
CommLong = FundValue( CommLongFieldNme, 0, oCommLongErr );
CommShort = FundValue( CommShortFieldNme, 0, oCommShortErr);
NonCommLong = FundValue( NonCommLongFieldNme, 0, oNonCommLongErr );
NonCommShort = FundValue( NonCommShortFieldNme, 0, oNonCommShortErr );
SpecLong = FundValue( SpecLongFieldNme, 0, oSpecLongErr );
SpecShort = FundValue( SpecShortFieldNme, 0, oSpecShortErr );
if oCommLongErr = fdrOk and oCommShortErr = fdrOk then
begin
CommNet = CommLong - CommShort;
Min_Net_C = (Lowest (CommNet, weeks_back));
Max_Net_C = (Highest (CommNet, weeks_back));
COM_Index = IFF(Max_Net_C - Min_Net_C <>0, 100*(CommNet - Min_Net_C) / (Max_Net_C - Min_Net_C),1);
Plot1( COM_Index, !( "Comm" ) );
end;
if oNonCommLongErr = fdrOk and oNonCommShortErr = fdrOk then
begin
NonCommNet = NonCommLong - NonCommShort;
Min_Net_LS = (Lowest (NonCommNet, weeks_back));
Max_Net_LS = (Highest (NonCommNet, weeks_back));
LS_Index = IFF(Max_Net_LS - Min_Net_LS <>0, 100*(NonCommNet - Min_Net_LS) / (Max_Net_LS - Min_Net_LS),1);
Plot2( LS_Index, !( "LargeSpec" ) );
end;
if oSpecLongErr = fdrOk and oSpecShortErr = fdrOk then
begin
SpecNet = SpecLong - SpecShort;
Min_Net_SS = (Lowest (SpecNet, weeks_back));
Max_Net_SS = (Highest (SpecNet, weeks_back));
SS_Index = IFF(Min_Net_SS - Max_Net_SS <>0, 100*(SpecNet - Min_Net_SS) / (Max_Net_SS - Min_Net_SS),1);
Plot3( SS_Index, !( "SmallSpec" ) );
end;
|