Mark Brown

OddBall Systems

 

New Page 1

Home | About Us | Help | Contact

 

 Mark Brown

 •  Position Trading
 •  Swing Trading
 •  Day Trading

-

 Software Products

 •  Indicators
 •  Systems
 •  Utilities

-

 Resource Center

 •  Code Contribution
 •  OddBall Forum
 •  News Feed
 •  LabLibrary
 •  Glossary
 •  Code Library

-

 Other Items

 •  Links Of Interest
 •  Accolades
 •  Sitemap
 •  E-Mail

-

ICQ 65956237

oddballsystems.com@BitWine
 Free Introductory Chat

 

Code Library
Code Library

Compiling public domain code for the archives while continually producing advanced proprietary code.

In order to get a indicator simply click on the name, the file will open showing the text then click edit at the top of your screen, click select all, click edit at the top of your screen again, now click copy. Go to the Omega Power Editor and click file new, click indicator, name the indicator click ok. Now click edit, then click paste.Your done hit the F3 key to verify.

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

The Original OddBall System Logic Below

The OddBall System is a FREE and fully disclosed, mechanical trading model.  Please visit the Contribution page to review the original and variations of the system complete with code in text and native platform file format.  OddBall systems code is available in TradeStation, MetaStock, WealthLab and eSignal format.  

Also note that there are free Email Alerts to notify you via email of new position changes in real time.  Please visit the Email Alerts page to manage this service and choose amongst plain text or html delivery methods.

Active Trader Magazine - December 2000 issue: OddBall Position System Code

{Data1 = Either the SP cash S&P 500 index tracking stock or the S&P 500 commodity futures contract. 
  Data2 = Advancing issues of the Nyse.   
  * this was added after article was released to be sure that a buy-sell does not occur on the closing bar.}

if time >830 and time<= 1500 then begin {*}

{based upon (GMT-06:00) Central Time (US and Canada) - note you may have to adjust for your time zone.}

Inputs: RL(7), BZ(3), SZ(1);

           If ROC(Close Data2, RL)>BZ Then Buy;
           If ROC(Close Data2, RL)<SZ Then Sell;
end; {*}


Easy Language from the Omega-list below.


Kase Indicator

Origin: omega-list
Written by: Mark Brown
Date found: 30 sep 97
{idea from Cynthia Kase}
input: N1(10);

var:KSDIUP(0),KSDIDN(0);

if  average(@TrueRange, n1) > 0 then
KSDIUP = ((high[N1]/low))/(( average(V, N1) * SquareRoot(n1)))
else KSDIUP = KSDIUP[1];

if  average(@TrueRange, n1) > 0 then
KSDIDN = ((high/low[N1]))/(( average(V, N1) * SquareRoot(n1)))
else KSDIDN = KSDIDN[1];

if KSDIUP>KSDIDN then plot1(l,"l");
if KSDIUP<KSDIDN then plot2(h,"h");

if KSDIUP=KSDIDN then plot3((h+l)/2,"m");

Oscillator of Kase indicator

Origin: omega-list
Written by: Mark Brown
Date found: 30 sep 97

input: N1(10);

var:KSDIUP(0),KSDIDN(0),jj(0);

if  average(@TrueRange, n1) > 0 then
KSDIUP = ((high[N1]/low))/(( average(V, N1) * SquareRoot(n1)))
else KSDIUP = KSDIUP[1];

if  average(@TrueRange, n1) > 0 then
KSDIDN = ((high/low[N1]))/(( average(V, N1) * SquareRoot(n1)))
else KSDIDN = KSDIDN[1];

jj=ksdidn-ksdiup;

if KSDIUP>KSDIDN then plot1(jj,"l");
if KSDIUP<KSDIDN then plot2(jj,"h");

a Kaufman kinda thing

Origin: omega-list
Written by: Mark Brown
Date found: 30 sep 97

input: period(5), indate(940331),yield(0);
vars:  sum(0), aclose(0), ahigh(0), alow(0), sumER(0), sumvlty(0),
          change(0), netchange(0), pcnet(0), pchange(0), maxrange(0),
          crange(0), ER(0), avgER(0), avglty(0), avgmaxv(0), sumrange(0), 
          summax(0);

{Noise(%) = Absolute price range perday, in percent
Mom = Momentum, net price change over time}


if yield = 0 then begin
  aclose = close;
  ahigh = high;
  alow = low;
   end
else if yield = 1 then begin
{Euros, T-Bills and 3 month rates}
  aclose = 100 - close;
  alow = 100 - high;
  ahigh = 100 - low;
   end
else if yield = 2 then begin
{Bonds and Notes: approx 100=8%, each 8 points = 1% the 164 =0}
  aclose = 164 - close;
  alow = 164 - high;
  ahigh = 164 - low;
  end;

change = @AbsValue(aclose - aclose[1]);
pchange = 0;
 if aclose[1] <> 0 then pchange = change*100/aclose[1];
sum = @summation(pchange,period);
netchange = @AbsValue(aclose - aclose[period]);

{close - only and maximum calculations, in percent}
pcnet = 0;
crange = 0;
maxrange = 0;
if aclose[period] <> 0 then begin
  pcnet = netchange*100/aclose[period];
  crange = (@highest(aclose,period) -
@lowest(aclose,period))*100/aclose[period];
  maxrange = (@highest(ahigh,period) -
@lowest(alow,period))*100/aclose[period];
  end;
sumrange = sumrange +crange;
summax = summax + maxrange;

ER = 1.0;
if sum <> 0 then ER = pcnet / sum;
sumER = sumER + ER;
Print
(currentbar:5:0,",PcNet",pcnet:4:2,",Crange",crange:4:2,",MaxRange",maxrange:4:2,",ER",ER:3:3);

if date >= indate then begin
 avgER = sumER/currentbar;
 avglty = sumrange/currentbar;
 avgmaxv = summax/currentbar;
Print
(currentbar:5:0,",p=",period:3:0,",avgER=",avgER:2:3,",avgVlty=",avglty:3:2,"%,avgMaxv",avgmaxv:3:2,"%");

end;

plot1(avger,"AVGER");
plot2( er,"ER");

More from Kaufman

Origin: omega-list
Written by: Mark Brown
Date found: 30 sep 97

input:  Erperiod(10), Erentry(.25), Erexit(.03), maxavg(1.00),
maxchg(1.5), option(2);
vars:  change(0),pchange(0),noise(0),signal(0), diff(0), efratio(0),
ERavg(0), ERsd(0), ERsd3a(0), ERsd3(0);

{CALCULATE EFFICIENCY RATIO}
diff = @AbsValue(close - close[1]);
if currentbar > ERperiod then begin
  change = close - close[ERperiod];
  pchange  =  change*100/close[ERperiod];
  signal = @AbsValue(change);
  noise = @summation(diff,ERperiod);
  efratio = 1.00;
  if (noise <> 0 ) then efratio = signal/noise;
  ERavg = @average(efratio,21);
  ERsd = @stddev(efratio,21);
  ERsd3a = @average(ERsd,3);
  ERsd3 = @average(Eravg - ERsd,3);

{Entry signals}
  if efratio > Erentry and pchange > .000 then plot1(efratio,"+");
  if efratio > Erentry and pchange < .000 then plot2(efratio,"-");
end;

if efratio < ERexit then plot3(efratio,"exitS");
plot4(noise/10,"exitL");

Larry Connors, secrets of a hedge fund Mgr.

Origin: omega-list
Written by: Mark Brown
Date found: 30 sep 97
{data1=sp futures data2=sp cash}

input:extra(.50);

if t=1603 then value1=C of data1;
if t=1603 then value2=C of data2;
if t=1603 then value3=value1-value2;
value4=value3+value2;
value5=value4+extra;

if t>=1603 and t<=1615 and DayOfWeek(date)<5 then
plot1(value5,"SELL");

if t>=1603 and t<=1615 and DayOfWeek(date)<5 then
plot2(value5+.50,"STOP");

if t>=1603 and t<=1615 and DayOfWeek(date)<5 then
plot3(value5-.50,"TARGET");

Even more Kaufman

Origin: omega-list
Written by: Mark Brown
Date found: 30 sep 97

input : vbars(10),shockfac(3),endshock(1.00) ;
vars :vlty(0),norm(0),avgTr(0),ix(0),iy(0),na(0),vmax(100),trend(0),save(0),x(0);

if DataCompression=1 and TrueHigh >= average(TrueHigh,vbars) then x =h
else
if DataCompression=1 and TrueLow <= average(TrueLow,vbars) then x =l
else
if DataCompression= 2 then x= c else
if DataCompression= 3 then x= c else
if DataCompression= 4 then x= c ;

Arrays : rng[100](0) ;
{average true range during selected market periods}
if currentbar <= vbars then begin
{initilization}
if na <= vmax then begin
na = na + 1 ;
rng[na] = @TrueHigh - @TrueLow ;
end ;
end
else if currentbar = vbars + 1 then begin
{sort range and find initial median value}
for ix = 1 to na - 1 begin
for iy = 2 to na begin
if rng[ix] < rng[iy ] then begin
save = rng[ix] ;
rng[ix ]= rng[iy] ;
rng[iy] = save ;
end ;
end ;
end ;
avgTr = rng[@IntPortion(na/2)] ;
end
else if currentbar > vbars + 1 then begin
{normal processing}
{current volatility uses all bars}
vlty = @TrueHigh - @TrueLow ;
{test for price shock levels}
norm = avgTR ;
if vlty/avgTR > shockfac then begin
if TrueHigh >= average(TrueHigh,vbars) then
if vlty>= shockfac then
plot1(x,">shock+");end;

