Page 1 of 1

Prev day

Posted: Wed Feb 10, 2010 5:11 pm
by blackda14
Tried to modify indicator to reference prev day high, prev day close, prev day low. Prevclose works when I plug it in but the high and low is not doing the calculation correctly. I was using HighD(1) LowD(1). What am I doing wrong?

Code: Select all

inputs:

iExitTarget( .0012 ),
   
iTop( HighD(1) ),

iMiddle( Prevclose ),

iBottom( LowD(1) ),

iTextMsg( true ),
{
iMsgLong("LONG"),

iMsgShort("SHORT"),

iMsgFlat("FLAT"),


iMsgXAbove("XA"),

iMsgXBelow("XB"),
}

iWaitColor(white),
   
   

iDecimals(4);
 
 
variables:
 
tMid(""),
tMsgTop(""),

tMsgMid(""),

tMsgBot(""),
tMsgExit(""),

   PLTop( 0 ),
   PLBottom( 0 ),

   DayTop( 0 ),
   DayBottom( 0 ),
   DayHigh( 0 ),    
   PrevMiddle( 0 ),
   DayLow( 0 ),

xPeriods(60),
xInterval(0),

sFirstPass(true),
 
xBars(0),   

xInd(0),
tInd(""),
tAlert("");

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

variables:
   xColor1FG(white);

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  }

end; {if sFirstPass}


{ INITIALIZE }

FG1 = iWaitColor;
BG1 = BLACK;

fg2 = iWaitColor;
bg2 = BLACK;

fg3 = iWaitColor;
bg3 = BLACK;

fg4 = WHITE;
bg4 = BLACK;
 
tInd   = "";

tMsgTop   = "";

tMsgMid   = "";

tMsgBot   = "";

tMsgExit   = "";

tAlert = "WAIT  ";

xDate   = Date ;

xTime   = Time ;

xOpen    =  Open;

xClose   =  Close;

xHigh    =  High;

xLow    =  Low;

{ PROCESSING }
 
 

{ Middle Alert criteria }

If CLOSE CROSSES ABOVE iMiddle
then begin
   if iTextMsg then    tMsgMid = "XA Mid " ;
   tMsgMid = tMsgMid + Numtostr(close - iMiddle , idecimals) ;
   Fg2 = BLACK;
   Bg2 = yellow;
end
else
If CLOSE CROSSES below iMiddle
then begin
   if iTextMsg then tMsgMid = "XB Mid "  ;
   tMsgMid = tMsgMid + Numtostr( iMiddle - close , idecimals) ;
   Fg2 = red;
   Bg2 = yellow;
end
else
If CLOSE > iMiddle
then begin
   if iTextMsg then tMsgMid = "Above Mid " ;
   tMsgMid = tMsgMid + Numtostr(close - iMiddle , idecimals) ;
   Fg2 = BLACK;
   Bg2 = green;
end
else
If CLOSE < iMiddle
then begin
   if iTextMsg then tMsgMid = "Below Mid " ;
   tMsgMid = tMsgMid + Numtostr( iMiddle - close , idecimals) ;
   Fg2 = BLACK;
   Bg2 = red;
end
else begin
   if iTextMsg then tMsgMid = "Midpoint! " ;
   tMsgMid = tMsgMid + Numtostr( 0 , idecimals) ;
   Fg2 = magenta;
   Bg2 = white;
end;

{ Top Alert criteria }

If CLOSE CROSSES ABOVE iTop
then begin
   if iTextMsg then tMsgTop = "XA Top " ;   
   tMsgTop= tMsgTop + Numtostr(close - iTop , idecimals) ;
   Fg1 = BLACK;
   Bg1 = yellow;
   if close - iTop >= iExitTarget
   then begin
      tMsgExit   = "SELL!" ;
      Fg4 = RED;
      Bg4 = WHITE;
      end;

