How to Build an Automated Trading System

Discussion in 'Automated Trading' started by greaterreturn, Sep 14, 2008.

Thread Status:
Not open for further replies.
  1. Tums

    Tums

    #21     Sep 15, 2008
  2. Alright, here's my approach and progress.

    First, I'm working on channel traversals. FYI, Jacks definition of channel differs from CW (conventional wisdom).
    His channels operate in virtually all market condidtion including trends.
    You can read at traderuniverse.info The goal here is to automate profiting from back and forth traversals
    across the channels. During trends that means playing both sides of the trend and counter trend retraces.

    Okay, first, the big picture.

    BTW, Jack, I expect corrections or clarification here. I write my understanding as an
    programmer/analyst. If it's unclear or incorrect. Let me know.

    Jack's process for decision making includes 6 steps.

    They are: Housekeeping, Monitoring, Analysis, Decision, Action, and Debriefing

    What Jack calls housekeeping and debriefing are equally as critical as the other four even though he often
    emphasizes MADA the most.

    Anyway, housekeeping refers to making chart annotations and logging your analysis and decisions for later review.
    (done manually if not an ATS).

    Debriefing refers to review after market hours to see what you learned and make notes to review later to add to what you learn.

    The plan is to emulate this entire human process equally and build the ATS to make it capable learning over time similar to a human student.

    He recommends starting with learning price action using channels.

    So now I only focus on channels for right now. After the ATS trades those profitable, it can more on to Volume, Sentiment, the DOM, etc.

    AUTOMATED CHANNELS

    First step: Housekeeping (a.k.a. chart annotations)

    Jack shows how to use three highs/lows to start a channel on a chart. My automated channels do the same.
    There's a few caveats to automating them. They use pivot highs and lows (at them moment--that might change).
    They're based on a combo of bars and price movement. That way it doesn't find highs in flat market conditions.

    Second caveat is that it must remember the slop and intercept of the lines in order to continue to calculate there
    level as the market move forward in time.

    That part all works well. I'll post a chart screenshot tonight.

    Second Step: Monitoring

    To monitor, the software watches very tick to assess it's position relative to the channel lines.
    It has 5 possible positions.
    1. InsideChannel (Inside the channel)
    2. AtLeftLine
    3. AtRightLine
    4. OutsideRight
    5. Confused
    If the position has changed since the last tick, it creates an "event" to trigger Analysis on the new position.

    Third Step: Analysis

    Analysis starts any time monitoring triggers an event to analyze. It then takes the new event and considers the
    previous state to determine if a new state is necesary.

    List of "states" of the market relative to the channel.
    1. InActive (Start state)
    2. LtoR (Completed a Left to Right traversal)
    3. RtoL (Completed a Right to Left traversal)
    4. TLeft (Traversing left)
    5. FTT (Failure to Traverse)
    6. TRight (Traversing right)
    7. Outside (Outside on the right)
    8. Confused (ATS confused which state is correct)

    Example: Monitoring says the event AtRightLine just happenend. So analysis looks and sees that the previous state
    was TRight so it sees that it just finished a traversal to the right and sets the new state to LtoR.

    Anytime analysis changes the state, it triggers a decision on the new state.

    Fouth Step: Decision

    Eventually the decision state will compare the states of multiple analysis and make a complex decision.

    For now, it simply buys/reverse on an LtoR, sells/reverse on a RtoL, and exits when confused or if the trend changes.

    Fifth Step: Debriefing

    You may be wondering what confusion was. Well Jack recommends that a human student only trade situations the student
    understands and feels comfortable with. If the market gets confusing, he says to exit and the reenter when
    you feel comfortable you understand what's happening.

    That's why the states above all have Confused. If an event or state changes happens unexpectedly, the system goes
    to the confused state. Decision can exit the market until not confused.

    What is debriefing? The system logs details about it's confusion each time it happens. The recent even and
    that caused confusion, the tick time, price levels of the trend lines.

    Using that report I can study how it got confused and add additional, housekeeping or monitoring or analysis or
    decisions to solve the issue for the next time.

    I'm amount 80% done with creating the engine to make these state changes and decision. Have some more testing.
    But it looks good so far!

    Sincerely,
    Wayne
     
    #22     Sep 15, 2008
  3. Aurum

    Aurum

    Just to throw out a scenario for you, from what I understand of your posting above:

    The channel is built - an up channel. Price currently resides inside the channel. This would put your position at 1. (inside the channel).

    Price is "below" the LTL, and ticks up. The LTL has still not been reached. No criteria is met for you to enter analysis.

    Price now ticks down. The LTL has not been reached, nor has the RTL been reached. No criteria is met for you to enter analysis.

    Price continues to tick down until the RTL is reached. Criteria is met for you to enter analysis now, and you've missed the FTT.

    Am I missing something from your algorithm? If not, what solution would you consider in order to effectively capture the FTT?

    -Au
     
    #23     Sep 15, 2008
  4. What does LTL stand for? Did you type and mean LTR? (Left to Right)?

    But your question about FTT is good.

    At the moment I have an issue to resolve for the FTT because it ticks down to be AtRightLine and was InsideChannel so it is now LtoR.

    If it then ticks right up, it's in the InsideChannel zone again. Since it comes from the LtoR to inside zone, the analysis says its now in the TLeft state which is traversing left.

    If then it ticks down again the analysis says it's now an FTT.

    But as a human I can see that all happens during one bar.

    Next, guess what? It ticks up again shortly afterwards and now says InsideChannal after an FTT.

    That make the analysis switched to "confused" because it doesn't know what to do with InsideChannel after an FTT.

    My thinking at the moment is to set a minimum level that an LTL has to reach before it's LTL

    Jacks says it's usually about half way across the channel before it gives up.

    That looks right in the two instances on my test chart. So my thought is to add another position. I like your term "zone" better.

    So i add another zone call CenterChannel which ranges from 40% to 60% of the channel range.

    That way, an FTT has to go from the LtoR state (in the AtRightLine zone) all the way to the center before it can qualify as an FTT if it doesn't make it to the AtLeftLine zone.

    Does that answer your question?

    Wayne
     
    #24     Sep 15, 2008
  5. Tums

    Tums

    #25     Sep 15, 2008
  6. Aurum

    Aurum

    Thanks Wayne,

    LTL = Left Trend Line

    Yes, I think it does answer my question. Interesting solution, as I didn't remember seeing Jack post about price getting back to the half way point. Intuitively it makes sense.

    -Au
     
    #26     Sep 15, 2008
  7. One more tidbit about that.

    I had an issue on the opposite zone whereby sometime it would tick up and down between the AtLeftLine zone and the InsideChannel zone and so the states went from:

    I log changes like this with event on the left and new state on the right.

    AtRightLine -> LtoR
    InsideChannel -> TLeft
    AtLeftLine -> RtoL
    InsideChannel -> TRight
    AtLeftLine -> Confused

    The way I solved that one was to add the rule that once it goes from RtoL to TRight then the InsideChannel stays in TRight status.

    I might reconsider than. I have it automatically annotating the states on either side of the channel on to the chart so I can observe if the states it finds make sense on real charts.

    That's part of debriefing. Jacks talks about using a "red pen" to go back and fix your charts after each day as a learning exercise when the pressure is off.

    One more BIG point about FTTs or a RtoL too for that matter.

    Volume plays a big role in determining for more certainty whether you have an FTT or an RtoL.

    It's because volume surges with each move in the trend direction and relaxes with retraces.

    Right now, I'm ONLY looking at price.

    After I get this working, Jack reviews and approves the charts, I'll make completely separate algorithm for Volume.

    For volume it will have zones, and states.

    That will require the higher level decision making by what I will call the trader "robot".

    It'll Monitor the states of Price and Volume and then Analyze their relationship to confirm or deny the LTT, RtoL, etc.

    Jack says Volume drive the continue/change mode of the market.

    So if the price says it's a RtoL but the volume says "continue" then we won't reverse or exit yet--not until the volume says "okay, now change".

    I may have to rejuggle the states and how they interact.

    That's fine. The priority right now is getting the state machine itself working so it's easy to teach just like a little kid as this moves forward.

    It's amazing how Jack's stuff is coming so clear in working out these details.

    Wayne
     
    #27     Sep 15, 2008
  8. Aurum

    Aurum

    Hi Wayne,

    Perhaps I'm misunderstanding you here - my apologies if so - but are you saying:

    "If price is moving from the right trendline to the left trendline, but the volume says 'continue' then we won't reverse or exit yet..." ?

    If that's the case, then it sounds like you are mixing up the right and left trendlines. In an up channel, the RTL is the bottom line, the LTL is the top line. In a down channel, the RTL is the top line, and the LTL is the bottom line.

    Hoping to clear up some confusion on my part.

    Best regards
    -Au
     
    #28     Sep 15, 2008
  9. By the way, the half way point seems consistent and makes sense. I didn't read it in a post. I think I read that on the traderuniverse.info website where Jack a couple free and entire "treatise" on the methods.

    He does a more comprehensive and clear explanation there with great step-by-step graphs too.

    By the way, it's funny we're talking about 50% moves.

    I made thousands of dollars once on the 50% retrace rule by buying put options every several days on the Eurodollar when it was spiking to a major high.

    It was fun the conversation at lunch one day when I called the broker (before computerization of the markets) to ask about the current price.

    He spurted out something like, "Oh man, it's terrible. You better get out quick. It's pummeling everybody today."

    I said, "Really, what's the price?"

    Turns out it had fallen EXACTLY the 50% point I had been expecting and ALL in one day. A really humdinger of a retrace. I didn't expect it so quickly.

    I asked him to liquidate my options.

    You should have heard the sound in his voice when he observed that instead of getting killed, I had raked in THOUSANDS of dollars profits on that day.

    It turned out I happened to buy a cheap put option just the day before. So it made the most money.

    But all the options even the ones a week or two did well.

    Come to think of it. I learned that when I was a wee newbie and very naive from that guy who does direct mail marketing of futures stuff. Ken something, I think. I remember he called his course, TWMPMM pronounced twampum. I guess that course more than paid the cost and MANY times over. But it wasn't a get rich quick opportunity as he promotes it.

    Anyway, 50% (give or take a little) like you said is very intuitive. It's almost too easy.

    Sincerely,
    Wayne
     
    #29     Sep 15, 2008
  10. ehorn

    ehorn

    There is quite a bit written about the topic of IF1. Thanks Tums for including that great diagram.

    As Jack mentions, there are 2 types of analysis. Value and Participant. I have NO logic in place to perform participant analysis at this point (i.e. DOM leading indicators). I am however performing volume analysis. So that leaves the current model with Value Analysis... the "Ball Park" stuff :)

    That said, my model is focused on 3 modules (Cases, Volume, and P/V) at this time. You will notice that the 7 cases contain >= 2 bars for the case. In order for analysis and decision to occur, you settle on a fractal and make a decision once a case is derived (or inter-bars) are formed and give a picture. Also, at this time it eliminates alot of logic (read "state" management) for dealing with complex intra-bar conditions (i.e. Volume and Price behaviors which form each bar). In my current model, Decisions are always being made but the mode and action gate only opens at the "close of" each bar. Not sure if this reasoning is good, but (in my mind) it is simplifying the initial stages of development and implementation.

    Today I had the opportunity to evaluate my model against my discretionary MADA. It was mainly a confirmation that "MANY" actions the model is currently making are lacking "degrees of freedom" which would constrain the model from acting on every change signal. For instance, I have come to rely on the medium indicators quite a bit for leading signals of Mode and Sentiment and was able to see how incorporating these would have over-riden (or added a dimension of clarity) to many of the decisions made by the model.

    It is funny, many things the computer is so good at, namely speed and no discretion, but I have to laugh when I look at some of the decisions and think... You dumb computer! then I remember who programmed it and I laugh even harder :D Well, just have to make it (me) smarter I guess.

    The current state of the model extracted ~ 1.4X range today with some really silly actions though. Time to debreif :)


    <img src="http://www.elitetrader.com/vb/attachment.php?s=&postid=2069742" width=800 height=600>
     
    #30     Sep 15, 2008
Thread Status:
Not open for further replies.