Sunday Apr 02, 2006

Programming language for custom indicator?

I tried to write the MA indicator in javascript, here's what it looks:

this._sname = "MA";
this._lname = "Moving Average";
this._overlapping = true;
    
var period1 = new P("Period 1", 5.0 );
var period2 = new P("Period 2", 10.0);
var period3 = new P("Period 3", 20.0);
    
var ma1 = new Var("ma1", Chart.LINE);
var ma2 = new Var("ma2", Chart.LINE);
var ma3 = new Var("ma3", Chart.LINE);
    
function computeCont(int fromIdx) {
    for (int i = fromIdx; i < this._dataSize; i++) {
            
        ma1.set(i, ma(i, C, period1.value()));
        ma2.set(i, ma(i, C, period2.value()));
        ma3.set(i, ma(i, C, period3.value()));
    }
}

And the Java version:

public class MAIndicator extends AbstractContIndicator {
    {   
        _sname = "MA";
        _lname = "Moving Average";
        _overlapping = true;
    }
    
    P period1 = new P("Period 1", 5.0 );
    P period2 = new P("Period 2", 10.0);
    P period3 = new P("Period 3", 20.0);
    
    Var ma1 = new Var("ma1", Chart.LINE);
    Var ma2 = new Var("ma2", Chart.LINE);
    Var ma3 = new Var("ma3", Chart.LINE);
    
    void computeCont(int fromIdx) {
        for (int i = fromIdx; i < _dataSize; i++) {
            
            ma1.set(i, ma(i, C, period1.value()));
            ma2.set(i, ma(i, C, period2.value()));
            ma3.set(i, ma(i, C, period3.value()));
        }
    }
    
}

There is rare difference between those two versions. So, why should we extend this platform via script language if we've built a helpful framework?

Java also has better support via IDE. It's easier to implement code completing, debug etc in java than script language.

For the learning curve, the basic syntax of Java is almost same as javascript. If you don't want to write UI, Network features from the scratch, Java is same easier as javascript.

This comes out my decision: I'll implement the feature of custom indicator directly in Java via wizard and templet. It will be integrated with most of the features in NetBeans IDE for developing module.

And the packed size of binary package will grow to 15M size. But you get a BlogTrader Platform Developer Edition.

Comments:

As a Java developer, I don't need Javascript and I would prefer to read/explore the Java code in my IDE.

As for the code size, it really doesn't matter. Broadband is everywhere these days.

Posted by im-james on April 05, 2006 at 12:41 AM PDT #

You are integrating the great features into BlogTrader Platform, I'm looking forward to it competing with Wealth-Lab which is extended via Pascal.

Posted by rororo on April 05, 2006 at 12:41 AM PDT #

Java works by me as a Java programmer, but there is one Java Scripting Framework that allows for Java scripting, as well as JavaScript, Python, JRuby, Groovy plus others.

Jakarta's Bean Scripting Framework: http://jakarta.apache.org/bsf

I have not used it, but here is an article from JavaWorld: http://www.javaworld.com/javaworld/jw-03-2000/jw-03-beans.html

Thanks for the great platform! Very excited about the future developments!
Gerry

Posted by Gerry Power on April 07, 2006 at 12:42 AM PDT #

If there are good edit modules for those scriptings, I may add support for them.

Posted by dcaoyuan on April 07, 2006 at 12:43 AM PDT #

Think about the users!

Not every user can fire up netbeans and write a custom indicator. The app should let a user write a script to generate a custom indicator w/o recompiling the app.

markpmc

Posted by markpmc on April 10, 2006 at 12:43 AM PDT #

The IDE features will be integrated into BlogTrader Platform, that is, users need not to operate a IDE, they just:
1. click a button, then input the custom indicator's name, parameters etc, a java template will be shown up for their further editing.
2. when they edit the java file, they will get code auto-completing, suggesting of available fuctions(methods), variables etc.
3. after finish editing, click to install it on platform. that's all.
4. they can also fire debug, if they want to.

Posted by dcaoyuan on April 11, 2006 at 12:44 AM PDT #

Thanks for the reply. I guess that makes the 'scripting' usuable for regular users. I assume this means that blogtrader will require a java sdk install instead of a jvm install to use the scripting feature.

Mark

Posted by Mark on April 11, 2006 at 12:45 AM PDT #

Here is another great article on JSR-223: Scripting for the Java Platform

http://today.java.net/pub/a/today/2006/04/11/scripting-for-java-platform.html

While it is not due out until Java 6, the Interface might help in your design.

Cheers,
Gerry

Posted by Gerry Power on April 12, 2006 at 12:46 AM PDT #

I'm just in the process of researching, whether your system can be applied to forex (foreign currency exchange). As data source I intend to use Forexite, a Russian site with free signals of various formats for ca. 14 different currency pairs.

Things which might slow me down: poor knowledge of Java; my own data is on a remote server under MySQL. It got there via PHP and is currently evaluated for my time-of-day trading system through PHP.

If you are interested in access to the Forexite data server (called "Quoteroom"), let me know and I'll send you translations (from Russian to English) of some of their pages. They also offer free historical data under http://www.forexite.com/free_forex_quotes/forex_history_arhiv.html all the way back to 2001.

Posted by Gert weise on June 02, 2006 at 05:45 PM PDT #

Post a Comment:
Comments are closed for this entry.