if vlty/avgTR > shockfac then begin
if TrueLow <= average(TrueLow,vbars) then
if vlty>= shockfac then
plot2(x,">shock-");end;

if vlty >=endshock and vlty<= shockfac then plot3(c,"shockmid");

if vlty < endshock then plot4(c,"<shocklow");

end;

Undocumented use of a function

Origin: omega-list
Written by: Mark Brown
Date found: 30 sep 97
{undocumented use of a function TradeStation has many,
this one looks like the aroon, in a recent S&C article.

This function is used internally and should not be called directly by
the user.}


inputs:PriceH(H),PriceL(L),Length(10);
plot1(FastHighestBar(PriceH,Length),"FHB");
plot2(FastLowestBar(PriceL,Length),"FLB");

intraday fib juck here it is

Origin: omega-list
Written by: Mark Brown
Date found: 30 sep 97

var:r(0),f(0),hf(0),lf(0);

r=IDhigh-IDlow;
f=r*.68;
hf=IDhigh-f;
lf=IDlow+f;
if t>1015 then
plot1(hf,"hf");
if t>1015 then
plot2(lf,"lf");
plot3(idhigh,"high");
plot4(idlow,"low");

outperform CatScan and Aberration

Origin: omega-list
Written by: Mark Brown
Date found: 1 oct 97
{
Since my first posting of a system by mistake that was missing some
critical user functions, I have be inundated by request for some serious
systems. So in response to these request I am posting here a system that
should out perform both CatScan and Aberration. The system is very
simple as you can see and I have many various versions of it. I traded
it for years before I hit on the nonlinear stuff. Most important it is
free! I have hoarded code long enough to know allot of stuff works ok.
It's as much a mind game as anything and if you want to make money let
your mind go blank and trust the system, the system can be intuitive or
computerized or any blend thereof. But defined and cast in stone it must
be.
In response to the editors comment in S&C magazine, in which he said
there is no Holy Grail. I say pop poo on you! Just because you are a
native in the woods of the jungle doesn't mean there isn't a cure for
your disease here in the city. You just don't have it!

Mark

}

inputs:BBLength(38),BBStdDev(3),
BBHPrice(ADAPTIVE(H,10)),BBLPrice(ADAPTIVE(L,10));

vars:BBH(0),BBL(0);

BBH=BollingerBand(BBHPrice,BBLength,BBStdDev);
BBL=BollingerBand(BBLPrice,BBLength,-BBStdDev);

if c >bbh then buy;
if c<bbl then sell;

{
P.S. The adaptive function part is Perry Kaufmans:
}

inputs:price(numericseries),period(numericsimple);

vars: noise(0),signal(0),dif(0),efratio(0),
       smooth(1),fastend(.666),slowend(.0645),am(0);

{CALCULATE EFFICIENCY RATIO}
dif=@AbsValue(price - price[1]);
if(currentbar <= period) then am =price;
if(currentbar > period)then begin
        signal = @AbsValue(price - price[period]);
        noise = @summation(dif,period);
        efratio = signal/noise;
        smooth = @Power(efratio*(fastend - slowend) + slowend,2);

{ADAPTIVE MOVING AVERAGE}
       am = am[1] + smooth*(price - am[1]);
     Adaptive=am;
        end;

What's an Aroon?

Origin: omega-list
Written by: Mark Brown
Date found: 1 oct 97
{THIS IS AN AROON}

input:thold(20),length(25);
var:hiref(0),loref(0);
hiref=100*((length-nthhighestbar(1,h,length))/length);
loref=100*((length-nthlowestbar(1,l,length))/length);
plot1(hiref,"hi");
plot2(loref,"lo");
plot3(50+thold,"hiref");
plot4(50-thold,"loref");

Calm markets good for scalping

Origin: omega-list
Written by: Mark Brown
Date found: 1 oct 97

inputs:adxlen(28),adxavg(2),dmilen(28),dmiavg(2),adxzone(15);
{sp,$tick,$ticki,$adv,$dec}
inputs: N(25),UDVzone(1);
inputs:LENGTH(20),FRSTDATA(C OF DATA4),SECNDATA(C OF DATA5);

vars:v1(0),v2(0),v3(0),v4(0),v5(0),v6(0),v7(0),v8(0),v9(0),v10(0),v11(0),v12(0);

v1=ADX(adxlen);
v2=ADXZone;
v3=average(value1[1],adxavg);
v4=average(dmiPlus(dmilen),dmiavg);
v5=average(dmiMinus(dmilen),dmiavg);
v6=UDVolume(N);
v7=UDVzone;
v8=Diff(FRSTDATA,SECNDATA);
v9=average(Diff(FRSTDATA,SECNDATA),LENGTH);

{--------------------function Diff-------------}

{Diff returns the difference of the two data series
  specified by the inputs.
  This is used to take the difference of Advances - Declines
   where Advances is Data2 and Declines is Data3}



inputs: FrstData(numericseries),SecnData(numericseries);
Diff = FrstData - SecnData;


condition10=v8<v9;
{A/D Line lessr than average A/D line showing calm market}
Condition1=v1<=v2;
{ADX below ADXzone showing market is still}
Condition2=v3>v1;                                                          
{ADXavg greater than ADX so its rising showing market strength increassing}

Condition3=v4>v5;
{DMIplus greater than DMI minus showing market direction up}
condition4=v4<v5;
{DMIplus less than DMI minus showing market direction down}

condition5=v6<v7;
{UDV Less Than UDVzone showing market stillness}

condition6=h of data2<280 and h of data2>50;               
{High of $Tick less than 280 showing average trading}
condition7=l of data2>-280 and l of data2<-50 ;              
{Low of $Tick less than -280 showing average trading}

condition8=h of data3<21;
{High of $Ticki less than 21 showing average  trading}
condition9=l of data3<-21;
{Low of $Ticki less than -21 showing average  trading}

{-------------------------------- all items above are to identify calm market------}

if Condition1 then plot1(o,"1");
if condition5 then plot2(h,"2");
if condition6 then plot3(c of data2,"3");
if condition7 then plot4(c of data2,"4");

Pretty weird late night stuff

Origin: omega-list
Written by: Mark Brown
Date found: 1 oct 97

input:NUM(10),avglen(5),thold(10);

value1 =
MaxList(h-h[1],h-h[2],h-h[3],h-h[4],h-h[5],h-h[6],h-h[7],h-h[8],h-h[9],h-h[10],h-h[11],
h-h[12],h-h[13],h-h[14],h-h[15],h-h[16],h-h[17],h-h[18],h-h[19],h-h[20]);

value3 =
MaxList(h-h[21],h-h[22],h-h[23],h-h[24],h-h[25],h-h[26],h-h[27],h-h[28],h-h[29],h-h[30],h-h[31],
h-h[32],h-h[33],h-h[34],h-h[35],h-h[36],h-h[37],h-h[38],h-h[39],h-h[40]);

value5 =
MaxList(h-h[41],h-h[42],h-h[43],h-h[44],h-h[45],h-h[46],h-h[47],h-h[48],h-h[49],h-h[50],h-h[51],
h-h[52],h-h[53],h-h[54],h-h[55],h-h[56],h-h[57],h-h[58],h-h[59],h-h[60]);

value2 =
MinList(l-l[1],l-l[2],l-l[3],l-l[4],l-l[5],l-l[6],l-l[7],l-l[8],l-l[9],l-l[10],l-l[11],
l-l[12],l-l[13],l-l[14],l-l[15],l-l[16],l-l[17],l-l[18],l-l[19],l-l[20]);

value4 =
MinList(l-l[21],l-l[2],l-l[23],l-l[24],l-l[25],l-l[26],l-l[27],l-l[28],l-l[29],l-l[30],l-l[31],
l-l[32],l-l[33],l-l[34],l-l[35],l-l[36],l-l[37],l-l[38],l-l[39],l-l[40]);

Value6 =
MinList(l-l[41],l-l[2],l-l[43],l-l[44],l-l[45],l-l[46],l-l[47],l-l[48],l-l[49],l-l[50],l-l[51],
l-l[52],l-l[53],l-l[54],l-l[55],l-l[56],l-l[57],l-l[158],l-l[59],l-l[60]);

Value9 =averageMaxList(0,value1)*SquareRoot(num),avglen);
Value10 =average(  MinList(0,value2)*SquareRoot(num),avglen);
Value11= value9-(-value10);
plot1(value11,"ax");

if value9< -value10 then begin
plot2(-thold,"di-");end;

if value9> -value10 then begin
plot3(thold,"di+");end;

if value11>0 then
if Value11[0]>(average(value11[1],2)) then plot4(0,"TrendStart") ;

if value11<0 then
if Value11[0]<(average(value11[1],2)) then plot4(0,"TrendStart");

'recent magazine system I saw'

Origin: omega-list
Written by: Mark Brown
Date found: 1 oct 97

input: LEN1(100),fac(.05);

