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

Re: Introducing noise to OHLC



PureBytes Links

Trading Reference Links

Ernie:

>Does anyone have a function that will purposely introduce
>somewhat random but controlled noise into the given OHLC values
>to be used to create a new OHLC for that bar.

How about something like this (untested, unverified):

-------------------------------------------------------------------
{Function: randombar
 Return open, high, low, close values perturbed by perturb_pct of the
 current' bar's range.}

Inputs:
    Op(NumericRef),              {Open value returned}
    Hi(NumericRef),              {High value returned}
    Lo(NumericRef),              {Low value returned}
    Cl(NumericRef),              {Close value returned}
    perturb_pct(NumericSimple);  {percentage perturbation, 0-50}

Hi = H + perturb_pct*0.00001*(random(1000)-500)*range;
if range = 0 then Lo = Hi - AvgTrueRange(10)
else begin
    Lo = Hi;
    While Lo >= Hi begin
        Lo = L + perturb_pct*0.00001*(random(1000)-500)*range;
    end;
end;
Op = Op + perturb_pct*0.00001*(random(1000)-500)*range;
If Op > Hi then Op = Hi;
if Op < Lo then Op = Lo;
Cl = H + perturb_pct*0.00001*(random(1000)-500)*range;
If Cl > Hi then Cl = Hi;
if Cl < Lo then Cl = Lo;

-------------------------------------------------------------------
-- 
  ,|___    Alex Matulich -- alex@xxxxxxxxxxxxxx
 // +__>   Director of Research and Development
 //  \ 
 // __)    Unicorn Research Corporation -- http://unicorn.us.com