Page 1 of 1

GAP FILL

Posted: Sat Sep 15, 2007 4:25 pm
by TheRumpledOne
TOP 25 COWS TO MILK - FIXED




Code: Select all

[LegacyColorValue = true];

{ _SMAA_MTC_TRADE}

{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:
iHigh(  High) ,
iLow(  Low) ,

iDecimals(2),
iPeriods(60),
   
iMarketOpenTime( 0631 ) ;

{*************************************************}
{            V A R I A B L E S                    }
{*************************************************}

variables:

xBars(0),   

 
tMid(""),
tAlert(""),
   DayTop( 0 ),
   DayBottom( 0 ),
   DayHigh( 0 ),    
   PrevDayMid( 0 ),
   DayLow( 0 ),


tInd(""),
tGap(""),

FG1(white),
BG1(black),

fg2(white),
bg2(black),

fg3(white),
bg3(black),

fg4(white),
bg4(black),
   

xLast(0),
xGapFill(0),
xOpenGap(0),
xNetChgAtOpen(0),
xNetChg(0);


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


{ INITIALIZE }

tInd = "";
tMid = "Wait";

FG1 = WHITE;
BG1 = BLACK;

fg2 = yellow;
bg2 = BLACK;

fg3 = WHITE;
bg3 = BLACK;

fg4 = WHITE;
bg4 = BLACK;




{*************************************************}
{    R E S E T                                    }
{*************************************************}


If d <> d[1]
then begin
   
   tGap         = "" ;
   xNetChgAtOpen = 0 ;
   xNetChg        = 0 ;

end;

{*************************************************}
{    C A L C U L A T I O N S                      }
{*************************************************}



DayHigh    = iHigh ;
DayLow       = iLow ;

PrevDayMid    = ( HighD(1) + LowD(1) ) * .50 ; 

If close crosses above PrevDayMid
or close crosses below PrevDayMid
   then xBars = 1
   else xBars = xBars + 1;


// xBars = _fBarsSinceXover( close, PrevDayMid, iPeriods) ;


If time <= iMarketOpenTime
then begin
   xNetChgAtOpen = close - closed(1);
    xLast        = close ;
   xNetChg        = xNetChgAtOpen ;
end
else begin
   xNetChgAtOpen = Opend(0) - closed(1);
    xNetChg        = close - closed(1);
end;

{*************************************************}
{    D I S P L A Y                                }
{*************************************************}

If xNetChgAtOpen > 0   
then begin
   tInd       = "GapUp - Short" ;
   Fg4       = red;
   Bg4       = BLACK;
   xGapFill    =  closed(1) - lowd(0) ;
   if xGapFill >= 0
      then fg2 = green;
end
else
If xNetChgAtOpen <  0   
then begin
   tInd       = "GapDn - Long" ;
   Fg4       = green;
   Bg4       = BLACK;
   xGapFill    =  highd(0) - closed(1) ;
      if xGapFill >= 0
      then fg2 = green;
end;

if xGapFill >= 0
and tGap = ""
then begin
   tGap = numtostr(time, 0) + " Filled " + tInd  ;
end;

If tGap <> ""
   then tInd = tGap ;


{ Alert criteria }

If CLOSE CROSSES ABOVE PrevDayMid
then begin
   tMid = "XA Mid "  + Numtostr(close - PrevDayMid , idecimals) ;
   tAlert = tInd ;
   Fg1 = black;
   Bg1 = yellow;
end
else
If CLOSE CROSSES below PrevDayMid
then begin
   tMid = "XB Mid "  + Numtostr( PrevDayMid - close , idecimals) ;
   tAlert = tInd ;
   Fg1 = red;
   Bg1 = yellow;
end
else
If CLOSE > PrevDayMid
then begin
   tMid = "Above Mid " + Numtostr(close - PrevDayMid , idecimals) ;
   Fg1 = green;
   Bg1 = BLACK;
end
else
If CLOSE < PrevDayMid
then begin
   tMid = "Below Mid " + Numtostr( PrevDayMid - close , idecimals) ;
   Fg1 = red;
   Bg1 = BLACK;
end
else begin
   tMid = "Midpoint! " ;
   tAlert = tInd ;
   Fg1 = magenta;
   Bg1 = white;
end;



If xNetChgAtOpen > 0
and CLOSE < PrevDayMid
then begin
   Fg1       = red;
   Bg1       = WHITE;
   tMid       = "SELL SHORT " + Numtostr( PrevDayMid - close , idecimals) ;
end
else
If xNetChgAtOpen < 0
and CLOSE > PrevDayMid
then begin
   Fg1       = darkgreen;
   Bg1       = WHITE;
   tMid       = "BUY LONG " + Numtostr(close - PrevDayMid , idecimals) ;
end;
   

tMid = Numtostr( xBars , 0 ) + " " + tMid ;

{ PLOT }

Plot1( tMid, "Middle Msg", fg1 ) ;
SetPlotBGColor( 1, bg1);
   
plot2( xGapFill , "Gap Fill", fg2 ) ;
SetPlotBGColor( 2, bg2);

plot3( closed(1) ,"PrevC", fg3 ) ;
SetPlotBGColor( 3, bg3);

plot4( tInd ,"Gap Message", fg4 ) ;
SetPlotBGColor( 4, bg4);


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( "closed(1): ", NumToStr( closed(1) , iDecimals) );

CommentaryCl( "opend(0): ", NumToStr( opend(0) , iDecimals) );


CommentaryCl( "highd(0): ", NumToStr( highd(0) , iDecimals) );


CommentaryCl( "lowd(0): ", NumToStr( lowd(0) , iDecimals) );

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


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

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

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

CommentaryCl( "iMarketOpenTime: ", NumToStr( iMarketOpenTime ,  0 ) );


CommentaryCl( "Time: ", NumToStr( Time ,  0 ) );



I added the time the gap was filled to the the Message column.

ELD attached.

Posted: Sun Sep 16, 2007 4:07 am
by Ken_S
TRO,
What does the gap fill time pertain to if the gap was never filled as is the case for RIMM in your screenshot above. (1516 Filled GapUp - Short).
You see another column in the ELD titled Middle MSG. What does this column represent?
Any idea how I can modify this to see the results over a number of days?
Thanks in advance.
Ken

Posted: Sun Sep 16, 2007 4:08 pm
by TheRumpledOne
Ken_S wrote:TRO,
What does the gap fill time pertain to if the gap was never filled as is the case for RIMM in your screenshot above. (1516 Filled GapUp - Short).
You see another column in the ELD titled Middle MSG. What does this column represent?
Any idea how I can modify this to see the results over a number of days?
Thanks in advance.
Ken



You're right about RIMM.. it was a "bug". Thanks! Will post corrected code.

Middle Msg is for the midpoint crossover trade.

You would have to use my Statistics indicator to see results over a number of days.

Posted: Mon Sep 17, 2007 1:25 am
by Ken_S
TRO,
Any reason why you have the opening time input set to 31 past the hour and not 30?

Posted: Mon Sep 17, 2007 8:32 am
by TheRumpledOne
Think about it. The time is the candle CLOSE TIME.

So the candle that closes at 9:31 EST STARTS at 9:30 which is when the market opens.

What do you mean by "Middle Msg is for the midpoint cro

Posted: Fri Feb 20, 2009 4:40 am
by Noam
TheRumpledOne wrote:
Ken_S wrote:TRO,
What does the gap fill time pertain to if the gap was never filled as is the case for RIMM in your screenshot above. (1516 Filled GapUp - Short).
You see another column in the ELD titled Middle MSG. What does this column represent?
Any idea how I can modify this to see the results over a number of days?
Thanks in advance.
Ken



You're right about RIMM.. it was a "bug". Thanks! Will post corrected code.

Middle Msg is for the midpoint crossover trade.

You would have to use my Statistics indicator to see results over a number of days.


Hi,

What do you mean by "Middle Msg is for the midpoint crossover trade", How should i use it?

Thanks

Posted: Fri Feb 20, 2009 2:53 pm
by TheRumpledOne
Just ignore it.