SLOT MACHINE INDICATOR - DARVAS BOX

post your indicators here

Moderator: moderators

User avatar
TheRumpledOne
rank: 10000+ posts
rank: 10000+ posts
Posts: 11430
Joined: Sun May 14, 2006 9:31 pm
Reputation: 45
Location: Oregon
Real name: Avery T. Horton, Jr.
Gender: None specified
Contact:

SLOT MACHINE INDICATOR - DARVAS BOX

Postby TheRumpledOne » Wed Jun 28, 2006 11:19 pm






Code: Select all

// _SMAA_CT_DarvasBox2
   

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


{MODIFYING Programmer:  Avery T. Horton, Jr.  aka TheRumpledOne,
gifts and donations accepted, PO Box 43575, Tucson, AZ 85733 }

{ © Copyright 2006 Avery T. Horton, Jr.}


{   Indicator - CT_DarvarBox2

   Darvas Boxes originally coded by Combs [Thanks Greg]

   Modified by Codetalker

   Note:

   CT_DarVarBox2 allows for specifying the number of Box or Lines to remain on Screen

   October 14, 2003

}
Inputs:
   
   idecimals( 2 ),

   iThreshold( .05 ),

   ShowAll(False),      { True = no Boxes or Lines are deleted, False = the BoxesOnScreen number is shown on screen }
   BoxesOnScreen(5),   { If ShowAll=False then # of Boxes or Lines to keep on the screen [not > BoxTL_ID's Array d2 Size] }
   DoBoxes(True),      { True= boxes are drawn, False = Lines are drawn }
   ScreenAdjust(20),   { Used in a dummy Plot statement to force the screen to adjust }
   TopColor(Yellow),
   BottomColor(Magenta),
   BuyTextColor(White),
   SellTextColor(White);



Variables:

tAlert(""),

xSort(0),

xDiff(0),

xBoxTop  ( 0 ) ,
xBoxBtm  ( 0 ) ,

xPrev_BoxTop  ( 0 ) ,
xPrev_BoxBtm  ( 0 ) ,

FG1(white),
BG1(black),

fg2(white),
bg2(black),

fg3(white),
bg3(black),

fg4(white),
bg4(black);


Variables:
   BoxTop  ( 0 ) ,
   BoxBtm  ( 0 ) ,
   BBD     ( 0 ) ,
   BBT     ( 0 ) ,
   EBD     ( 0 ) ,
   EBT     ( 0 ) ,
   PED     ( 0 ) ,
   PET     ( 0 ) ,
   TopId   ( -1 ) ,
   TopCId  ( -1 ) ,
   BtmId   ( -1 ) ,
   BtmCId  ( -1 ) ,
   LSId   ( -1 ),
   RSId   ( -1 ),
   UpBand  ( 0 ) ,
   DnBand  ( 0 ) ,
   CurrentState(0),
   BuyTextID(-1),
   SellTextID(-1),
   PlotColor(GetBackGroundColor),   { Used by Dummy Plots }
   HiFirst  ( true ) ,
   LoFirst  ( false ) ,
   DrawBox  ( false ) ,
   NewBox   ( false ) ;

{ Used as State compares...Don't change these }

Variables:
   MyState1( 1 ) ,
   MyState2( 2 ) ,
   MyState3( 3 ) ,
   MyState4( 4 ) ,
   MyState5( 5 );

Variables:
   BoxColor(0),
   StateCheck1(False),
   StateCheck2(False);

Variables:
   HStyleLeft(0),
   HStyleRight(1),      
   HStyleCenter(2),
   VStyleTop(0),
   VStyleBottom(1),      
   VStyleCenter(2),
   THStyle(HStyleLeft),
   TVStyle(VStyleBottom),
   BHStyle(HStyleLeft),
   BVStyle(VStyleTop);

Variables:
   TTLStyle(Tool_Dashed2),
   BTLStyle(Tool_Dashed2);

Variables:
   CircularBased(0),      { The Circular buffer can be either 0 or 1 based - I pick 0 - saves a little memory }
   BoxTLsCount(0),         { This is a function internal variable...don't change the contents }
   BoxTLsTail(0),
   BoxTLsHead(0),
   BoxTLsPrevHead(0);

{ BoxTL_IDs Array Box Side Index Variables }

Variables:
   TTStatus(0),
   TopId_Index(CircularBased),
   BtmId_Index(CircularBased+1),

   LSId_Index(CircularBased+2),
   RSId_Index(CircularBased+3),

   TopCId_Index(CircularBased+2),
   BtmCId_Index(CircularBased+3);   { Same because of two different methods }

Variables:
   BuyText_Index(CircularBased+4),
   SellText_Index(CircularBased+5);      { Text Id Index vars }

   { Because TS forces us to statically declare the Arrays size, BoxesOnScreen must be <= BoxTL_IDs[x,"thisone"] definition }

   { If CircularBased=0 then BoxTL_IDs[5,x] else If CircularBased=1 then BoxTL_IDs[6,x] }


   { The Last Two BoxTL_IDs' are used to store the text id's }


{ INITIALIZE }

if CurrentBar = 1 then
   begin
      BoxTop=High; BoxBtm=Low;
      BBD=Date; BBT=Time;
      CurrentState=MyState1;
      BoxTLsCount=CircularBased;         { Initalize the Counts to our base}
      PED=0; PET=0;
   end ;
   

tAlert = "";

FG1 = WHITE;
BG1 = BLACK;

fg2 = WHITE;
bg2 = BLACK;

fg3 = WHITE;
bg3 = BLACK;

fg4 = WHITE;
bg4 = BLACK;


Condition1=High > UpBand;
Condition2=Low < DnBand;
   
if NewBox and ( Condition1 or Condition2 ) Then
   begin    
      BBD=Date; BBT=Time;   NewBox=False;
      CurrentState=MyState1;
      LoFirst=IffLogic(Condition2,True,False);
      HiFirst=IffLogic(Condition1,True,False);

   
   End;
   
   StateCheck1=IffLogic(HiFirst,High > BoxTop,Low < BoxBtm);
   StateCheck2=IffLogic(HiFirst,Low < BoxBtm,High > BoxTop);

      If CurrentState=MyState4 then
      begin
         If StateCheck1 then
         begin
            CurrentState=MyState1;
            StateCheck1=False;
            If HiFirst Then BoxTop = high
                     Else BoxBtm = low;
         end else
         begin
            if StateCheck2 then
            begin
               CurrentState=MyState3;
               StateCheck2=False;
               If HiFirst Then BoxBtm = low
                        Else BoxTop = high;
            end else CurrentState=MyState5;
         end;
      end ;
   
      if CurrentState=MyState3 then
      begin
         if StateCheck1 then
         begin
            CurrentState=MyState1;
            StateCheck1=False;
            If HiFirst Then BoxTop = high
                     Else BoxBtm = low;
         end else
         Begin
            if StateCheck2 then
            Begin
               StateCheck2=False;               
               If HiFirst Then BoxBtm = low
                          Else BoxTop = high;
            End Else CurrentState=MyState4;
         end ;
      end ;

   if CurrentState=MyState2 then
      if StateCheck1 then
      begin
         CurrentState=MyState1;
         StateCheck1=False;
         If HiFirst Then BoxTop = high
                  Else BoxBtm = low;
         end else
         begin
            CurrentState=MyState3;
            If HiFirst Then BoxBtm = low
                     Else BoxTop = high;
         end ;

   if CurrentState=MyState1 then
      if StateCheck1 then
      Begin
         If HiFirst Then BoxTop = high
                  Else BoxBtm = low ;   
      End Else CurrentState=MyState2;

   if CurrentState=MyState5 then   
      begin
         DrawBox  = true ;
         EBD      = date ;
         EBT      = time ;
      end ;

If DrawBox then
   begin

   If DoBoxes Then
   Begin      
      



if xBoxTop <> xPrev_BoxTop
   then xPrev_BoxTop = xBoxTop ;


if xBoxBtm <> xPrev_BoxBtm
   then xPrev_BoxBtm = xBoxBtm ;

      xBoxTop = BoxTop ;
      xBoxBtm = BoxBtm ;
      
   End Else
   Begin

      PED=EBD; PET=EBT;
   End;

      { These are just Dummy Forced Plot's }
      CurrentState=0;
      DrawBox=False; NewBox=True;
      UpBand=BoxTop; DnBand=BoxBtm;
      BoxTop=High; BoxBtm=Low;

End;


{ Alert criteria }


If xBoxTop > xPrev_BoxTop
then begin
   Fg1 = green;
   Bg1 = BLACK;
end
else
If xBoxTop < xPrev_BoxTop
then begin
   Fg1 = red;
   Bg1 = BLACK;
end
else
begin
   Fg1 = white;
   Bg1 = BLACK;
end;


If xBoxBtm > xPrev_BoxBtm
then begin
   Fg2 = green;
   Bg2 = BLACK;
end
else
If xBoxBtm < xPrev_BoxBtm
then begin
   Fg2 = red;
   Bg2 = BLACK;
end
else
begin
   Fg2 = white;
   Bg2 = BLACK;
end;

xSort = 0 ;
xDiff = 0 ;

value2  = xBoxTop - close ;


if value2 <= iThreshold
and value2 > 0
then begin
   fg1    = yellow ;
   fg3    = green;
   xSort    = 2 ;
   xDiff    = value2 ;
   tAlert    = "DBx Top B/O " ;
end;

value3 = close - xBoxBtm ;

if value3 <= iThreshold
and value3 > 0
then begin
   fg2    = yellow ;
   fg3    = red ;
   xSort    = 1 ;
   xDiff    = value3 ;
   tAlert   = "DBx Btm B/O " ;
end;


{ Alert }

 
if tAlert <> ""
and tAlert <> tAlert[1]
   then Alert( tAlert + Numtostr( xDiff , idecimals) ) ;
 

{ plot }

Plot1( xBoxTop , "BoxTop", fg1 ) ;
SetPlotBGColor( 1,  bg1 );

Plot2( xBoxBtm, "BoxBtm", fg2 ) ;
SetPlotBGColor( 2, bg2);

Plot3( xSort, "Sort", fg3 ) ;
SetPlotBGColor( 3, bg3);

Plot4( xDiff , "Diff", fg4 ) ;
SetPlotBGColor( 4, bg4);


{
Plot3( xPrev_BoxTop , "Prev BoxTop", fg3 ) ;
SetPlotBGColor( 3, bg3);

Plot4( xPrev_BoxBtm, "Prev BoxBtm", fg4 ) ;
SetPlotBGColor( 4, bg4);
}
Attachments
DARVASBOX.ELD
(11.95 KiB) Downloaded 98 times

Please add www.kreslik.com to your ad blocker white list.
Thank you for your support.

Return to “Tradestation indicators”