[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: EasyLanguage to C# translator



PureBytes Links

Trading Reference Links

On Jun 25, 2007, at 5:43 PM, Chris Evans wrote:
Why do you use more than one
platform (i.e. Ninja)?

I think I stumbled upon the answer in the course of developing the translator. A picture is worth a thousand words so allow me to illustrate. Compare a simple piece of EL code below [1] with its C# equivalent [2].

EL code is precise and to the point. No fluff, nothing extra, nothing but net. EL automatically initializes things on the first bar keeps values from bar to bar, etc. These are things that you have to take care of manually in C# (Initialize, OnFirstBar).

The boilerplate code in this simple example is quite bearable but once a strategy becomes large, original intent and meaning can get lost in translation (pun intended). Take a look at http://tinyurl.com/ 234zat if you don't believe me.

There are issues with TS and EL that are solved by C# and NinjaTrader (faster? easier automation, more powerful?) but C# is not the easiest language to use for trading. It may sound self-serving but maybe a good solution is to use both platforms simultaneously. Think of quickly prototyping in EL and then deploying and automating your translated strategies on NinjaTrader.

	Thanks, Joel

---

[1] EL code

input: price(100);

buy 100 shares next bar at price limit;

[2] C# equivalent

public class MyStrategy : Strategy
{
    #region Variables
    private bool[] init_once;
    private int price = 100;
    #endregion

    protected void OnFirstBar(int bip)
    {

    }

    protected override void Initialize()
    {
        init_once = new bool[BarsArray.length];
        foreach (bool elem in init_once)
            elem = false;
    }

    protected override void OnBarUpdate()
    {
        int bip = BarsInProgress;
        if (!init_once[bip])
        {
            OnFirstBar(bip);
            init_once[bip] = true;
        }
        EnterLongLimit(100, price);
    }

    #region Properties

    [Description("")]
    [Category("Parameters")]
    public int Price
    {
        get
        {
            return price;;
        }
        set(int value)
        {
            price = value;;
        }
    }

    #endregion
}


--
http://wagerlabs.com/