var:aa(0);

aa=(Log(c/c[len1])/(StdDevx(Log(c/c[1]),len1)*SquareRoot(len1)));
if aa>fac and aa[1]<fac then buy;
if aa<-fac and aa[1]>-fac then sell;

The Kaufman Smoothing Constant Part of the Graile

Origin: omega list
Written by: Mark Brown
Date found: 1 oct 97

inputs:Period(10),Price(C),Z1(.10),Z2(.20),Z3(.30);
vars: noise(0),signal(0),difference(0),efratio(0),
          smooth(1),fastend(.666),slowend(.0645),AMA(0);

{CALCULATE EFFICIENCY RATIO}
difference = @AbsValue(price - price[1]);
if(currentbar <= period) then AMA = price;
if(currentbar > period)then begin
       signal = @AbsValue(price - price[period]);
       noise = @summation(difference,period);
       efratio = signal/noise;
       smooth = @Power(efratio*(fastend - slowend) + slowend,2);
       plot1(smooth,"AMAsmooth");
       end;
  plot2(Z1,"Z1");
  plot3(Z2,"Z2");
  plot4(Z3,"Z3");

Note for Newbies

Origin: omega-list
Written by: Mark Brown
Date found: 2 oct 97
{Well I didnt relize so many people are having problems with the adaptive
user function.

It is a user function, not a system, not a indicator, a USER FUNCTION!

Functions can be thought of as a shortcut list. If a user has a certain
set of rules that he or she would like to use often, these can be
written inside a function. That function can then be called, by using a
single word, inside any study, system, or even another function. This
saves time and also makes the other analysis techniques easier to
understand.

Like any language, Easy Language has a set of basic components that make
up the core of the language. Components are words, characters, or
methods used to construct statements. These components must be organized
and structured correctly to create valid sentences or statements. The
organized pattern or structure of language is called syntax. If a
statement does not have correct syntax, the computer will be unable to
recognize it as valid. When the components of Easy Language are used in
the proper syntax, virtually any trading strategy can be written.
One of the major components of Easy Language is the function. Many
functions were written by Omega Research, Inc. for the convenience of
the user; however, the user may write his or her own functions. Then,
all that users have to do is to reference the function while writing
their own studies, systems, or other functions. Functions that are
already included with TradeStation are covered in further detail later
in this chapter.

Ultimately, the goal will be to write complete statements using Easy
Language. We will first look at how to put the different components of
the language together to form various expressions. Then we will discuss
how to turn these expressions into statements. Once a user is able to
write statements, he or she will have little difficulty turning ideas
into studies or systems that TradeStation can read and recognize.


Make a USER FUNCTION and name it Adaptive then insert the code below and
verify, thats it.
I have included an ELA this time for the SC users.

Cut and paste the below code to the power editor USER FUNCTION and name
it Adaptive.}



inputs:price(numericseries),period(numericsimple);

vars: noise(0),signal(0),dif(0),efratio(0),
       smooth(1),fastend(.666),slowend(.0645),am(0);

{CALCULATE EFFICIENCY RATIO}
dif=@AbsValue(price - price[1]);
if(currentbar <= period) then am =price;
if(currentbar > period)then begin
        signal = @AbsValue(price - price[period]);
        noise = @summation(dif,period);
        efratio = signal/noise;
        smooth = @Power(efratio*(fastend - slowend) + slowend,2);

{ADAPTIVE MOVING AVERAGE}
       am = am[1] + smooth*(price - am[1]);
     Adaptive=am;
        end;

text-objects

Origin: omega-list
Written by: Mark Brown
Date found: 5 oct 97
{
r = resistance
last = the last price or current real time price
s = support
factor = the empirical range of a choppy market
lookback = just that a reference in time and space

user function adaptive can be substituted with about anything.}


input:factor(1.30),lookback(10);

var:txtr(0),  r(" r - - - - - - - - - - - - - - - - -");
var:txt(0),last(" last - - - - - - - - - - - - - - - - -");
var:txts(0),s(" s - - - - - - - - - - - - - - - - -");

value9=c ;
value8=adaptive(l,lookback)-factor;
value7=adaptive(h,lookback)+factor;

if currentbar=1 then begin txtr= Text_New
(d,1,0,"--"+r+r+r+r+r+r+r+r+r+r+r+r+r+r);
Text_SetColor(txtr,5);
Text_SetStyle(txtr,0,2);end;

if currentbar=1 then begin txt= Text_New
(d,1,0,"--"+last+last+last+last+last+last+last+last+last+last+last+last+last+last);

Text_SetColor(txt,8);
Text_SetStyle(txt,0,2);end;

if currentbar=1 then begin txts= Text_New
(d,1,0,"--"+s+s+s+s+s+s+s+s+s+s+s+s+s+s);
Text_SetColor(txts,4);
Text_SetStyle(txts,0,2);end;

{1=black,2=blue,3=cyan,4=green,5=magenta,6=red,7=yellow,8=white}

if c >= 0 then begin Text_SetLocation(txtr,d,1,value7);end;
if c >= 0 then begin Text_SetLocation(txt,d,1,value9);end;
if c >= 0 then begin Text_SetLocation(txts,d,1,value8);end;

plot1(c,"");

art of minimizing code

Origin: omega-list
Written by: Mark Jurik & Mark Brown
Date found: 5 oct 97
{My thanks to Mark Jurik for rewriting some of my code and sending it to me.
There is an art form to minimizing code and M.J. is certainly expressing it here.
Again thanks to all who have in the past and are in the future posting code and
answering questions. Mark}


input: NUM(10), avglen(5), thold(10);

value1 = H - lowest  ( H , 60 ) ;
value2 = L - highest ( L , 60 ) ;

Value9  =averageMaxList(0,value1),avglen);
Value10 =averageMinList(0,value2),avglen);

Value11 = (value9 + value10) * SquareRoot(num) ;
plot1(value11,"ax");

if value11 < 0 then begin
        plot2(-thold,"di-");
        if Value11 < average(value11[1],2) then plot4(0,"TrendStart");
        end;

if value11 > 0 then begin
        plot3( thold,"di+");
        if Value11 > average(value11[1],2) then plot4(0,"TrendStart") ;
        end;

to get the very last tick in a tick chart

Origin: omega-list
Written by: Mark Brown
Date found: 7 oct 97
{To get the very last tick in a tick chart}

input:back(10);
var:z(0);
if date = CurrentDate then begin
for z=0 to back-1 begin
  plot1[z](c,"c");
end;
plot2[back](c[1],"");
end;

{plot1-(color)-point
 plot2-black-point}

colored time-intervals on tick-charts

Origin: omega-list
Written by: Rick Saidenberg
Date found: 12 oct 97
{This was programmed for me (Mark Brown) by Rick Saidenberg. Before I
had all my systems fully automated, I DayTraded using a 5 tick
bar chart. I liked the tick bar charts because they smoothed
out the indicators and were more responsive to quick jerk
moves that time frame based charts would wreck you on.
But I always missed the time intervals that a time chart
provides. Like knowing every bar = 5 minutes ect. So Rick
wrote this paint bar study  that paints the bars on a tick bar
chart a different color for each time interval. So if you using
a 5 tick bar chart and you want the color of the bars to change
every 5 minutes then set the rotate input to 5.
Mark

=====code starts here=====}


input:rotate(5);

var:go(0),new(0);

if d>d[1]or currentbar=1 then begin
  if go=0 then go=1 else go=0;
  new=TimeToMinutes(Sess1StartTime)+rotate;
end;

if TimeToMinutes(t)>new then begin
  if go=0 then go=1 else go=0;
  new=new+rotate;
end;

if go=1 then begin
  plot1(h,"time");
  plot2(l,"rotate");
end;

volatility based system + SAR code

Origin: omega-list
Written by: Mark Brown
Date found: 27 nov 97
{
This system code is using volatility to both time the entry of a position
and to determine the amount of extra points that should be added to a
limit type order. I thought just for fun, I have found when I'm wrong I'm
usually really wrong so I added some SAR code that was provided to
me by Rich Estrem my partner in the Market Profile Indicator. Which
can be seen at <A HREF="http://www.markbrown.com/estrem.html">MB</A>
Sorry for the spam but we didn't get a review in S&C, like some. But we
are furnishing code here that shows promise and the price is right.
     Mark
}


{This could be run on a five minute chart with close all trades
at eod and mm of 1-3 pts and pt of 2-5 pts.}


input:V1(10),V2(9),AL(5),sar_pts(4);

vars: Vola_average(0),  Vola_trend(0),p1(0),p2(0),extra(0);

P1=Volatility(V1);
P2=average(P1,V2);
if p1>=1.5 then extra=1.20;
if p1<=1.5 then extra=.50;

 Vola_average=average(P1,V2);
 if Vola_average>Vola_average[1] and P1>Vola_average then
  Vola_trend=1
 else if Vola_average<Vola_average[1] and P1<Vola_average then
  Vola_trend=-1
 else
  Vola_trend=Vola_trend[1];


  if Vola_trend<0 and Vola_trend[1]>=0
  then begin if c crosses below average(c,AL) then begin
               value1=c - extra;
            sell tomorrow at value1 Limit;
