Updated code in post #37

*********/

I created a indicator that plots the Footprint for the lastcalcdate based on a 1 Tick chart for for best accuracy and the complete history for the day by simulating a higher timeframe.

It works ok so far, but i need to plot the last "live" footprints till the condition

"If Barcounter = SynthTimeFrame " is true.

If i use the same logic for plotting as after "If Barcounter = SynthTimeFrame " I do not get either all the rows updated or deleted the next higher timeframe bar.

Maybe some coder here or the MC has a solution?

Code: Select all

inputs :

MaxExpectedRangeInTicks ( 300 ),

SynthTimeFrame ( 2000 ),

// 0 - Bid x Ask

// 1 - Delta (Bid-Ask)

// 2 - TotalVolume (Bid+Ask)

PlotDeltaMode ( 0 ),

TxTSize ( 8 ),

Width ( 4 ),

TxTFont ( "Consolas"),

Plot.Border ( true ),

Plot.Candle ( true ),

Show.SubText ( true ),

Show.UpTminusDnT ( true ),

Show.UpT ( true ),

Show.DnT ( true ),

Show.UpTplusDnT ( true );

vars:

BarHigh ( 0 ),

BarLow ( 0 ),

FootPrintPrice ( 0 ),

TodayOpenPrice ( 0 ),

UpDnTick ( 0 ),

BarCounter ( 0 ),

TickSize ( 0 ),

ResetCounter ( 0 ),

OpenValue ( 0 ),

TextString (""),

NumBarsText (0),

FootPrintText ( 0 ),

TotalBid ( 0 ),

TotalAsk ( 0 ),

FirstCandle ( 0 ),

BidAskArraySz ( 2*MaxExpectedRangeInTicks);

//dynamic numerical arrays

Array: Bid.Array[](0),Ask.Array[](0) ;

Once begin

if bartype_ex >1 or barinterval >1 then raiseruntimeerror (" For 1 Tick chart resolution only !! ");

TickSize = (minmove/PriceScale);

Array_SetMaxIndex( Bid.Array, BidAskArraySz );

Array_SetMaxIndex( Ask.Array, BidAskArraySz );

end;

if d = LastCalcDate then

begin

//Reset the values at the begin of the day

if d > d[1] then

begin

BarCounter = 0;

BarHigh = 0;

BarLow = 999999;

TodayOpenPrice = Close;

FootPrintPrice = 0;

TotalBid = 0;

TotalAsk = 0;

FirstCandle = 1;

for ResetCounter=0 to BidAskArraySz

begin

Bid.Array [ResetCounter] = 0;

Ask.Array [ResetCounter] = 0;

end;

end;

BarCounter = BarCounter +1 ;

FootPrintPrice = (BidAskArraySz/2 )+ (Close - TodayOpenPrice) / TickSize;

if FootPrintPrice >= BarHigh then BarHigh = FootPrintPrice ;

if FootPrintPrice <= BarLow then BarLow = FootPrintPrice ;

//We move up

if close > close[1] then

begin

UpDnTick = 2; //Set the state to 2

Ask.Array[FootPrintPrice] = Ask.Array[FootPrintPrice] + Ticks;

end;

//We move down

if close < close[1] then

begin

UpDnTick =-2; //Set the state to -2

Bid.Array[FootPrintPrice] = Bid.Array[FootPrintPrice]+ Ticks;

end;

//Same close as the bar before

if close = close[1] then

begin

// last movement before was an Uptick

if UpDnTick = 2 then

begin

Ask.Array[FootPrintPrice] = Ask.Array[FootPrintPrice] + Ticks;

end;

// last movement before was an Dntick

if UpDnTick =-2 then

begin

Bid.Array[FootPrintPrice] = Bid.Array[FootPrintPrice]+ Ticks;

end;

end;

If Barcounter = SynthTimeFrame then

begin

For FootPrintPrice = BarLow to BarHigh

begin

if Bid.Array[FootPrintPrice] >0 or Ask.Array[FootPrintPrice] >0 then

begin

//TextString = NumToStr (Bid.Array[FootPrintPrice],0) +" x " + NumToStr(Ask.Array[FootPrintPrice],0)+" ";

if PlotDeltaMode <=0 then

TextString = " "+_SpacifyString(NumToStr(Bid.Array[FootPrintPrice], 0), Width, -1) + "x" + _SpacifyString(NumToStr(Ask.Array[FootPrintPrice], 0), Width, 1)+" ";

if PlotDeltaMode =1 then

TextString = _SpacifyString(NumToStr(Ask.Array[FootPrintPrice]-Bid.Array[FootPrintPrice], 0), Width+2, 1)+" ";

if PlotDeltaMode >=2 then

