Possible array question in C++

Discussion in 'Programming' started by raymam1, Oct 4, 2011.

  1. raymam1


    Hi Everyone,

    This is my first post here, and I am a very green C++ programmer, so some insight on how to visualize my trading system would be very helpful.

    I created a strategy using Market Delta's proprietary language, RTL, and have decided to re-code in C++ and to hopefully automate the execution.

    Instead of using a time-based periodicity, I am using a price range periodicity - like 5 ES ticks for example.

    My idea is that I would need to use arrays to store the current and each previous 5 tick range in order to perform the necessary calculations required for my signals...Is this an accurate assessment, or do I need to consider another alternative?

    And for those who don't understand what I mean by 5 tick range, here is the following:

    Ex) Price trades from 1088-1085, but instead of monitoring the price changes and trades on a 5 min period, I would monitor the trades that occur at each price level. Once a 5 tick range has been exceeded either higher or lower from the previous last price, a new 5 tick range would be created. However, I would need to store the trades, and prices that occur within those ranges, then monitor the additional prices and trades that occur in subsequent 5-tick ranges until my signal criteria are met.

    Thanks for your help!
    dratsum likes this.
  2. byteme


    Array or linked list of Range Bar structs/objects....

    Depends on how performant, memory efficient, lossless/lossfull you need the data structure arrangement to be.

    The Range Bar struct/object encapsulates all the information you need to know about that specific bar e.g open, close, volume at price....depends on your specific analysis requirements.

    As each tick comes in you decide whether to update the current Range Bar or create a new one (or retrieve from an object pool) and add it to the tail of the list.

    Tools like Esper are good at this sort of thing.

    If you're new, suggest you first learn about Structs and then Classes and object oriented programming. That should occupy you for a couple of years...

    Running values for signal generation e.g. indicator values should be stored elsewhere; simplistically in an a array parallel to that of your array/list of Range Bars.

    dratsum likes this.
  3. raymam1


    Thanks byteme,

    So you're basically saying my task is a very complicated endeavor and for someone who is a novice, it is not something one can complete in a few weeks?

    Anyway, I would need the most efficient and quickest data structures, so I presume arrays would be the correct solution?

    Having said that, I have no idea where to even begin, and I'm very overwhelmed with this. Should I try to find a developed to code this for me?

  4. mickmak


    If I understand the Ex correctly, I think you may be over engineering this.

    What you really are after is VAP - volume at price. So for that a simple array is sufficient _if_ your tick size is the same. If equities, you may want to use a dlink list: because you can have prices in sequence, then a new price that comes in between the previous two (such as, 20.01 as price 1; 20.02 as price two. then you have 20.019). Using an array in such a case means inefficiency.

    Check your market data vendor. They may already provide that information - either on request/response basis or can be subscribed.

    Once you have the VAP structure, what you need is just two pointers pointing to the top and bottom of the range. To observe if any actions occurred outside of that range, you can simply process market data prices.
    dratsum likes this.
  5. In c++, better to use vectors
  6. byteme


    Not that complicated, don't be put off by my comments. I have no idea about your experience and learning aptitude.

    The "correct" solution is dependent on your specific needs which I can only guess at from your initial post. I personally would be very hesitant to use arrays as the only data structure in the solution. You'll receive a wide range of suggestions from other people on ET.

    Before you even get to that though, do you have everything set up to receive market data from a data feed?

    I can't really answer that question for you. Is this a one-off job or will you have more work in the future? Are you interested in being a programmer in the long-term or just want to find a solution to this problem?


    This thread might be relevant for you too:

    dratsum likes this.
  7. You didn't say what you are screening for (signal criteria).
    Therefore the question cannot be answered at this point.
    It might not be necessary to store the data in an array.

    In principle arrays are ok for monitoring the activity in a range.

    Simplistic approach:
    - Define an array that has 10 elements (enough for 2x5 ticks)
    - For every incoming trade: Add the volume to the according array element
    - If range is exceeded reset all array elements to zero

    C++ is overkill for this.
    There are languanges out there that have a less steep learning curve and are doing the same job.
    dratsum likes this.
  8. Eight


    I've done similar tasks in the environs of Ninjatrader, Easy Language, Sierrachart, etc... they have existing wrapper code to help with most of the tasks and I have to refer out to the internet to find out how to code the C++ stuff and it helps to have a subscription to Experts-Exchange...

    Building bars is trivial really, just check every tick, build the current bar and build an array, when a bar is completed move everything over one place and start building the new bar... efficient with regard to learning curve, time to code it, amount of code, absolutely! Efficient with regard to being the fastest operating code, who knows and I didn't care about that at the time(s).. I'm always astounded at how fast code runs after worrying the whole time I'm writing it, about how to not do things every tick unless absolutely necessary and having code that is efficient and all that...
    dratsum likes this.

  9. No comment needed.

    Form speaks for content and state of mind of poster.
    dratsum likes this.
  10. No, you say C++ is overkill.

    Why do you say such crap if you're even not a skilled C++ programmer ?

    I'm fed up with morons talking about stuff they don't know jack shit about.

    #10     Oct 6, 2011