end;end;


     if Vola_trend<0 and Vola_trend[1]>=0  {Corrected this line of code ; -}
          then begin if c crosses above average(c,AL) then begin
             value2=c + extra;
          buy tomorrow at value2 Limit;
end;end;

if MarketPosition=1 then sell("Ssar") at EntryPrice(0)-sar_pts stop;
if MarketPosition=-1 then buy("Bsar") at EntryPrice(0)+sar_pts stop;

Keltner bands

Origin: omega-list
Written by: na
Date found: 3 dec 97
{ *******************************************************************
       Indicator:       Keltner Bands 
       Provided By       : Retrieved from Internet 
     submitted to omega by Mark Brown
********************************************************************}


input: Price(close), MALen(10), Const(.8);
vars: Centline(0), AvgRange(0), Upper(0), Lower(0);

CentLine =  average(Price,MALen);
AvgRange = average(TrueRange,MALen);
Upper = CentLine+(AvgRange*Const);
Lower = CentLine-(AvgRange*Const);
plot1(Upper,"Upper");
plot2(Lower,"Lower");

FibTimeProjections

Origin: omega-list
Written by: Unknown
Date found: 20 sep 97
{ FibTimeProjections }

input: Adate(0), Atime(0), Bdate(0), Btime(0),
        Width(0), Displace(0), Color(Tool_Red);
var: Abar(0), Bbar(0), AB(0);
array: proj[3](0);

{
Width - the thickness of the projected timeline, a value from 0 to 6
Displace - the number of bars back that the projected line will appear
(0 for no displacement)
Color - the color of the projected timeline
}


{ Associate the barnumber with the date/time input }
if date = Adate and time = Atime then
        Abar = currentbar;
if date = Bdate and time = Btime then
        Bbar = currentbar;

{ After we have the A and B barnumbers, calculate the projected
barnumbers }

if Abar <> 0 and Bbar <> 0 and AB = 0 then begin
        AB = Bbar - Abar;
        proj[0] = IntPortion(Abar + AB * 1.618);
        proj[1] = IntPortion(Abar + AB * 2.000);
        proj[2] = IntPortion(Abar + AB * 2.618);
end;

{ Check the current bar to find out if a projected timeline should be
shown }

var: ii(0), handl(0);
for ii = 0 to 2 begin
        if currentbar = proj[ii] - displace then begin
                { Yes, so create it and set its attributes }
                handl = TL_New(date,time,0,date,time,100);
                TL_SetExtLeft(handl, true);
                TL_SetExtRight(handl, true);
                TL_SetSize(handl, width);
                TL_SetColor(handl, color);
        end;
end;
if false then plot1(0,"");

Draw linear regressionlines for two past periods

Origin: omega-list
Written by: Earl Adamy
Date found: 21 jan 98
{ *****************************************************************************
Indicator  : i_LRPriceShort
   Date     : 8/19/95 2:56PM
Author     : Earl Adamy     Copyright 1995, all rights reserved.
Transfer   : o:\omega\inds\lrprice
History    : 8/19/95 9:06AM create indicator to mark pivot points
Purpose    : Draw linear regression lines for two past periods
Notes      : MaxPlotBarsBack must be long enough for pivot extreme to be
reversed

***************************************************************************** }

    inputs  : Periods(20);
    vars    : LRValueEnd(0),
                 LRSlopeEnd(0),
                 LRStdDevEnd(0),
                 LRValueBeg(0),
                 PlotBarsBack(0),
                 LRChanWidth(0);

    LRValueEnd = LinearRegValue(close, Periods, 0);
    LRSlopeEnd = LinearRegSlope(close, Periods);
    LRStdDevEnd = stddev(close, Periods);
    {
    Print(file("o:\omega\i_LRPrc.log"),Date, BarNumber, " Close ", Close, "
LRVal ", LRValueEnd, " LRSlp ", LRSlopeEnd, " LRStd ", LRStdDevEnd);
    }

    if date = LastCalcDate then begin
        {Plot end of last LR period)}
        PlotBarsBack = 0;
        LRChanWidth = (2 * LRStdDevEnd[PlotBarsBack]);
        plot1[PlotBarsBack](LRValueEnd[PlotBarsBack],"LRP Short");
        plot2[PlotBarsBack]((LRValueEnd + LRChanWidth)[PlotBarsBack],"LRP S
Upper");
        plot3[PlotBarsBack]((LRValueEnd - LRChanWidth)[PlotBarsBack],"LRP S
Lower");
        {Plot begin of last LR period)}
        LRValueBeg = LRValueEnd[PlotBarsBack] + ((Periods-1) *
(LRSlopeEnd[PlotBarsBack] * -1));
        PlotBarsBack = Periods - 1;
        plot1[PlotBarsBack](LRValueBeg, "LRP Short");
        plot2[PlotBarsBack]((LRValueBeg + LRChanWidth), "LRP S Upper");
        plot3[PlotBarsBack]((LRValueBeg - LRChanWidth), "LRP S Lower");
        {Plot end of prev LR period)}
        plot4[Periods](LRValueEnd[Periods],"LRP S Prev");
        {Plot begin of last LR period)}
        LRValueBeg = LRValueEnd[Periods] + ((Periods-1) *
(LRSlopeEnd[Periods] * -1));
        PlotBarsBack = (Periods * 2) - 1;
        plot4[PlotBarsBack](LRValueBeg, "LRP S Prev");
    end;

Upside/DownSide Volume

Origin: omega-list
Written by: Aldo A. Palles
Date found: 1 oct 97
{
Written by Aldo A. Palles

Notes:  Upside/DownSide Volume

Source: Investor's Business Daily
}


inputs: N(numericsimple);
vars: UpVol(0), DnVol(0), x(0);


UpVol = 0;
DnVol = 0;

for x = 0 to N - 1 begin
   if close[x] > close[x+1] then UpVol = UpVol + volume[x];
   if close[x] < close[x+1] then DnVol = DnVol + volume[x];
end;

if DnVol > 0 then UDVolume = UpVol / DnVol;

(intra day) Delta Phenomenon

Origin: omega-list
Written by: Patrick Mikula
Date found: 3 oct 97
{Dear Omega List,

Below is an indicator which will plot the colored lines for the intra
day  Delta Phenomenon.  I have provided it in text and ELA form.  The
text below is actually in the ELA file, please read it before applying
the indicator to intra day data.

Good Luck
Patrick Mikula.}


{**************************************************************************
Delta Phenomenon Patent Pending?
Being a financial astrologer I have always found  the moon to be a
valuable trigger of market events so I was naturally impressed with
Wells Wilder's book The Delta Phenomenon.  The problem most traders have
with this trading method is simply that the actual entry and exit points
are very subjective.  For my own personal use I programmed an
EasyLanguage system which monitors the intraday, daily and weekly Delta
Phenomenon counts and  combines them with support and resistance levels,
the direction of  2 moving averages and some candle stick patterns to
create a fully mechanical version of the Delta Phenomenon.  I had
planned to release this system but the Delta Phenomenon book written in
1991 claims that it has a patent pending.  I called the Delta Society
International several times over the course of about 8 months and they
always claimed that the patent had in fact been granted but refused to
provide the patent number.  The fact that the Delta Society
International claims the patent was granted means that I will not
release any delta system which plots numbers because the lock-in number
counts are what makes the Delta Phenomenon the method that it is.

The indicator below will plot the four colored lines of the intra day
Delta Phenomenon.  This is intended to be a time saving aid for traders
using this method it is not the actual method.  If you want to
understand the Delta Phenomenon  lock-in number counts please buy the
book The Delta Phenomenon written by Wells Wilder.

WARNING 1: If there are 4 or more days missing in a row, this indicator
will not plot the correct color line.

WARNING 2: This indicator plots a trend line from a bars low to high
then extends the line upward and downward.  If the first bar of the day
has the same low and  high price none of the trend lines  will  plot.

NOTE 1: The FstColor input should be set to a number between 1 and 4 in
order to adjust the color sequence to get it the way you want.  As a
reference point I believe  September 18, 1997 is a red trend line.

NOTE 2:  I  have provided a short line of text above each section of
code to explain what the code does.  

NOTE 3: If you would like an indicator similar to this one but for daily
or weekly charts see my web page were I have an astrological add on for
TradeStation and SuperCharts which can make the required lunar
calculations.  http://www.flash.net/~vibri/

THE INDICATOR CODE STARTS BELOW THIS LINE
*****************************************************************************}




{------------Below sets up the Inputs, Variables and
Values-----------------}

input: FstColor(2);  
Variables: Plotted(false), TLColor(0), Counter(0);
value1 = DateToJulian(date) - DateToJulian(date[1]);

{------Below transfers the input FstColor to the variable
TLColor--------}

if TLColor = 0 then TLColor = FstColor;

{------Below increments the TLColor by the number of days between
bars-----}

if value1 > 0 then begin
TLColor  = TLColor + value1;
plotted = false;
end;

{------Below reduces the  TLColor when it  moves above 4--------}
if TLColor > 4 then TLColor = TLColor - 4;

{--------Below plots a Red Vertical Line on a days first bar-----------}
if TLColor = 1 and plotted = false {TLColor = 1 = Red}
then begin
Value20 = TL_New(date,time,high,date,time,low);
Value21 = TL_SetColor(Value20, Tool_Red);
Value22 = TL_SetExtRight(Value20, true);
Value23 = TL_SetExtLeft(Value20,true);
plot1(high,"delta");
Plotted = true
end;

