[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fw: Constant vol bars partial solution (+DLL querstion)



PureBytes Links

Trading Reference Links

The ELA was attached when it left my mail box...not sure why it didn't
appear...
Here it, is as text...


R


{Constant Volatility Bars}
{Input: Length of vol-bar in percent of underlying}

{(c) Robert Hodge 1999}

Inputs: Percent(0.00125);
Vars: UBOpen(0),UBHigh(0),UBLow(0),UBClose(0), BarComplete(False);

{if using single Tick display for Data1 go ahead}
if DataCompression = 0 then
begin
 {if on first bar then initialise variables}
 if CurrentBar = 1 then
  begin
   UBHigh = Close;
   UBLow = Close;
   UBOpen = Close;
   UBClose = Close;
  end
 else {not on first tick so start working out high/low of this universal
bar}
  begin
   {if this tick occurs higher then UBHigh then increase bar high}
   if Close > UBHigh then UBHigh = Close;
   {if this tick occurs lower then UBLow then decrease bar low}
   if Close < UBLow then UBLow = Close;
   {if bar is wider than range then stop it and start anew}
   if UBHigh - UBLow > UBOpen * Percent then
    begin
     {bar size is greater than spec so end bar on previous tick}
     UBClose = Close[1];
     {reset bar high/low to what it would have been on previous tick}
     if UBHigh = Close then UBHigh = Close[1];
     IF UBLow = Close then UBLow = Close[1];
     {indicate done}
     BarComplete = True;
    end;

   if BarComplete = True then
    begin
     {draw bar: need to assign these properly in indicator formatting area}
     Plot1(UBOpen, "Open");
     Plot2(UBHigh, "High");
     Plot3(UBLow, "Low");
     Plot4(UBClose,"Close");

     {reset variables to first tick in this next bar}
     UBOpen = Close;
     UBHigh = Close;
     UBLow = Close;
     BarComplete = False;
    end;
  end;
end;