Regular visitors will have noticed ever increasing amounts of spam on the Trading Gurus Community Forum. On November 24th 2012 we implemented some changes:

1. New users will be moderated 2. Registered users who have a post count of zero will not be able to view attachments or download code. 3. Registered users who have a post count of zero will not be able to create a new thread

As an additional countermeasure we anticipate introducing a modest paywall in the near future.

If this is your first visit here our apologies for the inconvenience.

Existing users may wish to contribute their ideas to this thread.

Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Buying Dips Using EasyLanguage

  1. #1
    Administrator Jim's Avatar
    Join Date
    Apr 2010
    Location
    South West England
    Posts
    494

    Buying Dips Using EasyLanguage

    We've arrived here from yet another random entry thread (YARET for short) via an academic thesis introduced by Dr. T, and a subsequent offer to post some code that implements the concept from Frank. Here we can discuss one form of "non-random entry".

    Take it away guys. I'll certainly check if the code runs happily on MultiCharts as well as TradeStation. If there's any technical problems feel free to shout at me!

    For some additional information concerning this type of strategy please also see:



    Jim
    Reality is merely an illusion, albeit a very persistent one - Albert Einstein

  2. #2
    Junior Member Frank's Avatar
    Join Date
    Sep 2013
    Location
    Germany
    Posts
    15
    Long live Captain Broccoli!

    So, lets buy some dips shall we

    First things first: Don't use my code to trade this strategy live! The whole thing is still very messy and there still might be terrible little bugs in there that will kill little baby kittens in Indonesia. You have been warned.

    Also the strategy does not meet my personal requirements live trading the way I understood / coded it and probably even the way it was designed by the author. Most multipliers appear to be especially fitted to the OMX Stockholm 30 which I have never traded and actually I don't even have intraday data for.

    However, let's give it a shot. Maybe we can make sense of everything and discover a raw diamond. I copy pasted the sections with the relevant information from the pdf. Some little copy paste errors might be in there due to the PDF. Also I am not sure if I am allowed to do this actually. If not, please tell me Jim and I will remove the excerpts.

    I started coding the daily long trading strategy (4.1) and applied it to the /ES as it has some similarities (scale wise) to the OMX Stockholm 30.

    Here is the Nitty gritty, let's see if I got something wrong. I will put the quotes from the thesis in here and how I translated it (full code attached to post):

    1.
    The rst thing that happens when a trading
    day is over is that the ATR for 250 days, ATR(250), and the 14 days ATR,
    ATR(14), are calculated.
    Code:
    ATR_Long = AvgTrueRange(Atr_Long_Period);
    ATR_Short = AvgTrueRange(Atr_Short_Period);
    2.
    After that the highest, HH6, and the lowest, LL6, price for
    the last six trading days are selected.
    Code:
    HH = Highest(High,HighLowChannelPeriod);
    LL = Lowest(Low,HighLowChannelPeriod);
    3.
    When HH6, LL6 and ATR(250) are
    known the quotient VolQuota = HH6-LL6/
    ATR(250) is calculated.
    Code:
    VolQuota = (HH-LL)/Atr_Long;
    4.
    If there is no trade open the strategy will calculate a trigger, T, that
    will be used as an entry signal. To get T the rst thing done is to calculate
    a volatility quantity expressed as a percentage of the latest closing price of
    the index, C1. This volatility is thus calculated as:
    VolPct = 100  ATR(14) / C1
    Code:
    VolPct = (100*Atr_Short)/close;
    Quick remark: I use C and not C[1] as my last day close as I calculate "on close" in my software (Tradesignal.com)

    5.
    It's getting tricky now:
    By studying earlier values of this quantity a lowest value of VolPct is set.
    Before calculating the trigger T, a trigger factor, TF, is to be dened. TF
    gets the value 1 when the VolPct reaches a certain top value, and when the
    lowest value of the VolPct is hit the value of the trigger factor is 0.05.
    I tried to solve this by calculating a little oscillator with boundaries 1 and 0.05:

    Code:
    minVolP=lowest(VolPCT,Barnumber-Atr_Short_Period);
    maxVolP=highest(VolPCT,Barnumber-Atr_Short_Period);
    
    RangeVolP = maxVolP - minVolP;
    ScaleCurrentVolP = VolPct - minVolP;
    
    If RangeVolP > 0 then
    TFtemp = round(0.05 +(0.95 * ScaleCurrentVolP/RangeVolP),2);
    Not sure if I got that right conceptually, might be interesting to hear your thoughts.

    6.
    [QUOTE]Yet
    an other value is also added to TF. This value is a proportion of the value
    between the latest six days highest prices and lowest prices. This dierence
    is then divided by 5 and added on to TF. The a trigger T0 is the dened as:
    T0 = LL6 + (HH6
    Attached Files Attached Files

  3. #3
    Administrator Jim's Avatar
    Join Date
    Apr 2010
    Location
    South West England
    Posts
    494
    Hi Frank,

    Thanks very much for the code. I'm wondering if it's in a Tradesignal specific dialect of EasyLanguage? It's certainly not trivial to get it to compile in MultiCharts, which seems never to have heard of "maxItems" for example.
    Reality is merely an illusion, albeit a very persistent one - Albert Einstein

  4. #4
    Senior Member
    Join Date
    Dec 2011
    Location
    London, UK
    Posts
    139
    Hi Frank,

    Thanks for posting this... you've beaten me to it! Coding this has been on my list for a while, and the list continues to grow!!

    Anyway, I've been messing with Time of Day based approaches recently. Despite a rather sorry accident on a live account (messing with parameters and getting hit multiple times by a news event!!), trading at specific times of day does/did appear to offer a systematic 'edge', albeit very slight - but just enough to cover costs. This leads me to think that there is some potential in looking into 'dip searching and breakout algorithms'. With this in mind, you might be interested in the attached colour maps representing the EURUSD...

    What they show is described below:


    For the EURUSD over the past year a linear regression line was fitted to every possible combination of open and close minutes within each day. For each regression line, the gradient was determined. Now, with each row representing days Monday to Friday, the first column is the expected return for every combination of minutes within a day (1440 minutes in a day) based upon the gradient of a linear regression. The second column is the expected return based upon the magnitude of the gradient (i.e. ignoring the sign of the gradient). The third column is the corresponding mean squared residual for all of the regression lines (provides an idea of volatility).

    I think that these are very interesting. The first column is indicative of market preferred direction at particular times of day. Now, if one could reliably detect this and exploit it, then that would be very interesting indeed! Of course, we could just be being fooled by randomness!

    I'm afraid that I don't have a great deal of time to contribute to the forum at the moment, but will be following developments.

    Cheers,
    Pete


    EURUSD_TOD.jpg

  5. #5
    Senior Member
    Join Date
    Dec 2011
    Location
    London, UK
    Posts
    139
    So, I'm meant to be doing something else and this isn't EasyLanguage, it's Matlab (which is incidentally an 'easy language'!).

    Anyway, following my previous post and inspired by Mr Broccoli man, I thought that I'd modify one of my scripts to see if TOD (the time of day trader) could profit from buying dips. See his backtest (2009-2013) and code attached, TOD - Buy The Dip During Sideways Market (or TODBTDDSM for short). Beware, trading costs have been neglected. I also haven't double checked the code to make sure that it's working properly. Nonetheless, interesting result!



    Cheers,
    Pete
    BuyTheDipDuringSidewaysMarket.jpgBuyTheDipDuringSidewaysMarket.zip

  6. #6
    Junior Member Frank's Avatar
    Join Date
    Sep 2013
    Location
    Germany
    Posts
    15
    Hi,
    Very interesting work Dr_T.
    Even though I don't have that much of experience with intraday systems I believe that the sessions in which you trade are crucial to the success.

    Returning to the "dip searching" system above I still wonder how I could make the inputs independent from the symbol traded. I have tried percentages for the atr threshold for example to test on other symbols but they all seem to have their own "clock" ...

  7. #7
    Administrator Jim's Avatar
    Join Date
    Apr 2010
    Location
    South West England
    Posts
    494
    Thanks for that Pete. Have you ever experimented with Octave and/or R? We're not all well paid academics you know!

    Quote Originally Posted by Frank View Post
    I believe that the sessions in which you trade are crucial to the success.
    I also believe it helps. See for example (MQL4 not EZL I'm afraid!):

    http://community.trading-gurus.com/t...reakout-System

    Returning to the "dip searching" system above I still wonder how I could make the inputs independent from the symbol traded. I have tried percentages for the atr threshold for example to test on other symbols but they all seem to have their own "clock" ...
    Why not "fine tune" things for each individual instrument?
    Reality is merely an illusion, albeit a very persistent one - Albert Einstein

  8. #8
    Senior Member
    Join Date
    Dec 2011
    Location
    London, UK
    Posts
    139
    Quote Originally Posted by Jim View Post
    Why not "fine tune" things for each individual instrument?
    I was wondering the same thing.

    Have you ever experimented with Octave and/or R?
    I have messed around with both, although I have more experience with Octave. I used to use SciLab as my main tool of choice too. However, I currently have access to Matlab and many of its toolboxes... The matlab .m file that I shared would probably require minimal tinkering (if any) to work in Octave. It's just a text file, so your favourite text editor will open it.

  9. #9
    Junior Member Frank's Avatar
    Join Date
    Sep 2013
    Location
    Germany
    Posts
    15
    Maybe I am a bit conservative but "fine tuning" to an instrument rings a lot of optimisation alarm bells in my head. I personally like models that elegantly adjust themselves to the instrument with parameters like "fraction x of volatility" and "stop loss = multiple y of volatilty" or even just "percentage of price" for example that are the same for every instrument.
    I am a fussy old robustness German
    What I have learned so far is that if a model works conceptually on the majority of different instruments (like a broad selection of futures or a big portfolio of stocks) we have a higher chance that the system holds up in the future.
    Also as this is a pain to optimise it might avoid over optimising (which I often find myself doing to make that equity curve just look that littttttle bit smoother ...)

  10. #10
    Junior Member Frank's Avatar
    Join Date
    Sep 2013
    Location
    Germany
    Posts
    15
    Thanks for sharing the system above Dr_T. Very interesting to see complete Matlab systems. I have just started with R and might try to port this as an exercise if that's ok

Page 1 of 2 12 LastLast

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •