Page 1 of 1

_TRO_FOREX_PipDiff

Posted: Thu Aug 16, 2007 4:23 pm
by TheRumpledOne

Code: Select all

{ _TRO_FOREX_PipDiff }
   

{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 2006 Avery T. Horton, Jr.}

inputs:
   iDecimals(4),
   iPlotMinMax(false),
   iPlotAvg(false),
   IndepData( Close of data1 ),
   DepData( Close of data2 ),
   iPeriods(60),
   iMaxDiffAlert( .63 ),
   iMinDiffAlert( .626 ) ;


variables:
 
xLowestLow(0),
xHighestHigh(0),

oExtremeVal( 0 ),
oExtremeBar( 0 ) ,

tAlert(""),

xMaxDiffDate(999999),   
xMinDiffDate(999999),

xMaxDiff(0),   
xMinDiff(999999999),
xAvgDiff(0),
xDiff(0);   

variables:
 
FG1(white),
BG1(black),

fg2(white),
bg2(black),

fg3(white),
bg3(black),

fg4(white),
bg4(black);

{commentary variables}
variables:
xcomm(0),
oComm1( "" ),    
oComm2( "" ),    
oComm3( "" ),    
oComm4( "" ),    
oComm5( "" ),
oComm6( "" ),
oComm7( "" ),
oComm8( "" ),
oComm9( "" ),    
oComm10( "" );
   
   
{ INITIALIZE }

tAlert  = "";

FG1 = WHITE;
BG1 = BLACK;

fg2 = WHITE;
bg2 = BLACK;

fg3 = WHITE;
bg3 = BLACK;

fg4 = WHITE;
bg4 = BLACK;


xDiff  = IndepData - DepData  ;

{ Alert criteria }


if xDiff > xMaxDiff
then begin
   xMaxDiff = xDiff ;
   xMaxDiffDate = Date ;
end
else
if xDiff < xMinDiff
then begin
   xMinDiff = xDiff ;
   xMinDiffDate = Date ;   
end;


xAvgDiff = ( xMaxDiff + xMinDiff ) *.5 ;


If xDiff     > xAvgDiff
then begin
   Fg1 = green;
   Bg1 = BLACK;
end
else
If xDiff     < xAvgDiff
then begin
   Fg1 = red;
   Bg1 = BLACK;
end
else
begin
   Fg1 = darkgray;
   Bg1 = BLACK;
end;

if xDiff = xMaxDiff
then begin
   Fg1 = cyan;
   Bg1 = BLACK;
end
else
if xDiff = xMinDiff
then begin   
   Fg1 = magenta;
   Bg1 = BLACK;
end;


{ Alert criteria }
if xDiff crosses over iMaxDiffAlert 
then begin
   tAlert   = "Maximum Diff  alert"  ;
   Fg1 = yellow;
end
else if xDiff crosses under iMinDiffAlert
then begin
   Alert( "Minimum Diff  alert" ) ;
   Fg1 = yellow;
end
else
if xDiff crosses over xAvgDiff 
then begin
   tAlert   =  "crosses over xAvgDiff alert"  ;
   Fg1 = yellow;
end
else if xDiff crosses under xAvgDiff
then begin
   tAlert   =  "crosses under xAvgDiff alert"  ;
   Fg1 = yellow;
end;

if xDiff > xAvgDiff 
then begin
   tAlert   = "Below Avg PipDiff";
end
else if xDiff < xAvgDiff
then begin
   tAlert   = "Above Avg PipDiff";
end;





oExtremeVal = Extremes( xDiff, iPeriods, -1, xLowestLow , oExtremeBar ) ; // lowest low

oExtremeVal = Extremes( xDiff, iPeriods, 1, xHighestHigh , oExtremeBar ) ; // highest high


if xDiff = xHighestHigh
then begin
   tAlert   = "Recent Maximum Diff alert"  ;
   Fg1 = darkcyan;
   Bg1 = BLACK;
end
else
if xDiff = xLowestLow
then begin   
   Alert( "Recent Minimum Diff  alert" ) ;
   Fg1 = darkmagenta;
   Bg1 = BLACK;
end;

{ Alert }
{
if tAlert <> ""
and tAlert <> tAlert[1]
   then Alert( tAlert ) ;
}

{ PLOT }

Plot1( xDiff , "Diff", Fg1 ) ;


if iPlotMinMax
then begin

Plot2( xMaxDiff, "xMaxDiff", cyan ) ;

Plot3( xMinDiff, "xMinDiff" , magenta ) ;
end;

if iPlotAvg
then begin
   Plot4( xAvgDiff , "xAvgDiff" , white ) ;
end;
 


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( " " );

CommentaryCl( "IndepData:    ", NumToStr( IndepData , iDecimals) );

CommentaryCl( "DepData:    ", NumToStr( DepData , iDecimals) );
 

CommentaryCl( " " );

CommentaryCl( "xDiff:    ", NumToStr( xDiff , iDecimals) );

CommentaryCl( "xAvgDiff:      ", NumToStr( xAvgDiff , iDecimals) );

CommentaryCl( " " );

CommentaryCl( "xMaxDiff:    ", NumToStr( xMaxDiff , iDecimals) );

CommentaryCl( "xMaxDiffDate:    ", ELDateToString(xMaxDiffDate) );

CommentaryCl( " " );

CommentaryCl( "xMinDiff:      ", NumToStr( xMinDiff , iDecimals) );

CommentaryCl( "xMinDiffDate:      ", ELDateToString(xMinDiffDate) );

CommentaryCl( " " );


 

CommentaryCl( "xHighestHigh:    ", NumToStr( xHighestHigh , iDecimals) );

CommentaryCl( "xLowestLow:    ", NumToStr( xLowestLow , iDecimals) );