Building a TradeEngine, need syntax advice!

Discussion in 'Automated Trading' started by januson, Jul 21, 2010.

  1. januson

    januson

    Hi there...

    I'm in the middle of designing a piece of event-driven trading software and to keep a nice intuitive feel and usability, I have decided to listen to the voice of people.

    Feel free to help and NO it's not a new comedy of TickZoom and NO it's not open source at the moment and NO I'm not going to sell it. I am only myself and programming is only done in my spare time which equals to close to no-time.

    Anyway....
    Here we go...

    As in many other trading platforms I've created a Strategy-class.

    Here we are looking at some methods in the strategy class:

    public override void StartUp()
    {
    // in this startup we need to define which indicators that should be available when the strategy is running.

    //option 1)
    var sma21 = Indicator.Trend.SMA.Input(Close).WithLength(21);
    var macd = Indicator.Trend.MACD.Input(Close).WithFastLength(26).WithSlowLength(21).SignalLine(9);

    var trix = Indicator.Momentum.TRIX.Input(Close).WithLength(21);

    //option 2)
    var sma9 = new Indicators.Trend.SMA();
    sma9.Input(Close);
    sma9.Length(9);

    //same approach for MACD
    }


    protected override void OnBarUpdated(Common.Entities.IBarData barData)
    {
    base.OnBarUpdated(barData);
    }
    protected override void OnTick(Common.Entities.ITickData tickData)
    {
    System.Diagnostics.Trace.WriteLine("Tick recieved");

    }


    Or could we come up with something else?
     
  2. OP, have you looked into the open-source products that are out there? They are very good - unless you need something more customizable I'd strongly suggest that you not try to reinvent the wheel.
     
  3. If the fruit of your labor is going to only benefit yourself, what causes you to believe that the opinion of the public is useful? The feedback loop is incomplete.

    If you're just looking for coding style advice, always do what you find easiest and most natural. Don't overthink in advance.
     
  4. januson

    januson

    ohhh.. nothing like it outthere :D and never under estimate the power of doing the things by yourself. Many of the open sources have a nasty code smell that would be impossible for me to ignore.
     
  5. rosy2

    rosy2

    whats this all about


    protected override void OnBarUpdated(Common.Entities.IBarData barData)
    {
    base.OnBarUpdated(barData);
    }
     
  6. januson

    januson

    What? 2 things here...

    The first: Exactly that should be the purpose of a forum, help other and they will help you back. I just asked for input, the true power is hidden in helping and you will receive it ten times. But somehow you have forgotten why you are here, do you know it your self?

    The second: It's not coding style, you have misinterpreted the question. But again... you have misunderstood the whole posting... it is not me, it was an open question, and not what I think is natural.
     
  7. januson

    januson

    The purpose is to override OnBarUpdated with some custom code.. It could be reading some indicator value defined in the StartUp, that of course is automatically updated.. So for instance:

    protected override void OnBarUpdated(Common.Entities.IBarData barData)
    {
    if(barData.Open.CrossAbove(sma9.Current))
    BuyOnNextBar();
    }

    -- or something like that.. syntax that still needs thinking.. :cool:

    I should mention that OnBarUpdated is triggered by en event in the base class Strategy, the event is raised each time a tick/ trade is processed/ aggregated into another interval.

    There will also be an event for OnTickReceived, that we could do something with.
     
  8. promagma

    promagma

    I started with option #1 but ended up doing it vertically because sometimes I had many parameters and horizontal became messy.

    For example I set up a strategy:

    Strategy1 thisStrategy = new Strategy1();
    thisStrategy.stock = stock;
    thisStrategy.size = 50000.0;
    thisStrategy.useStop = 500.0;
    thisStrategy.buffer1 = 1.5;
    thisStrategy.buffer2 = 2.4;
    thisStrategy.isPanicOnLoss = true;
    thisStrategy.isPostETonProfit = true;
    thisStrategy.activate();

    Yeah I am a programmer who like to call everything a "this" :)
     
  9. I did not mean my comment in a "why should we bother to help you" way, I meant it in a "how are we supposed to offer advice if we can't see the whole thing and guide the process" kind of way.

    Also, syntax advice falls exactly into coding style. I guess I did misinterpret your question "Or could we come up with something else?" The answer, of course, is "yes, we could".
     
  10. well, so far everyone responding to you has apparently "misunderstood you" according to your judgment. Maybe it was you who communicated in confusing ways. Have you ever thought about it?

    So far its also not clear to me what you try to do other than what is already out there in terms of open source or 3rd party products. Look at RightEdge and you see what I mean. You can build anything on top of their code.

     
    #10     Jul 21, 2010