end
else
If CLOSE CROSSES below iTop
then begin
   if iTextMsg then tMsgTop = "XB Top " ;
   tMsgTop = tMsgTop    + Numtostr( iTop - close , idecimals) ;
   Fg1 = red;
   Bg1 = yellow;
end
else
If CLOSE > iTop
then begin
   if iTextMsg then tMsgTop = "Above Top " ;
   tMsgTop = tMsgTop + Numtostr(close - iTop , idecimals) ;
   Fg1 = BLACK;
   Bg1 = green;

   if close - iTop >= iExitTarget
   then begin
      tMsgExit   = "SELL!" ;
      Fg4 = RED;
      Bg4 = WHITE;
      end;
end
else
If CLOSE < iTop
then begin
   if iTextMsg then tMsgTop = "Below Top " ;
   tMsgTop = tMsgTop + Numtostr( iTop - close , idecimals) ;
   Fg1 = BLACK;
   Bg1 = red;
end
else begin
   if close > close[1]
   then begin
   if iTextMsg then tMsgTop = "BUY! " ;
   tMsgTop = tMsgTop + Numtostr( 0 , idecimals) ;
   Fg1 = magenta;
   Bg1 = white;
   end;
end;

{ Bottom Alert criteria }

If CLOSE CROSSES ABOVE iBottom
then begin
   if iTextMsg then tMsgBot = "XA Bottom " ;
   tMsgBot = tMsgBot + Numtostr(close - iBottom , idecimals) ;
   Fg3 = BLACK;
   Bg3 = yellow;
end
else
If CLOSE CROSSES below iBottom
then begin
   if iTextMsg then tMsgBot = "XB Bottom "  ;
   tMsgBot = tMsgBot + Numtostr( iBottom - close , idecimals) ;
   Fg3 = red;
   Bg3 = yellow;
   if iBottom - close >= iExitTarget
   then begin
      tMsgExit   = "COVER!" ;
      Fg4 = DARKGREEN;
      Bg4 = WHITE;
      end;

end
else
If CLOSE > iBottom
then begin
   if iTextMsg then tMsgBot = "Above Bottom " ;
   tMsgBot = tMsgBot + Numtostr(close - iBottom , idecimals) ;
   Fg3 = BLACK;
   Bg3 = green;
end
else
If CLOSE < iBottom
then begin
   if iTextMsg then tMsgBot = "Below Bottom " ;
   tMsgBot = tMsgBot + Numtostr( iBottom - close , idecimals) ;
   Fg3 = BLACK;
   Bg3 = red;
   if iBottom - close >= iExitTarget
   then begin
      tMsgExit   = "COVER!" ;
      Fg4 = DARKGREEN;
      Bg4 = WHITE;
      end;

end
else begin
   if close < close[1]
   then begin
   if iTextMsg then tMsgBot = "SHORT!" ;
   tMsgBot = tMsgBot + Numtostr( 0 , idecimals) ;
   Fg3 = magenta;
   Bg3 = white;
   end;
end;


{ Alert }

{
if tAlert <> "wait  "
and tAlert <> tAlert[1]
   then Alert( tAlert + Numtostr( iMiddle , idecimals)) ;
}



{ PLOT }


Plot1( tMsgTop , "Top", fg1 ) ;
SetPlotBGColor( 1, bg1);

   
Plot2( tMsgMid  , "PrevClose", fg2 ) ;
SetPlotBGColor( 2, bg2);


Plot3( tMsgBot , "Bottom", fg3 ) ;
SetPlotBGColor( 3, bg3);

 
 
Plot4( tMsgExit , "Exit", 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( "iTop: ", NumToStr( iTop , iDecimals) );
 
 
CommentaryCl( "iMiddle: ", NumToStr( iMiddle , iDecimals) );


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



CommentaryCl( "iMiddle[1]: ", NumToStr( iMiddle[1] , iDecimals) );
 

correct?

Posted: Wed Feb 10, 2010 10:01 pm
by blackda14
Load additional bars was my problem I think