TextString = _SpacifyString(NumToStr(Ask.Array[FootPrintPrice]+Bid.Array[FootPrintPrice], 0), Width+3, 1)+" ";

FootPrintText = Text_New_s(Date, Time_s, 0, " ");

Text_SetString (FootPrintText, TextString);

Text_SetLocation_s(FootPrintText, Date, Time_s, (FootPrintPrice -(BidAskArraySz/2 ))*TickSize + TodayOpenPrice );

Text_SetStyle(FootPrintText, 1, 2);

if Plot.Border then

begin

if Bid.Array[FootPrintPrice] >Ask.Array[FootPrintPrice] then text_SetBGColor(FootPrintText, red) else

if Bid.Array[FootPrintPrice] <Ask.Array[FootPrintPrice] then text_SetBGColor(FootPrintText, green) else

text_SetBGColor(FootPrintText, white);

Text_SetBorder(FootPrintPrice, True);

text_SetColor(FootPrintText, black);

end else

begin

if Bid.Array[FootPrintPrice] >Ask.Array[FootPrintPrice] then text_SetColor(FootPrintText, red) else

if Bid.Array[FootPrintPrice] <Ask.Array[FootPrintPrice] then text_SetColor(FootPrintText, green) else

text_SetColor(FootPrintText, white);

end;

text_setsize (FootPrintText,TxTSize);

text_setfontname (FootPrintText,TxTFont);

end;

TotalBid = TotalBid + Bid.Array[FootPrintPrice];

TotalAsk = TotalAsk + Ask.Array[FootPrintPrice];

end;

if Plot.Candle then

begin

// To see the candle plot them [-SynthTimeFrame/10] to the right

{plot21 [-SynthTimeFrame/10](lowest(low,SynthTimeFrame ),"CL");

plot22 [-SynthTimeFrame/10](highest(high,SynthTimeFrame ),"CH");

plot23 [-SynthTimeFrame/10](Close,"CC");

Plot24 [-SynthTimeFrame/10](iff ( firstCandle =1 ,TodayOpenPrice ,OpenValue[1]),"CO") ;}

plot21 (lowest(low,SynthTimeFrame ),"CL");

plot22 (highest(high,SynthTimeFrame ),"CH");

plot23 (Close,"CC");

Plot24 (iff ( firstCandle =1 ,TodayOpenPrice ,OpenValue[1]),"CO") ;

if Plot23 > Plot24 then setplotcolor (23,cyan) else

if Plot23 < Plot24 then setplotcolor (23,magenta) else

setplotcolor (23,yellow);

end;

if Show.SubText then

begin

Plot10 (lowest(low,SynthTimeFrame )-5*ticksize, "Dummy");//set to invisible

NumBarsText = text_new_s (DATE, Time_S, lowest(low,SynthTimeFrame )-ticksize,"" );

Text_SetString (NumBarsText,

ifftext (Show.UpTminusDnT," Del: "+ NumToStr ( TotalAsk- TotalBid , 0) +newline,"")+

ifftext (Show.UpT, " Ask: "+NumToStr ( TotalAsk, 0) +newline,"")+

ifftext (Show.DnT, " Bid: "+NumToStr ( TotalBid , 0) +newline,"") +

ifftext (Show.UpTplusDnT, " Vol: "+NumToStr ( (TotalAsk+TotalBid ), 0) ,""));

if TotalAsk- TotalBid <0 then text_SetColor (NumBarsText, red) else text_SetColor (NumBarsText, green) ;

text_setsize (NumBarsText, TxTSize);

text_setborder (NumBarsText, true);

text_SetStyle (NumBarsText, 1, 0) ;

text_setfontname (NumBarsText, TxTFont);

end;

//print (barcounter, " ",FootPrintPrice," ",BarLow, " ",BarHigh);

TotalAsk = 0;

TotalBid = 0;

BarLow = 999999;

BarHigh = 0;

OpenValue = close;

FirstCandle = 0;

for ResetCounter=0 to BidAskArraySz

begin

Bid.Array [ResetCounter] = 0;

Ask.Array [ResetCounter] = 0;

end;

BarCounter = 0;

//print (barcounter, " ",FootPrintPrice," ",BarLow, " ",BarHigh);

end;

end;

{Function _SpacifyString, Return Type: String

Inputs:

Str(StringSimple),

Width(NumericSimple),

Dir(NumericSimple);

Variables:

Spaces(" "); // That should do.. :)

_SpacifyString = Str;

if (StrLen(Str) < Width) then

begin

if (Dir = 1)

then _SpacifyString = LeftStr(Spaces, Width - StrLen(Str)) + Str;

if (Dir = -1)

then _SpacifyString = Str + LeftStr(Spaces, Width - StrLen(Str));

end;

}