What is a main idea for such stuff sounds like wheels reopening ? The key is a magic word Java ! This wrapper give you open interface for adding your own indicators in form of java classes.
How to use it:
1. Copy (paste) quotes to left window from Clipboard. The form is standard:
Date Open High Low Close Volume
Data are space separated, or comma separated or tab separated. So, open your quota, select data and copy to Clipboard. Click mouse in left applet's window and print Ctrl-V (or Shift-Ins) for paste.
2. Choose indicator (one or more)
3. Click Calc button
Here are some quotes for Russian stocks. Why Russia ? I think reading text above you can guess that English is not my native language ...
How to write your own class ? O, it is very easy, at list for the author, I hope ... See the PARAM tag for this applet:
PARAM name=SIGNALS value="Momentum,Trb,Rw"
This line contains names of visible indicators and each indicator is just a Java class. I am using so called java reflection stuff for loading classes in runtime and running methods. Rest is clear. Each class just implements some standard interface. It is here:
public interface Signal
{
// constants for signals
public static final int BUY=1;
public static final int SELL=-1;
public static final int OUT=0;
// receive quotes from wrapper
// class Records coontains the list
// (vector) of quotes
public void initSignal(Records r);
// return String name for indicators list
public String getName();
// return String for comments about indicator public
String getInfo();
// calculate signals
public void getSignal();
}
// that is all !
Here is a sample for Momentum indicator:
import Records;
public class Momentum implements Signal
{
Records recs;
// init
// just save reference to records
// in internal variable
public void initSignal(Records r0)
{ recs=r0; }
// name for indiacators list
public String getName()
{ return "Simple momentum"; }
// comments for wrapper (button Info)
public String getInfo()
{ return "Comparing close prices for today and yesterday"; }
// main method
// Records interface:
// int getRecords() - records count
// Record getRecord(int number)
// return one record. Numbers are from 0
// void setSignal(int number, int signal)
// set signal for numbered record
// Record interface:
// float O()
// float H()
// float L()
// float V()
// float C()
// Open,High,Low,Close and Volume
public void getSignal()
{ int i;
Record r2,r1,r;
for (i=2; i<recs.getRecords(); i++)
{ r=recs.getRecord(i);
r1=recs.getRecord(i-1);
r2=recs.getRecord(i-2);
if (r1.C()>r2.C() && r.C()<r1.C())
recs.setSignal(i-1,Signal.SELL);
if (r1.C()<r2.C() && r.C()>r1.C())
recs.setSignal(i-1,Signal.BUY);
}
}
}
So, you can just add name of your indicator to param line.
Comments, suggestions: dnamiot@usa.net