{--------Below plots a Blue Verical line on a days first bar----------}
if TLColor = 2 and plotted = false {TLColor = 2 = Blue}
hen begin
Value20 = TL_New(date,time,high,date,time,low);
Value21 = TL_SetColor(Value20, Tool_Blue);
Value22 = TL_SetExtRight(Value20, true);
Value23 = TL_SetExtLeft(Value20,true);
plot1(high,"delta");
Plotted = true
end;

{-----------Below plots Dark Yellow Vertical Line on a days first bar-----------}
if TLColor = 3 and plotted = false {TLColor = 3 = Yellow}
then begin
Value20 = TL_New(date,time,high,date,time,low);
Value21 = TL_SetColor(Value20, Tool_DarkYellow);
Value22 = TL_SetExtRight(Value20, true);
Value23 = TL_SetExtLeft(Value20,true);
plot1(high,"delta");
Plotted = true
end;

{--------Below plots a Dark Green Vertical Line on a days first bar------------}
if TLColor = 4  and plotted = false {TTLColor = 4 = Green}
then begin
Value20 = TL_New(date,time,high,date,time,low);
Value21 = TL_SetColor(Value20, Tool_DarkGreen);
Value22 = TL_SetExtRight(Value20, true);
Value23 = TL_SetExtLeft(Value20,true);
plot1(high,"delta");
Plotted = true
end;  

{END EASYLANGUAGE CODE}

Market Mood indicator

Origin: omega-list
Written by: Guus Prick
Date found: 4 oct 97
{Market Mood - (c) G.Prick 1997  e-mail: guus@iaehv.nl
 provides a visual representation of market mood by using trendlines}


inputs: Flen(100);
vars: ax(0),Fhi(0),Flo(0),Midd(0),stem(0),RL(0),LL(0),BLH(0),BRH(0),TLH(0),
TRH(0),LA(0),RA(0); 
if currentbar = 1 then begin
 Fhi = highest(H,Flen);Flo=lowest(L,Flen);
 ax = Fhi-Flo;
 stem = TL_New(date,time,Fhi-.6*ax,date,time,Fhi-.4*ax);
 RL = TL_New(date,time,Fhi-.4*ax,date,time,Fhi-.2*ax);
 LL = TL_New(date,time,Fhi-.2*ax,date,time,Fhi-.1*ax);
 BLH = TL_New(date,time,Fhi-.2*ax,date,time,Fhi-.1*ax);
 BRH = TL_New(date,time,Fhi-.1*ax,date,time,Fhi-.4*ax);
 TLH = TL_New(date,time,Fhi-.6*ax,date,time,Fhi-.2*ax);
 TRH = TL_New(date,time,Fhi-.7*ax,date,time,Fhi-.6*ax);
 LA = TL_New(date,time,Fhi-.7*ax,date,time,Fhi-.6*ax);
 RA = TL_New(date,time,Fhi-.3*ax,date,time,Fhi-.2*ax);
 TL_SetExtLeft(stem, false);TL_SetExtRight(stem, false);
 TL_SetExtLeft(RL, false);TL_SetExtRight(RL, false);
 TL_SetExtLeft(LL, false);TL_SetExtRight(LL, false);
 TL_SetExtLeft(BLH, false);TL_SetExtRight(BLH, false);
 TL_SetExtLeft(BRH, false);TL_SetExtRight(BRH, false);
 TL_SetExtLeft(TLH, false);TL_SetExtRight(TLH, false);
 TL_SetExtLeft(TRH, false);TL_SetExtRight(TRH, false);
 TL_SetExtLeft(LA, false);TL_SetExtRight(LA, false);
 TL_SetExtLeft(RA, false);TL_SetExtRight(RA, false);
 if false then plot1(0,"duh");
end;
if currentbar > 1 then begin
 Fhi = highest(H,Flen);Flo=lowest(L,Flen);       ax = Fhi-Flo; Midd =
 Flen/2; TL_SetEnd(stem,date[Midd],time[Midd],Fhi-.4*ax);
 TL_SetBegin(stem, date[Midd], time[Midd], Fhi-.6*ax);
 TL_SetEnd(RL,date[Midd],time[Midd],Fhi-.6*ax); TL_SetBegin(RL,
 date[Midd-Midd/2], time[Midd-Midd/2], Flo);
 TL_SetEnd(LL,date[Midd],time[Midd],Fhi-.6*ax); TL_SetBegin(LL,
 date[Midd+Midd/2], time[Midd+Midd/2], Flo);
 TL_SetEnd(BLH,date[Midd+Midd/6],time[Midd+Midd/6],Fhi-.2*ax);
 TL_SetBegin(BLH, date[Midd], time[Midd], Fhi-.4*ax);
 TL_SetEnd(BRH,date[Midd-Midd/6],time[Midd-Midd/6],Fhi-.2*ax);
 TL_SetBegin(BRH, date[Midd], time[Midd], Fhi-.4*ax);
 TL_SetEnd(TLH,date[Midd],time[Midd],Fhi); TL_SetBegin(TLH,
 date[Midd+Midd/6], time[Midd+Midd/6], Fhi-.2*ax);
 TL_SetEnd(TRH,date[Midd],time[Midd],Fhi); TL_SetBegin(TRH,
 date[Midd-Midd/6], time[Midd-Midd/6], Fhi-.2*ax);
if close > close[10] then begin
 TL_SetEnd(LA,date[Flen],time[Flen],Fhi-.2*ax);
 TL_SetBegin(LA, date[Midd], time[Midd], Fhi-.5*ax);
 TL_SetEnd(RA,date[1],time[1],Fhi-.2*ax);
 TL_SetBegin(RA, date[Midd], time[Midd], Fhi-.5*ax);
 end else begin
 TL_SetEnd(LA,date[Flen],time[Flen],Fhi-.8*ax);
 TL_SetBegin(LA, date[Midd], time[Midd], Fhi-.5*ax);
 TL_SetEnd(RA,date[1],time[1],Fhi-.8*ax);
 TL_SetBegin(RA, date[Midd], time[Midd], Fhi-.5*ax);
 end;
end;

