Here are the two chunks of TS2000i code for testing the MACCI-653 in the way I've described.
The first chunk contains the Indicator and the extra code detect the signal to output it to a GV.
Lines highlighted in Blue are effectively the original code for the indicator.
Lines highlighted in Red are the additional lines of code added to grab the signal and output it to a globalvariable.
The second chunk picks up all the GV's and analyses them looking for a composite signal.
Note to programmers, I haven't bothered checking the Error code status's. It all seems to work well enough without that. Also the way T2W appears to treats spaces in a post means that the first Print line in the second chunk doesn't line up with the data in the second print line. This won't happen using proper ELS code. I posted this way to highlight things using colours
CHUNK 1:-
inputs:
Length1(6),
Length2(5),
Length3(3);
Vars: CCIval(0), CCIavg(0), MACCI( 0 ), MacciT(0), RtnVal( 0 ),SIGNAL(0) ;
CCIval = CCI(Length1);
MACCI = average(CCIval, Length2);
MACCIT = average(CCIval, Length3); {MACCIT is the Trigger line}
If MACCI >80 then begin
If MACCIT < MACCI then Signal = 2
else Signal = 0 ;
End;
If MACCI < -80 then begin
If MACCIT > MACCI then Signal = 1
else Signal = 0;
End;
If MACCI < 80 and MACCI > -80 then begin
If MACCIT > MACCI then Signal = 1
else begin If MACCIT < MACCI then Signal = 2;
End; end;
if RtnVal >= 0 then
Plot1( MACCI, "1m" ) ;
Plot2(MACCIT,"MT");
Plot3(Signal,"Signal");
If Signal = 2 then begin
RtnVal = GVSetNamedFloat( GetSymbolName + "76", SIGNAL );
end;
{COMMENT - GetSymbolName + "76", is the Globalvariable name for this timeframe i.e. 60 mins. For other timeframes it will be different as can be seen in the second chunk of code below.
If Signal = 1 then begin
RtnVal = GVSetNamedFloat( GetSymbolName + "76", SIGNAL );
end;
If Signal = 0 then begin
{RtnVal = GVSetNamedFloat( GetSymbolName + "76", SIGNAL );
end;
Value1 = Ticks ; { Force RadarScreen to update every tick. }
------------------------------------------
CHUNK 2 (this code is the same for all tests) :-
inputs:
ErrorCode1( -1 ) ,
ErrorCode2( -1 ) ,
ErrorCode3( -1 ),
ErrorCode4( -1 ) ,
ErrorCode5( -1 ) ,
ErrorCode6( -1 ) ;
variables:
RtnVal1( 0 ) ,
RtnVal2( 0 ) ,
RtnVal3( 0 ) ,
RtnVal4( 0 ) ,
RtnVal5( 0 ) ,
RtnVal6( 0 ) ,
Message( "" ),
Signal(0);
if LastBarOnChart then begin
RtnVal1 = GVGetNamedFloat( GetSymbolName + "71", ErrorCode1 ) ; {60 mim}
RtnVal2 = GVGetNamedFloat( GetSymbolName + "72", ErrorCode2 ) ; {30 min}
RtnVal3 = GVGetNamedFloat( GetSymbolName + "73", ErrorCode3 ) ; {10 min}
RtnVal4 = GVGetNamedFloat( GetSymbolName + "74", ErrorCode3 ) ; {5 min}
RtnVal5 = GVGetNamedFloat( GetSymbolName + "75", ErrorCode3 ) ; {3 min}
RtnVal6 = GVGetNamedFloat( GetSymbolName + "76", ErrorCode3 ) ; {1 min}
end;
{Market Long or Short ?}
Condition1 = (Rtnval3 = 1 and Rtnval2 = 1) OR (Rtnval3 = 1 and Rtnval1 = 1); {10 and 60or30 Long}
Condition2 = (Rtnval3 = 2 and Rtnval2 = 2) OR (Rtnval3 = 2 and Rtnval1 = 2); {10 and 60or30 Short}
{Entry Long or Short ?}
Condition3 = (Rtnval6 = 1 and Rtnval5 = 1) OR (Rtnval6 = 1 and Rtnval4 = 1); {1 and 3or5 Long}
Condition4 = (Rtnval6 = 2 and Rtnval5 = 2) OR (Rtnval6 = 2 and Rtnval4 = 2); {1 and 3or5 Short}
Plot1(" ","Alert");
If Condition1 and Condition3 then begin
Plot1("LONG ","Alert");
SetPlotBgColor(1, cyan);
Print(Playsound("C:\sierrachart\alertsound2.wav"));
Print(Date,Time," 60"," 30"," 10"," 5"," 3"," 1"," LONG");
Print(Date,Time," ",Rtnval1," ",rtnval2," ",rtnval3," ",rtnval4," ",rtnval5," ",rtnval6,"LONG");
end;
If Condition3 and Condition4 then begin
Plot1("SHORT ","Alert");
SetPlotBgColor(1, Red);
Print(Playsound("C:\sierrachart\alertsound2.wav"));
{COMMENT - the line of code above plays a sound file when a composite signal is detected. It can be removed or altered to use a sound file from your own PC}
Print(Date,Time," 60"," 30"," 10"," 5"," 3"," 1"," SHORT");
Print(Date,Time," ",Rtnval1," ",rtnval2," ",rtnval3," ",rtnval4," ",rtnval5," ",rtnval6,"SHORT");
End;
Value1 = Ticks ; { Force RadarScreen to update every tick. }