TRO PERCENT TRUE
Posted: Tue May 22, 2007 1:14 am
TRO PERCENT TRUE
The Architect likes to use a Percent True function for his plots.
I couldn't find anything like it in TradeStation so I wrote the _TRO_PctTrue indicator and _fPctTrue function.
You give it a true/false input statement and number of bars to test and it returns how many times the input statement was true as a percentage.
Simple, yet elegant.
ELD and WORKSPACE attached.
And for you 2000i folks:
The Architect likes to use a Percent True function for his plots.
I couldn't find anything like it in TradeStation so I wrote the _TRO_PctTrue indicator and _fPctTrue function.
You give it a true/false input statement and number of bars to test and it returns how many times the input statement was true as a percentage.
Simple, yet elegant.
ELD and WORKSPACE attached.
And for you 2000i folks:
Code: Select all
{ _TRO_SAK_HL }
{Attn: TradeStation
if this indicator is posted on the TradeStation Forum, I, TheRumpledOne, did NOT post it there,
so I can't be blamed for this indicator having my contact info.}
{Programmer: Avery T. Horton, Jr. aka TheRumpledOne,
gifts and donations accepted, PO Box 43575, Tucson, AZ 85733 }
{ ? Copyright 2007 Avery T. Horton, Jr.}
inputs:
iInd( c > c[1] ),
iIndStr("c > c[1]"),
iTestBars(100),
iColor( white ),
iOver( 90 ),
iOverMsg("Over" ),
iOverColor( cyan ),
iUnder( 10 ),
iUnderMsg("Under" ),
iUnderColor( Red ) ;
vars: Answer(0), x(0);
variables:
xAppType(0),
sFirstPass(true),
xInd(0),
tIND(""),
tMsg(""),
xBlank(" "),
FG1(white),
BG1(black),
fg2(white),
bg2(black),
fg3(white),
bg3(black),
fg4(white),
bg4(black),
vdummy("");
{commentary variables}
variables:
xcomm(0),
oComm1( "" ),
oComm2( "" ),
oComm3( "" ),
oComm4( "" ),
oComm5( "" ),
oComm6( "" ),
oComm7( "" ),
oComm8( "" ),
oComm9( "" ),
oComm10( "" );
{first time through}
if sFirstPass
then begin
xAppType = GetAppInfo(aiApplicationType); // returns a value that identifies the calling window type
sFirstPass = false;
end; {if sFirstPass}
{ INITIALIZE }
tIND = "";
tMsg = "";
FG1 = iColor;
BG1 = BLACK;
fg2 = iColor;
bg2 = BLACK;
fg3 = iColor;
bg3 = BLACK;
fg4 = iColor;
bg4 = BLACK;
Answer = 0;
For x = 0 to ( iTestBars - 1 ) begin
if iInd[x]
then Answer = Answer + 1;
end;
xInd = (Answer / iTestBars ) * 100 ;
{ CHECK OVER/UNDER }
If xInd > iOver
then begin
tMsg = iOverMsg + xBlank + NumToStr( iOver, 0 );
Bg4 = BLACK;
Fg4 = iOverColor;
bg1 = BLACK;
fg1 = iOverColor;
end
else
If xInd < iUnder
then begin
tMsg = iUnderMsg + xBlank + NumToStr( iUnder , 0 );
Bg4 = BLACK;
Fg4 = iUnderColor;
bg1 = BLACK;
fg1 = iUnderColor;
end;
{ PLOT }
Plot1( xIND, "%True", fg1 ) ;
SetPlotBGColor( 1, bg1);
if xAppType = 2
then begin
Plot2( iIndStr, "IND", fg2 ) ;
SetPlotBGColor( 2, bg2);
Plot4( tMsg, "Msg", FG4 ) ;
SetPlotBGColor( 4, bg4);
end;
{ Commentary }
xComm = _fCommentary(oComm1, oComm2, oComm3, oComm4, oComm5, oComm6, oComm7, oComm8, oComm9, oComm10);
CommentaryCl(oComm1 );
CommentaryCl(oComm2 );
CommentaryCl(oComm3 );
CommentaryCl(oComm4 );
CommentaryCl(oComm5 );
CommentaryCl(oComm6 );
CommentaryCl(oComm7 );
CommentaryCl(oComm8 );
CommentaryCl(oComm9 );
CommentaryCl(oComm10 );
CommentaryCl( "column 1 is SLOT MACHINE directional indicator ");
CommentaryCl( "column 2 is indicator value");
CommentaryCl( "column 3 is number of bars this trend");
CommentaryCl( "column 4 indicates o/b, o/s, crossovers, divergence");
CommentaryCl(" " );
CommentaryCl( xInd, ": ", NumToStr(xIND,0) );
CommentaryCl(" " );
CommentaryCl( "Close, : ", NumToStr(close,0) );
CommentaryCl(" " );