TradersXchange

Trading Indicator Resource Library
 
It is currently 16 Apr 2014, 17:03

All times are UTC - 5 hours




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: TRO Dynamic Fibs SR
PostPosted: 02 Jul 2011, 17:20 
Offline

Joined: 29 May 2011, 15:55
Posts: 20
Location: Russia
TRO Dynamic Fibs SR

Code:
{ _TRO_Dynamic_FibsSR - draw fibs between the Support/Resistance lines }

{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.}

// http://www.tradersxchange.com/


inputs:
   iAlert(false),
   iStartDate(1070101),  // if not intraday, date to start counting
   iPlotFibs(false),
   iPlotSR(true),
   iPlotTrade(false),
   iPlotStop(true),
   iEntryOffset(.01),
   iStopOffset(.01),
   iPrice( Close ),
   iDecimals(2),
   iPeriods(3),
//   iHigh( HighD(0) ),
//   iLow( LowD(0) ),

   iFibPlot("R"),         // "P" = projections, "R" = retracements
iFib1(.24),
iFib2(.38),
iFib3(.50),
iFib4(.62),
iFib5(.76),
iFib1Color(darkcyan ),
iFib2Color(darkbrown),
iFib3Color(darkgray),
iFib4Color(darkbrown ),
iFib5Color(darkcyan  ),
   HighColor(  red),
   LowColor(  blue),

iShortStopColor(yellow),
iShortEntryColor(magenta),
iLongStopColor(yellow),
iLongEntryColor(cyan),
   idummy("");

variables:
xLastTouch("S") ,
xShortStop(0),
xShortEntry(0),
xLongStop(0),
xLongEntry(0),
fg8(white),
bg8(black),
fg11(white),
bg11(black),
fg12(white),
bg12(black),
fg13(white),
bg13(black),
fg14(white),
bg14(black),
xAppType(0),
sFirstPass(true),
tInd(""),
tAlert(""),
xFib1(iFib1),
xFib2(iFib2),
xFib3(iFib3),
xFib4(iFib4),
xFib5(iFib5),
tFib(""),
xLowestLow(0),
xHighestHigh(0),
xRange(0),
xPosition(0),
oExtremeVal( 0 ),
oExtremeBar( 0 ) ;


variables:
xBars( 0 ),
xPeriods(05),
xOldPeriods(0),
   Dynamic_R( 0 ),
   Dynamic_S( 0 ),
   OldDynamic_R( 0 ),
   OldDynamic_S( 0 ),
   PrevDynamic_R( 0 ),
   PrevDynamic_S( 0 ) ;


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

{first time through}

if sFirstPass
then begin
sFirstPass = false;

{ APP TYPE TEST }
 
sFirstPass = false;

xAppType = GetAppInfo(aiApplicationType);        // cUnknown = 0 cChart = 1  cRadarScreen = 2 cOptionStation = 3

end; {if sFirstPass}

{ INITIALIZE }

tInd   = "";
tAlert  = "";
      
{ CALCULATIONS }
         
If date this bar >= iStartDate
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 ;

{ high / low for period }
   
xBars = xBars + 1;

oExtremeVal = Extremes( L, iPeriods, -1, Dynamic_S , oExtremeBar ) ; // lowest low

oExtremeVal = Extremes( H, iPeriods, 1, Dynamic_R , oExtremeBar ) ; // highest high

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 iFibPlot = "R"
Or iFibPlot = "r"
then begin
 
xLowestLow =  Dynamic_S ;

xRange        = Dynamic_R -  Dynamic_S ;

xFib1      = iFib1 * xRange + xLowestLow;
xFib2      = iFib2 * xRange + xLowestLow;
xFib3      = iFib3 * xRange + xLowestLow;
xFib4      = iFib4 * xRange + xLowestLow;
xFib5      = iFib5 * xRange + xLowestLow;
end // If iFibPlot = "R"...
else Begin

// oExtremeVal = Extremes( iLow[iPeriods], iPeriods, -1, xLowestLow , oExtremeBar ) ; // lowest low

// oExtremeVal = Extremes( iHigh[iPeriods], iPeriods, 1, xHighestHigh , oExtremeBar ) ; // highest high

xLowestLow   = Dynamic_S ;

xHighestHigh = Dynamic_R ;

xRange        = xHighestHigh - xLowestLow;

