[LegacyColorValue = true];
{ _RS_CTRL_PMSM_TF }
{credit of this indicator still goes out to Avery, please send your donations to him.}
{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(2),
iLgColor(green),
iShColor(red),
iPrice( close ),
iInd( xaverage(close,5) ),
iBarsBack(1),
iAboveColor( darkblue ),
iBelowColor( darkmagenta ),
iIndRisingColor( cyan ),
iIndFallingColor( magenta ) ;
inputs:
iMode("No"), { if "auto" code sets xPeriods, if not "auto" code uses iPeriods}
iDefault(false), // if true then load defaults from _fDYNAMIC_SR
iPeriods(05),
iResetSR(true), // if true reset dynamic s/r, if false don't for Forex use false!!
iStartDate(1060120), // if not intraday, date to start counting
iHorizontal(false), // if true only show horizontal dots
HighColor( red),
LowColor( blue),
SpikeColor( yellow );
variables:
FG_S( yellow ),
FG_R( yellow ),
xTicker(GetSymbolName),
xDecimals(4),
xPriceThreshold(0),
xWidthThreshold(0),
xChannelBars(0),
xStartDate(iStartDate), // if not intraday, date to start counting
oExtremeVal( 0 ),
oExtremeBar( 0 ) ,
xBarsSR( 0 ),
xOldPeriods(0),
//xPeriods(05),
//xInterval(0),
HavePrevLines( false ),
TLHigh( 0 ),
TLLow( 0 ),
Dynamic_R( 0 ),
Dynamic_S( 0 ),
OldDynamic_R( 0 ),
OldDynamic_S( 0 ),
PrevDynamic_R( 0 ),
PrevDynamic_S( 0 ) ,
Dynamic_UpVol( 0 ),
Dynamic_DnVol( 0 ) ,
PrevDynamic_UpVol( 0 ),
PrevDynamic_DnVol( 0 ) ;
variables:
xColor1FG(white),
xMajor( 0 ),
xMinor( 0 ),
xMid( 0 ),
xMid5( 0 ),
xMid15( 0 ),
xMid60( 0 ),
xMidD( 0 ),
xPrevMid( 0 ),
xPrevMid5( 0 ),
xPrevMid15( 0 ),
xPrevMid60( 0 ),
xPrevMidD( 0 ),
tPrevMid(""),
tMid(""),
tMsg(""),
PLTop( 0 ),
PLBottom( 0 ),
DayTop( 0 ),
DayBottom( 0 ),
DayHigh( 0 ),
PrevMid( 0 ),
DayLow( 0 ),
xPeriods(60),
xInterval(0),
sFirstPass(true),
xBars(0),
xInd(0),
tInd(""),
tAlert("");
variables:
xx(white),
FG1(white),
BG1(black),
fg2(white),
bg2(black),
fg3(white),
bg3(black),
fg4(white),
bg4(black),
fg5pm(white),
fg5cm(white),
fg15pm(white),
fg15cm(white),
fg60pm(white),
fg60cm(white),
fgDpm(white),
fgDcm(white);
{commentary variables}
variables:
xcomm(0),
oComm1( "" ),
oComm2( "" ),
oComm3( "" ),
oComm4( "" ),
oComm5( "" ),
oComm6( "" ),
oComm7( "" ),
oComm8( "" ),
oComm9( "" ),
oComm10( "" );
variables:
xDate(0),
xTime(0),
xOpen(0),
xClose(0),
xHigh(0),
xLow(0);
{first time through}
if sFirstPass
then begin
sFirstPass = false;
{bar test}
If bartype = 4
then xInterval = 94
else
If bartype = 3
then xInterval = 93
else
If bartype = 2
then xInterval = 92
else
If bartype = 1
then begin
xInterval = BarInterval;
end; { If bartype = 1 }
If iDefault
then begin
value1 = _fDynamic_SR_Load( xTicker, xPeriods , xDecimals , xPriceThreshold , xWidthThreshold , xChannelBars ) ;
end
else begin
xPeriods = iPeriods ;
end;
xOldPeriods = xPeriods ; // save this value
xStartDate = iStartDate ;
end; {if sFirstPass}
{ INITIALIZE }
FG1 = WHITE;
BG1 = BLACK;
fg2 = WHITE;
bg2 = BLACK;
fg3 = WHITE;
bg3 = BLACK;
//fg4 = WHITE;
//bg4 = BLACK;
tInd = "";
tAlert = "WAIT ";
xDate = Date ;
xTime = Time ;
xOpen = Open;
xClose = Close;
xHigh = High;
xLow = Low;
{ PROCESSING }
xMid = ( (High[0] + Low[0] ) * .50 );
xMid5 = ( (High[0] of data2 + Low[0] of data2 ) * .50 );
xMid15 = ( (High[0] of data3 + Low[0] of data3 ) * .50 );
xMid60 = ( (High[0] of data4 + Low[0] of data4 ) * .50 );
xMidD = ( (HighD(0) + LowD(0) ) * .50 );
xPrevMid = ( (High[1] + Low[1] ) * .50 );
xPrevMid5 = ( (High[1] of data2 + Low[1] of data2 ) * .50 );
xPrevMid15 = ( (High[1] of data3 + Low[1] of data3 ) * .50 );
xPrevMid60 = ( (High[1] of data4 + Low[1] of data4 ) * .50 );
xPrevMidD = ( (HighD(1) + LowD(1) ) * .50 );
If close crosses above PrevMid
or close crosses below PrevMid
then xBars = 1
else xBars = xBars + 1;
{ Alert criteria }
If close > xPrevMid
then begin
tPrevMid = "BUYERS";
Fg1 = iLgColor;
Bg1 = BLACK;
end
else
If close < xPrevMid
then begin
tPrevMid = "SELLERS";
Fg1 = iShColor;
Bg1 = BLACK;
end;
If close > xMid
then begin
tMid = "BUYERS";
Fg2 = iLgColor;
Bg2 = BLACK;
end
else
If close < xMid
then begin
tMid = "SELLERS";
Fg2 = iShColor;
Bg2 = BLACK;
end;
If close > xPrevMid5
then begin
Fg5pm = iLgColor;
end
else
If close < xPrevMid5
then begin
Fg5pm = iShColor;
end;
If close > xMid5
then begin
Fg5cm = iLgColor;
end
else
If close < xMid5
then begin
Fg5cm = iShColor;
end;
If close > xPrevMid15
then begin
Fg15pm = iLgColor;
end
else
If close < xPrevMid15
then begin
Fg15pm = iShColor;
end;
If close > xMid15
then begin
Fg15cm = iLgColor;
end
else
If close < xMid15
then begin
Fg15cm = iShColor;
end;
If close > xPrevMid60
then begin
Fg60pm = iLgColor;
end
else
If close < xPrevMid60
then begin
Fg60pm = iShColor;
end;
If close > xMid60
then begin
Fg60cm = iLgColor;
end
else
If close < xMid60
then begin
Fg60cm = iShColor;
end;
If close > xPrevMidD
then begin
FgDpm = iLgColor;
end
else
If close < xPrevMidD
then begin
FgDpm = iShColor;
end;
If close > xMidD
then begin
FgDcm = iLgColor;
end
else
If close < xMidD
then begin
FgDcm = iShColor;
end;
{ Alert criteria }
{
If CLOSE CROSSES ABOVE PrevMid
then begin
tMsg = "XA PrevMid " + Numtostr(close - PrevMid , idecimals) ;
Fg4 = BLACK;
Bg4 = yellow;
end
else
If CLOSE CROSSES below PrevMid
then begin
tMsg = "XB PrevMid " + Numtostr( PrevMid - close , idecimals) ;
Fg4 = red;
Bg4 = yellow;
end
else
If CLOSE > PrevMid
then begin
tMsg = "Above PrevMid " + Numtostr(close - PrevMid , idecimals) ;
Fg4 = BLACK;
Bg4 = green;
end
else
If CLOSE < PrevMid
then begin
tMsg = "Below PrevMid " + Numtostr( PrevMid - close , idecimals) ;
Fg4 = BLACK;
Bg4 = red;
end
else begin
tMsg = "Prev Midpoint! " ;
Fg4 = magenta;
Bg4 = white;
end;
}
{ Alert }
{
if tAlert <> "wait "
and tAlert <> tAlert[1]
then Alert( tAlert + Numtostr( PrevMid , idecimals)) ;
}
if xBars = 1
then Alert( tMsg + " / " + Numtostr( PrevMid , idecimals)) ;
If iPrice >= iInd
then begin
If iInd >= iInd[iBarsBack]
then xColor1FG = iIndRisingColor
else xColor1FG = iAboveColor ;
end
else begin
If iInd < iInd[iBarsBack]
then xColor1FG = iIndFallingColor
else xColor1FG = iBelowColor;
end;
If date this bar >= xStartDate
then begin
{save old values}
If Dynamic_R <> PrevDynamic_R
then OldDynamic_R = PrevDynamic_R;
If Dynamic_S <> PrevDynamic_S
then OldDynamic_S = PrevDynamic_S ;
OldDynamic_R = PrevDynamic_R ;
OldDynamic_S = PrevDynamic_S ;
PrevDynamic_R = Dynamic_R ;
PrevDynamic_S = Dynamic_S ;
PrevDynamic_UpVol = Dynamic_UpVol ;
PrevDynamic_DnVol = Dynamic_DnVol ;
{ high / low for period }
If d <> d[1]
then xBarsSR = 0;
xBarsSR = xBarsSR + 1;
If xBarsSR < xOldPeriods
and iResetSR
and xInterval < 92
then begin
xPeriods = xBarsSR ; // start fresh each day
PrevDynamic_S = L ;
PrevDynamic_R = H ;
end
else begin
xPeriods = xOldPeriods ; // no reset
end;
oExtremeVal = Extremes( L, xPeriods, -1, Dynamic_S , oExtremeBar ) ; // lowest low
oExtremeVal = Extremes( H, xPeriods, 1, Dynamic_R , oExtremeBar ) ; // highest high
Dynamic_UpVol = UpTicks ;
Dynamic_DnVol = DownTicks ;
If Dynamic_R <> H
and Dynamic_R < PrevDynamic_R
then if PrevDynamic_R <> 0
then Dynamic_R = PrevDynamic_R;
If Dynamic_S <> L
and Dynamic_S > PrevDynamic_S
then if PrevDynamic_S <> 0
then Dynamic_S = PrevDynamic_S;
If iHorizontal
then begin
If Dynamic_S = Dynamic_S[1]
then FG_S = LowColor;
If Dynamic_R = Dynamic_R[1]
then FG_R = HighColor;
end
else begin
If Dynamic_S = Dynamic_S[1]
then FG_S = darkblue
else FG_S = LowColor ;
If Dynamic_R = Dynamic_R[1]
then FG_R = darkred
else FG_R = HighColor ;
if low = Dynamic_S
then FG4 = FG_S
else if high = Dynamic_R
then FG4 = FG_R;
end; // If iHorizontal
end; // If date >= xStartDate
{ PLOT }
if fg1 <> fg2
then begin
fg1 = yellow;
end;
if fg5pm <> fg5cm
then begin
fg5pm = yellow;
end;
if fg15pm <> fg15cm
then begin
fg15pm = yellow;
end;
if fg60pm <> fg60cm
then begin
fg60pm = yellow;
end;
if fgDpm <> fgDcm
then begin
fgDpm = yellow;
end;
Plot1( 1.5 , "1min Ctrl", fg1 ) ;
//SetPlotBGColor( 1, bg1);
{
Plot2( 1 , "Minor", fg2 ) ;
//SetPlotBGColor( 2, bg2);
Plot3( 0, "Ind2", xColor1FG ) ;
//SetPlotBGColor( 3, bg3);
Plot4( -1 , "Dyn S/R", fg4 ) ;
SetPlotBGColor( 4, bg4 );}
Plot5( 1 , "5min Ctrl", fg5pm ) ;
Plot6( .5 , "15min Ctrl", fg15pm ) ;
Plot7( 0 , "60min Ctrl", fg60pm ) ;
Plot8( -.5 , "Day Ctrl", fgDpm ) ;
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( "xMid: ", NumToStr( xMid , iDecimals) );
CommentaryCl( "xPrevMid: ", NumToStr( xPrevMid , iDecimals) );