Tuesday May 16, 2006

Primary support for Buy/Sell Signals in BlogTrader Platform

The primary support for Buy/Sell signals has been implemented in BlogTrader Platform, inculding SignalChart, SignalIndictor etc.The signal indicators will be put in a separate module: "BlogTrader Platform Modules Basic Signal"

Below is a screenshot of signals generated by MACD's slow line cross fast line. The blue arrows indicate the signals:

custom ndicator

The sample code:

public class MACDSignal extends AbstractSignalIndicator {
    
    Opt periodFast   = new DefaultOpt("Period EMA Fast", 12.0);
    Opt periodSlow   = new DefaultOpt("Period EMA Slow", 26.0);
    Opt periodSignal = new DefaultOpt("Period Signal",    9.0);
    
    Var fast = new DefaultVar();
    Var slow = new DefaultVar();

    {
        _sname = "MACD Signal";
        _lname = "Moving Average Convergence/Divergence Signal";
    }
    
    void computeCont(int begIdx) {
        for (int idx = begIdx; idx < _dataSize; idx++) {

            fast.set(idx, macd(idx, C, periodSlow, periodFast));
            slow.set(idx, ema(idx, fast, periodSignal));
 
            if (crossOver(idx, fast, slow)) {
                signal(idx, Sign.EnterLong);
            }
            
            if (crossUnder(idx, fast, slow)) {
                signal(idx, Sign.ExitLong);
            }

        }
    }
}

Comments:

Post a Comment:
  • HTML Syntax: Allowed