Historical Volatility (GPF's ?)

Origin: omega-list
Written by: Craig Nelson
Date found: 6 oct 97
{ Name: Historical Volatility    Created: 10/6/97 02:05 PM }

vars: SumSqr(0),Mean(0),Sum(0),counter(0),Hist_Vol(0);
inputs: Length(18);
array: Stdarray[100](0);

if Length > 0  and close > 0 then begin

Sum = 0;
for counter = 0 to (Length-1) begin
 Stdarray[counter] =  Log(close[counter] / close[counter+1]);
 Sum = Stdarray[counter] + Sum;
end;

Mean = Sum / Length;

SumSqr = 0;
for counter = 0 to (Length-1) begin
 SumSqr = SumSqr + ((Stdarray[counter] - Mean) * (Stdarray[counter] -
 Mean));
end;

Hist_Vol = SquareRoot(SumSqr / Length)*SquareRoot(250);

end
else
Hist_Vol = 0;

plot1(Hist_Vol, "Hist_Vol");

{OK, a little background.  This indicator will calculate the correct
Historical Volatility, that is the REAL historical volatility based on the
daily changes(and not Omega definition of volatility) in closing prices.
As far as I know, and based on what I see in my indicator list, there isn't
a UF or Indicator that does this.  For those that trade options, historical
vol is what is compared to market-implied vol to help detect
overpriced/underpriced situations and how to figure out if premiums are fat
or lean.  Anyway, the Indicator verifies OK, but when I try to format the
indicator in a chart I get a GPF from TS.  I'm not sure if this might be
caused by a "stack overflow" from the multitudinous calculations, or if
there is a "divide by zero" problem that slipped through the cracks.  Can
others copy and paste this code into TS and see if they get a GPF?

The above code is a combination of "reinventing the wheel", "divide and
conquer", and the useful suggestions that poured in after I sent out my
initial request.  I'm certainly no EL expert, but I'm learning.  Thanks to
all who helped.  Hopefully, if we can get the GPF bug worked out this
should be a useful indicator to have, assuming Omega hasn't already
included it in TS 4.0 or their next release.  My version of TS is 3.51.}

Raschke/Connors based Historical Volatility

Origin: omega-list
Written by: Robert Adelman
Date found: 6 oct 97
{Craig,

I did try your Historical Volatility indicator, and it runs just fine. I
am not sure why you multiply by sqrt(250). Prior to that point it seems
like you have been figuring standard deviation of the log of C/C[1]. Are
you trying to annualize the volatility?

I have just been writing volatility code in order to look at an idea of
Raschke/Connors: the ratio of 6day to 100 day volatility (code below).
When I simplify my code to remove the ratio, I end up with the same
result as you with a lot less code, and no array (code below). I have also
exported the price series into Excel and verified the code, except for the
fact that it took me a while to figure out that TS uses log to represent a
natural log, ln in Excel.}


*******************************************************************

{User function reaHistVol2
  Traditional volatility calculation:
  StdDev(ln(C/C[1]))}


inputs:VolLen(numericsimple);
Variables: var1(1);

Var1 = Log(close/close[1]);

reaHistVol2 = stddev(Var1,VolLen);

********************************************************

{Indicator reaHistVol2
  Plots volatility as above}


inputs: VolLen(18);

plot1(reaHistVol2(VolLen),"Hist Vol");

********************************************************

{User function reaHistVol
  Computes the ratio of short term/long term volatility}


inputs:ShrtVolL(numericsimple),LongVolL(numericsimple);

Variables: var1(1),var2(.00001);

Var1 = Log(close/close[1]);

if Var1 <> 0 then Var2 = Var1 else Var2 = .00001;

reaHistVol = stddev(Var2,ShrtVolL)/stddev(Var2,LongVolL);

**********************************************************

{Indicator reaHistVol
  Plots the user function above}


inputs: ShrtVolL(6),LongVolL(100);

plot1(reaHistVol(ShrtVolL,LongVolL),"HistVol");

***********************************************************

user function for calculating volatility

Origin: omega-list
Written by: Jrehler
Date found: 7 oct 97
{From:  Jrehler, posted by Mark Brown

Here is my user function for calculating volatility. Wouldn't it be nice
if others were so forth coming?  I think the more examples of code you see the better you
are able to code and test your theories.  I encourage others to publish their code
so we all will benefit.

(You must name the user function MyVolatility or change the code to a
new name) }


inputs : Price(numericseries),Length(numericsimple);
vars    : SumSqr(0),Counter(0),R(0),vari(0),yr_var(0),
 N(1);

if Length <> 0 then begin
  SumSqr = 0;
  R = 0;
  vari = 0;
  yr_var = 0;
  N = 1;

  for counter = 1 to Length begin
    R = (Price[counter] - Price[counter + 1]) / Price[counter + 1];
    r = Log(1 + R);
    SumSqr = SumSqr + (r - Log(1 + average(R,Length) ) ) *  (r - Log(1 +
average(R,Length) ) );
  end;

  vari = SumSqr / (Length - 1);
  if DataCompression = 2 then N = 252
    else if DataCompression = 3 then N = 52
    else if DataCompression = 4 then N = 12;
  yr_var = vari * N;

  HistoricalVolatility = SquareRoot(yr_var);
end
else
  HistoricalVolatility = 0;


{===end of user function===code for indicator below===}

input:price(c),length(25),zone(.150);
plot1(HistoricalVolatility(PRICE,LENGTH),"hv");

Cat Tails indicator - FREE

Origin: omega-list
Written by: Glenn Orlofsky
Date found: 10 oct 97
{This is one of my first indicators which turned into a system. It
basically monitors the trend and breakout on a linear regression level
using highest highs/lows and a tad a standard deviation. You can modify
this for short medium or long term  watching. There are two functions
that it uses. Try this on a daily chart for starters. The DFrmLstB
function counts back the trade days from the last bar (i.e. no Sat or
Sun) but doesn't account for Holiday. It will still give an alert even
though it can't from on screen because the data is missing

**************** Indicator *************}


{Raff-Regression Trend Lines Indicator. Created by: G.M. Orlosky,
Revised 05/14/97}


{TREND LINE INDICATOR. CREATED BY: EMMANUEL LAVELANET, REVISED 07/15/96.

Provided by: Omega Research, Inc.  (c) Copyright 1996 }


{This indicator takes the plot information from a straight Linear Trend
Regression Line and plots two parrallel lines using VALDIFF with
extensions into the future. The inputs, MAXBACK is the number of days
into the past to draw the lines and ANCHOR is the date that you will
choose as the point from which your trend line will extend into the past
and into the future. If you leave the default of Zero in the input
STRENGTH then the number of bars that it will regress for is equal to
your chosen MaxbarsBack. If you enter a STRENGTH greater than Zero it
will regress to the most recent SwingHigh or SwingLow with that
STRENGTH. It projects indefinitely into the future. It also alerts you
depending on the condition you enter in the input ALERTIF.}


input : BarsBack(numericsimple);
var   : x(0);

if currentbar > 1 then begin
 value1 = DateToJulian(LastCalcDate);
 for x = 0 to BarsBack begin
 value2 = JulianToDate(value1);
 value3 = DayOfWeek(value2);
 if value3 = 0 or value3 = 6 then x = x - 1;
  value1 = value1 - 1;
 end;
 DFrmLstB = value2;
end;

{Instead of entering an offset date for the Anchor input simple type in
the function name with the offset; like so...
  INPUTS : Anchor(DFrmLstB(14)),...;}


input:ANCHOR(DFrmLstB(21)),MaxBack(120),AlertIF(false),Strength(0),SwHiOnly(false),SwLoOnly(false);

vars:TREND(0),EXTENT(0),TRENDMAX(0),MAXSTREN(MaxBarsBack),HiMark(0),LoMark(0),X(0);

Arrays: HiDiff[299](0),LoDiff[299](0),P1Array[299](0);

if DataCompression > 1 then begin {1}

EXTENT =  MaxBack;

 if Value30 < EXTENT then begin {2}
 Value30 = Value30 + 1;
 Value31 = date;
 end {2};

 if date > Value31 then begin {3}
    if date = ANCHOR then begin {4}
   if SwHiOnly = true and SwLoOnly = false then begin {5}
   if STRENGTH > 0 and STRENGTH < EXTENT  then
   EXTENT =  SwingHighBar(1,H,STRENGTH,EXTENT);
   end {5};

  if SwLoOnly = true and SwHiOnly = false then begin {6}
  if STRENGTH > 0 and STRENGTH < EXTENT  then
  EXTENT = SwingLowBar(1,L,STRENGTH,EXTENT);
  end {6};

   if STRENGTH > 0 and ((SwHiOnly = false  and SwLoOnly = falseor
(SwHiOnly = true and SwLoOnly = true)) and STRENGTH < EXTENT  then begin
{7}
          if SwingHighBar(1,H,STRENGTH,EXTENT) <
SwingLowBar(1,L,STRENGTH,EXTENT) then
             EXTENT =  SwingHighBar(1,H,STRENGTH,EXTENT) else
   EXTENT = SwingLowBar(1,L,STRENGTH,EXTENT);
   end {7};

       if STRENGTH > 0  and STRENGTH < EXTENT then
  MAXSTREN = EXTENT
  else  MAXSTREN = MaxBarsBack;

       Value60 = LinearRegValue(MEDIANPRICE,MAXSTREN,0);
      Value61 = LinearRegValue(MEDIANPRICE,MAXSTREN,MAXSTREN);
       value3 = barnumber;
      value4 = Value60;
       TRENDMAX = Value60 - Value61;
           if EXTENT > 0 then
            TREND = (Value60 - Value61) / EXTENT;
             for Value9 = 0 to EXTENT begin {8}
    value4 = value4 + (TREND);
            end {8};
   Value11 = Value60;
 end {4};

  if date =  ANCHOR and EXTENT > 0 then begin {9}
   for Value21 = 0 to EXTENT begin {10}
             P1Array[Value21]=(Value11 + Value22);
            Value22 = Value22 - TREND;
         end {10};
  end {9};

  if date =  ANCHOR and EXTENT > 0 then begin {11}
   for X = 0 to EXTENT begin {12}
   HiDiff[X]=(high[X]-P1Array[x]);
   LoDiff[X]=(low[X]-P1Array[x]);
   end {12};
  end {11};

LoMark=LoDiff[0];
HiMark=HiDiff[0];

  for x = 1 to EXTENT begin {13}
  if LoMark > LoDiff[x] then LoMark = LoDiff[x];
  if HiMark < HiDiff[x] then HiMark = HiDiff[x];
  end {13};

  if date =  ANCHOR and EXTENT > 0 then begin {14}
  Value32=0;
   for Value21 = 0 to EXTENT begin {15}
   plot1[Value21](Value11 + Value32 + LoMark,"BOT");
   plot2[Value21](Value11 + Value32 + HiMark,"TOP");
   Value32 = Value32 - TREND;
   end {15};
  end {14};

  if barnumber >= value3 and value3 > 0 then begin {16}
  plot3(Value11 + Value50 + LoMark,"BOText");
  plot4(Value11 + Value50 + HiMark,"TOPext");
  Value50 = Value50 + TREND;
  end {16};


Value90=Value11+Value50+LoMark;
Value91=Value11+Value40+HiMark;

  if CheckAlert then begin {17}
  if close >= plot4 or close <= plot3
  then Alert = true;
  end {17};

{print("TRLpar REG 051497 - INDICATOR",date:8:0);
print(" Close",close:8:0," LoMark",LoMark:8:2," Extent",extent:8:0,"
HiMark",HiMark:8:2);
print(" Value3",Value3:8:0," Value4",Value4:8:0," Value90",Value90:8:2,"
Value91",Value91:8:2);
print(" Value30",Value30:8:0," Value31",Value31:8:0,"
Value40",Value40:8:2," BarNumber",Barnumber:8:0);
print(" TrendMax",TrendMax:8:0," Value60",Value60:8:0,"
Value61",Value61:8:0," Value50",Value50:8:2);
print(" Trend",Trend:8:2," Value11",Value11:8:0);
print(" P1Array[0]",P1Array[0]:8:2," HiDiff[0]",HiDiff[0]:8:2,"
LoDiff[0]",LoDiff[0]:8:2);
Print("",c:8:2);}


end {3};

end {1};


*************** Function *************

input : BarsBack(numericsimple);
var   : x(0);

if currentbar > 1 then begin
 value1 = DateToJulian(LastCalcDate);
 for x = 0 to BarsBack begin
 value2 = JulianToDate(value1);
 value3 = DayOfWeek(value2);
 if value3 = 0 or value3 = 6 then x = x - 1;
  value1 = value1 - 1;
 end;
 DFrmLstB = value2;
end;

{Instead of entering an offset date for the Anchor input simple type in
the function name with the offset; like so...
  INPUTS : Anchor(DFrmLstB(14)),...;}


*************** Function *************

LastCalcDate = JulianToDate(LastCalcJDate)

vertical line between time-intervals on tick-charts

Origin: omega-list
Written by: Greg
Date found: 14 oct 97
{Thanks to Mark (and Rick) for finding a way to show time on tick charts.

Since I sometimes use paintbars to show other things, I adapted the
original code to draw a vertical line every N minutes instead of
painting bars. The code is attached.

This also works on 1-tick bars. 

You can still use the paintbar strategy by setting the color input to
zero.

/Greg}


input:rotate(5), color(tool_darkgray);

var:go(0),new(0);

if d>d[1]or currentbar=1 then begin
  if go=0 then go=1 else go=0;
  new=TimeToMinutes(Sess1StartTime)+rotate;
end;

if t <> t[1] then 
if TimeToMinutes(t)>new then begin
  if go=0 then go=1 else go=0;
  new=new+rotate;
end;

if go=1 then begin
  if color = 0 then begin
    plot1(h,"time");
    plot2(l,"rotate");
  end else if date = LastCalcDate then begin
    var: handl(0);
    handl = TL_New(date,time,h+1,date,time,l);
    TL_SetExtRight(handl,true);
    TL_SetExtLeft(handl,true);
    TL_SetColor(handl,color);
    go = 0;
  end;
end;

function to return ticks in given # minutes

Origin: omega-list
Written by: James Murphy
Date found: 12 oct 97
{<SNIP>. I prefer tick charts but at times you
need a time reference. I have a simple user function that I use to
return the amount of tick bars there are in a given amount of minutes.

>>>user function "BarsBack"}


input: Length(numericsimple);
vars: Counter1(0);

for counter1 = 0 to MaxBarsBack - 1 begin
       if TimeToMinutes(time) - TimeToMinutes(time[Counter1]) > Length then
begin
              BarsBack = Counter1 - 1;      
              Counter1= MaxBarsBack;
       end;
end;

{If you had a 5 tick chart but wanted to know the highest high for the
last 10 minutes you would use:}


highest(high,BarsBack(10))

{You might want to modify this and change the Maxbarsback to an arbitrary
value.}

Greg Woods Andrews Pitchforks

Origin: omega-list
Written by: Greg Wood
Date found: 24 oct 97
{ ======================================
This is my implementation of some aspects of Andrews Pitchforks. You are
welcome to use this code freely.  You may redistribute it provided you
include this comment block, plus a description of any changes you make.

If you extend it, or adapt it to other uses, I'd appreciate a look at what
you've done.  Thanks.

     Gregory Wood
     SwissFranc@worldnet.att.net
  
12/18/96 v1.0 - Initial distribution
01/08/96 v1.1 - Added median lines
01/15/96 v1.2 - Added TL_Thick, user-customizable colors (see "SET COLORS
HERE")
01/16/96 v1.3 - Removed projections to make room for up to 7 pitchforks
========================================}



SETUP

Set Plot1 and Plot2 to be large points.
Note that the trendlines use the default trendline settings 

USAGE

Use the text tool to label swing high/lows with "A", "B" and "C", then
refresh the indicator (clicking "Status" twice causes the indicator to
recalculate).  Be sure to put the label above the bar's high for a swing
high, and below the low for a swing low.  

You can display other groups of points by using labels "Ax", "Bx" and "Cx",
where 'x' is 1, 2, or 3, e.g. "A3", "B3", "C3".

Note that you can use the pointer tool to move the points anytime. Then to
view the new Pitchfork, refresh the indicator.

Use the Proj values to place a dot at a time expansion.  Try values like
.618, 1.0, 1.618 etc.  Then use Diff to control how near the dot needs to
be to the close for it to be seen. (This keeps the chart from shrinking.)

Use Median to add median lines.

Set MyColor (below) to be the colors for each Pitchfork
}


input{proj1(0), proj2(0), proj3(0), proj4(0), diff(10), } Median(false),
TL_Thick(1);

if currentbar = 1 then begin { initialize control arrays }
   array:abc[3]("");  { The basic point labels }
      abc[0] = "A";
      abc[1] = "B";
      abc[2] = "C";
   array:nums[7]("");  { The way to distinguish one series of points from
another, A-B-C, A1-B1-C1, etc }

      nums[0] = "";
      nums[1] = "1";
      nums[2] = "2";
      nums[3] = "3";
      nums[4] = "4";
      nums[5] = "5";
      nums[6] = "6";
      var: inums(7);
{   array: proj[5](0);  /* fibonacci extensions along a level line - "0"
means "unused" */
      proj[0] = proj1;
      proj[1] = proj2;
      proj[2] = proj3;
      proj[3] = proj4;
      var: iproj(4); 
}

   array: MyColor[7](0);
      MyColor[0] = tool_red;        { <=========== SET COLORS HERE }
       MyColor[1] = tool_blue;
       MyColor[2] = tool_yellow;
       MyColor[3] = tool_cyan;
       MyColor[4] = tool_green;
       MyColor[5] = tool_white;
       MyColor[6] = tool_darkyellow;
end;

array:dd[3,7](0),tt[3,7](0),vv[3,7](0),bb[3,7](0),hh[3,7](0);
array:fb[7,4](0),fv[7,4](0); {fb[nums,proj], fv[nums,proj]}
var: tft(0), fdd(0), fvv(0), ptt(0), pdd(0), pvv(0), fbb(0), pbb(0), pvv2(0);
var: ii(0), jj(0), mm(0);
var: handl(0), handlA(0), handlB(0), handlC(0), handlB1(0), handlC1(0),
handlB2(0), handlC2(0);
var: ss("");
var: y1(0), y2(0);

if currentbar = 1 then begin { examine all the text strings and save some
info about the ones we recognize }

   handl = text_getfirst(2);
   while handl > 0 begin
      ss = text_getstring(handl);
      for ii = 0 to inums - 1 begin
         for jj = 0 to 2 begin { look for well-formed strings }
            if ss = abc[jj] + nums[ii] then begin { save the item's date,
time, value and handle }

               tt[jj,ii] = text_gettime(handl);
               dd[jj,ii] = text_getdate(handl);
               vv[jj,ii] = text_getvalue(handl);
               hh[jj,ii] = handl;
            end;
         end;
      end;
      handl = text_getnext(handl,2); { IMPORTANT -- infinite loop if this
is missing!  }

   end;
end;

for ii = 0 to inums - 1 begin { check each series... }
   for jj = 0 to 2 begin { check each point }
      if time = tt[jj,ii] and date = dd[jj,ii] then begin { we've found a
selected point }

         bb[jj,ii] = currentbar{ remember where we found it }
         if vv[jj,ii] > c then begin { move the label above the bar and
center it }

            vv[jj,ii] = h;

Text_SetLocation(hh[jj,ii],text_GetDate(hh[jj,ii]),text_GetTime(hh[jj,ii]),h);
            Text_SetStyle(hh[jj,ii],2,1);
         end else begin { move the label below the bar and center it }
            vv[jj,ii] = l;

Text_SetLocation(hh[jj,ii],text_GetDate(hh[jj,ii]),text_GetTime(hh[jj,ii]),l);
            Text_SetStyle(hh[jj,ii],2,0);
         end;
         plot1(vv[jj,ii],"Selection"); { show the user which point we used
for the calculations }

         if jj = 2 then begin { we're at the third point, generally the Cx }
              handl = TL_New(dd[0,ii],tt[0,ii],vv[0,ii],dd[1,ii],tt[1,ii],vv[1,ii]);
            TL_SetExtLeft(handl,false);
            TL_SetExtRight(handl,false);
              TL_SetColor(handl,MyColor[ii]);
              handl = TL_New(dd[0,ii],tt[0,ii],vv[0,ii],dd[2,ii],tt[2,ii],vv[2,ii]);
            TL_SetExtLeft(handl,false);
            TL_SetExtRight(handl,false);
              TL_SetColor(handl,MyColor[ii]);

            fbb = bb[1,ii] / 2 + bb[2,ii] / 2;
            fvv = vv[1,ii] / 2 + vv[2,ii] / 2;
            pvv = TLValue(vv[0,ii],bb[0,ii],fvv,fbb,currentbar);
            handlA = TL_New(dd[0,ii],tt[0,ii],vv[0,ii],date,time,pvv);
            TL_SetExtRight(handlA,true);
              TL_SetColor(handlA,MyColor[ii]);
              TL_SetSize(handlA, TL_Thick);

            { show the related trident channel }
            pvv =
TLValue(vv[1,ii],bb[1,ii],fvv+vv[1,ii]-vv[0,ii],fbb+bb[1,ii]-bb[0,ii],curren
tbar);
            handlB = TL_New(dd[1,ii],tt[1,ii],vv[1,ii],date,time,pvv);
            TL_SetExtRight(handlB,true);
              TL_SetColor(handlB, MyColor[ii]);
              TL_SetSize(handlB, TL_Thick);
              if Median then begin { save for later }
                     handlB1 = TL_New(dd[1,ii],tt[1,ii],vv[1,ii],date,time,pvv);
                   TL_SetExtRight(handlB1,true);
                     TL_SetColor(handlB1, MyColor[ii]);
                     TL_SetSize(handlB1, TL_Thick);
                     handlB2 = TL_New(dd[1,ii],tt[1,ii],vv[1,ii],date,time,pvv);
                   TL_SetExtRight(handlB2,true);
                     TL_SetColor(handlB2, MyColor[ii]);
                     TL_SetSize(handlB2, TL_Thick);
              end;
            pvv =
TLValue(vv[0,ii]-(fvv-vv[2,ii]),bb[0,ii]+(bb[2,ii]-fbb),vv[2,ii],bb[2,ii],bb
[1,ii]);
            handlC = TL_New(dd[1,ii],tt[1,ii],pvv,date,time,vv[2,ii]);
            TL_SetExtRight(handlC,true);
              TL_SetColor(handlC, MyColor[ii]);
              TL_SetSize(handlC, TL_Thick);
              if Median then begin { save for later }
                     handlC1 = TL_New(dd[1,ii],tt[1,ii],pvv,date,time,vv[2,ii]);
                   TL_SetExtRight(handlC1,true);
                     TL_SetColor(handlC1, MyColor[ii]);
                     TL_SetSize(handlC1, TL_Thick);
                     handlC2 = TL_New(dd[1,ii],tt[1,ii],pvv,date,time,vv[2,ii]);
                   TL_SetExtRight(handlC2,true);
                     TL_SetColor(handlC2, MyColor[ii]);
                     TL_SetSize(handlC2, TL_Thick);
              end;

              if Median then begin { sorry these are hard-coded... you know what they
say about quick + dirty! }

                     { show the median lines }
                     y1 = TL_GetValue(handlB, dd[1,ii], tt[1,ii]);
                     y2 = TL_GetValue(handlA, dd[1,ii], tt[1,ii]);
                     TL_SetBegin(handlB1, dd[1,ii], tt[1,ii], (y1 + y2) / 2);
                     y1 = TL_GetValue(handlB, dd[2,ii], tt[2,ii]);
                     y2 = TL_GetValue(handlA, dd[2,ii], tt[2,ii]);
                     TL_SetEnd(handlB1, dd[2,ii], tt[2,ii], (y1 + y2) / 2);

                     y1 = TL_GetValue(handlB, dd[1,ii], tt[1,ii]);
                     y2 = TL_GetValue(handlA, dd[1,ii], tt[1,ii]);
                     TL_SetBegin(handlB2, dd[1,ii], tt[1,ii], y1 + y1- (y1 + y2) / 2);
                     y1 = TL_GetValue(handlB, dd[2,ii], tt[2,ii]);
                     y2 = TL_GetValue(handlA, dd[2,ii], tt[2,ii]);
                     TL_SetEnd(handlB2, dd[2,ii], tt[2,ii], y1 + y1 - (y1 + y2) / 2);

                     y1 = TL_GetValue(handlC, dd[1,ii], tt[1,ii]);
                     y2 = TL_GetValue(handlA, dd[1,ii], tt[1,ii]);
                     TL_SetBegin(handlC1, dd[1,ii], tt[1,ii], (y1 + y2) / 2);
                     y1 = TL_GetValue(handlC, dd[2,ii], tt[2,ii]);
                     y2 = TL_GetValue(handlA, dd[2,ii], tt[2,ii]);
                     TL_SetEnd(handlC1, dd[2,ii], tt[2,ii], (y1 + y2) / 2);

                     y1 = TL_GetValue(handlC, dd[1,ii], tt[1,ii]);
                     y2 = TL_GetValue(handlA, dd[1,ii], tt[1,ii]);
                     TL_SetBegin(handlC2, dd[1,ii], tt[1,ii], y1 + y1 - (y1 + y2) / 2);
                     y1 = TL_GetValue(handlC, dd[2,ii], tt[2,ii]);
                     y2 = TL_GetValue(handlA, dd[2,ii], tt[2,ii]);
                     TL_SetEnd(handlC2, dd[2,ii], tt[2,ii], y1 + y1 - (y1 + y2) / 2);
              end;

{            for mm = 0 to iproj-1 begin { for each projection }
               if proj[mm] > 0 then begin { calculate the fibonacci
price/time points }
                  fb[ii,mm] = IntPortion(fbb + (fbb - bb[0,ii]) * proj[mm]);
                  fv[ii,mm] = TLValue(vv[0,ii],bb[0,ii],fvv,fbb,fb[ii,mm]);
               end;
            end;
}

         end;
      end;
   end;
end;   

{ find out if this bar needs to show a time/price point }
{
for ii = 0 to inums - 1 begin
   for mm = 0 to iproj - 1 begin
      if fb[ii,mm] = currentbar then begin
         if c + diff > fv[ii,mm] and c - diff < fv[ii,mm] then
            plot2(fv[ii,mm],"Projection");
      end;
   end;
end;
}

Triangle pattern indicator

Origin: omega-list
Written by: Walt Downs
Date found: 1 dec 97
{**************************************************************
Triangle Function code starts Here....Function Name: Triangle
**************************************************************}


input:
OccurH1(numericsimple),OccurH2(numericsimple),OccurL1(numericsimple),
 OccurL2(numericsimple),PriceH1(numericseries),PriceH2(numericseries),
 PriceL1(numericseries),PriceL2(numericseries),StrenH(numericsimple),
 StrenL(numericsimple),Len(numericsimple);

value1 = SwingHighBar(OccurH1,PriceH1,StrenH,Len);
value2 = SwingHighBar(OccurH2,PriceH2,StrenH,Len);
value3 = SwingLowBar(OccurL1,PriceL1,StrenL,Len);
value4 = SwingLowBar(OccurL2,PriceL2,StrenL,Len);


Condition1 = high of value2 bars ago > high of value1 bars ago;
Condition2 =  low of value4 bars ago < low of value3 bars ago;
Condition3 = HighestBar(H,Len) = value2;
Condition4 = LowestBar(low,Len) = value4;

if 
Condition1 and
Condition2 and
Condition3 and
Condition4
then Triangle = true
else Triangle = false;

********************************************************************
Triangle Indicator Code starts here........Indicator Name: Triangle
********************************************************************

input:
OccurH1(1),OccurH2(2),OccurL1(1),OccurL2(2),PriceH1(high),PriceH2(high),PriceL1(low),PriceL2(low),
StrenH(1),StrenL(1),Len(10);

if
Triangle(OccurH1,OccurH2,OccurL1,OccurL2,PriceH1,PriceH2,PriceL1,PriceL2,StrenH,StrenL,Len)
true then plot1(10,"TriFinder")
else plot1(0,"TriFinder");

if
Triangle(OccurH1,OccurH2,OccurL1,OccurL2,PriceH1,PriceH2,PriceL1,PriceL2,StrenH,StrenL,Len)
true then Alert = true;

{Indicator calculates triangles based on SwingHighs 
and lows of a 10 day range, and with a swing strength of "1". Larger
triangles can be calculated by increasing the
strength and/or HighestBar/LowestBar range settings. The indicator plots
a simple "spike" graph, alerting the trader to the presence of a
triangle. The trader can then apply logical
trendlines to establish break-out points}

coding Stops in EL

Origin: omega-list
Written by: Craig Nelson
Date found: 4 dec 97
{Well, I received a few e-mails from the list regarding my problems coding
exits(stops and limits) in EL, and getting the trade to exit correctly.
After about 2 weeks of playing(struggling) around with ALL the suggestions,
I came up with the following that worked perfectly.  Below is an example of
what I'm using for the trade exits.}


vars: Entry_Price(0),Profit_Price(980.00),Loss_Price(910.00);  {Example Only}
inputs: whatever_you_want(0);

if Some_Condition = true   {Put whatever you want here for your entry
criteria}


then begin
buy 1 Shares This Bar On close;
Entry_Price = close;
end;

if BarsSinceEntry(0) >= 0
then ExitLong At Profit_Price Limit;   {Profit Target Price}

if BarsSinceEntry(0) >= 0
then ExitLong At Loss_Price stop;   {Stop Loss Price}

if BarsSinceEntry = 6
then ExitLong On close;

{The reverse of the above works for short positions.  It seems that
"BarsSinceEntry" is a reliable variable to use in getting trade exits to
work the way you want them to.

Once again, I thank all of you who helped with this.  We should put this
e-mail in some archive(along with the rest) so that others won't have to
reinvent the wheel  Iike I did.

Best Regards,
Craig}

   

 
 
 

 


Home
| About Us | Help | Contact
Site content intended for Educational purposes

Copyright 2008 markbrown.com

Non-US Citizen money management programs available!

 

The intuitive mind is a sacred gift and the rational mind is a faithful servant. We have created a society that honors the servant and has forgotten the gift. - Albert Einstein