If close > OpenD(0)
then begin
xFib1      = iFib1 * xRange + xHighestHigh;  // high projections
xFib2      = iFib2 * xRange + xHighestHigh;
xFib3      = iFib3 * xRange + xHighestHigh;
xFib4      = iFib4 * xRange + xHighestHigh;
xFib5      = iFib5 * xRange + xHighestHigh;
end
else begin
xFib1      = xLowestLow - iFib1 * xRange ;  // low projections
xFib2      = xLowestLow - iFib2 * xRange ;
xFib3      = xLowestLow - iFib3 * xRange ;
xFib4      = xLowestLow - iFib4 * xRange ;
xFib5      = xLowestLow - iFib5 * xRange ;
end;

end;

// end; { If iLow <> iLow[1]... }

xShortStop      = Dynamic_R + iStopOffset ;

xLongStop      = Dynamic_S - iStopOffset ;

{ Alert criteria }

If high >= Dynamic_R
then begin
   fg8          = red;
   bg8          = white;
   tAlert          = "Price touched Resistance" ;
   xShortEntry      = low - iEntryOffset ;
end
else
If Low   <= Dynamic_S
then begin
   fg8          = blue;
   bg8          = white;
   tAlert          = "Price touched Support" ;   
   xLongEntry      = high + iEntryOffset ;
end;

{ Alert }

if iAlert
and tAlert <> ""
//and tAlert <> tAlert[1]
   then Alert( tAlert ) ;

if iPlotFibs   
then begin
   
Plot1(xFib1 , "fib1", iFib1Color ) ;
Plot2(xFib2 , "fib2", iFib2Color ) ;
Plot3(xFib3 , "fib3", iFib3Color ) ;
Plot4(xFib4 , "fib4", iFib4Color ) ;
Plot5(xFib5 , "fib5", iFib5Color ) ;

end; // iPlotFibs

if iPlotSR   
then begin

Plot6(Dynamic_R , "Resistance",    HighColor ) ;
Plot7(Dynamic_S , "Support",   LowColor ) ;

end; // iPlotSR

if iPlotTrade
then begin
   if Low[1] = Dynamic_S[1]
   and Close[1] > Low[1]
      then Plot9 (Dynamic_S[1] , "go long",   white ) ;
   
   if High[1] = Dynamic_R[1]
   and Close[1] < High[1]
      then Plot10 (Dynamic_R[1] , "go short",   white ) ;
end ; // iPlotTrade

end; // If date >= xStartDate

 
if iPlotStop
then begin

if low = Dynamic_S
   then xLastTouch = "S"
   else if high = Dynamic_R
         then xLastTouch = "R" ;

If xLastTouch = "S"
and Dynamic_S = Dynamic_S[1]
then begin
   fg14 = iLongEntryColor ;    // long entry
   fg12 = iLongStopColor ;   // long stop
   fg13 = black ;     // short entry
   fg11 = black ;     // short stop
   NoPlot(11) ;
   Plot12 (xLongStop , "long stop",   fg12 ) ;
   NoPlot(13) ;
   Plot14 (xLongEntry , "long entry",    fg14 ) ;
end
else
if xLastTouch = "R"
and Dynamic_R = Dynamic_R[1]
then begin   
   fg14 = black ;       // long entry
   fg12 = black ;      // long stop
   fg13 = iShortEntryColor;        // short entry
   fg11 = iShortStopColor ;    // short stop
   Plot11 (xShortStop , "short stop",   fg11 ) ;
   NoPlot(12) ;
   Plot13 (xShortEntry , "short entry", fg13 ) ;
   NoPlot(14) ;
end;

   

end ; // iPlotStop            

if xAppType = 2   
then begin
   
if close = xFib1
   then SetPlotBGColor( 1, white );

if close = xFib2
   then SetPlotBGColor( 2, white );

if close = xFib3
   then SetPlotBGColor( 3, white );

if close = xFib4
   then SetPlotBGColor( 4, white );

if close = xFib5
   then SetPlotBGColor( 5, white );

if close = Dynamic_R
   then SetPlotBGColor( 6, white );

if close = Dynamic_S
   then SetPlotBGColor( 7, white );

   {Plot8(tAlert , "Alert", yellow ) ;}
end;

CommentaryCl( "Dynamic_R: ", NumToStr( Dynamic_R , iDecimals) );
CommentaryCl( "Dynamic_S: ", NumToStr( Dynamic_S , iDecimals) );
CommentaryCl( "Open[1]: ", NumToStr(Open[1] , iDecimals) );
CommentaryCl( "High[1]: ", NumToStr( High[1] , iDecimals) );
CommentaryCl( "Low[1]: ", NumToStr( Low[1] , iDecimals) );
CommentaryCl( "Close[1]: ", NumToStr( Close[1] , iDecimals) );


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Template made by DEVPPL