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<Float> ma1 = new Var("ma1", Chart.LINE);
    Var<Float> ma2 = new Var("ma2", Chart.LINE);
    Var<Float> 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.

  • Posted: 2006-04-02 09:00 (Updated: 2009-12-30 11:49)
  • Author: dcaoyuan
  • Categories: AIOTrade

Comments

1. im-james -- 2006-04-04 09:00

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.

2. rororo -- 2006-04-04 09:00

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

3. Gerry Power -- 2006-04-06 09:00

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

4. dcaoyuan -- 2006-04-06 09:00

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

5. markpmc -- 2006-04-09 09:00

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

6. dcaoyuan -- 2006-04-10 09:00

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.

7. Mark -- 2006-04-10 09:00

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

8. Gerry Power -- 2006-04-11 09:00

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

9. Gert weise -- 2006-06-02 09:00

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.