Carver Hybrid ProOrder Code

Forums ProRealTime English forum ProOrder support Carver Hybrid ProOrder Code

Viewing 15 posts - 1 through 15 (of 45 total)
  • #116639

    Hi Folks

    I’m moving on from my basic breakout indicator to try and code a simple trend following system with some ATR inputs for risk sizing and profit taking.

    The system should trade the Daily TF of xxx FX pair. The rules are quite simple.

    Long

    21ema >63ema AND Carver 1 indicator >0 AND price is greater than previous day’s close

    Short

    21ema <63ema AND Carver 1 Indicator <0 AND price is lower than previous day’s close

    I’m getting a infinite loop error so any help would be appreciated! Also any other glaring code errors you see would be insightful!

    I have placed the indicator code for Carver 1 below the Pro Real Code.

     

    #116656

    Because there is indeed an infinite loop! You are creating it at line 89, once the loop is started you are waiting in it that the “case” variable change, while it can’t since there is no instruction to change it in the loop! 🙂

    Anyway, there is no need to use loop there, just replace the WHILE/WEND instructions with a IF/ENDIF block.

    #116657

    Try replacing line 89 with:

    add this line before line 89:

    and add this line just before line 95 (wend):

    this could trick ProOrder into thinking the loop is not infinite (not tested)

    #116682

    Super thanks Guys – that’s got rid of the Infinite Loop. I have tidied up the code too but alas it’s not taking any trades in the backtest? I have adapted this from a code that is working. Is there something the code is missing or not doing? It should only trade on the daily TF?

    Thanks

     

    #116712

    I cannot test it because I don’t have the indicator you are using, but I want to remark that lines 35-36 could be logically incorrect. I don’t know what you want to achieve with those two lines, but, despite what they look like, they could be easily written as:

    or (as I encourage you to do, to make your code portable to all instruments):

     

    #116764

    Rightly or wrongly 🙂 … I got it going and I left Line 35 and 36 as original (for now anyway).

    .itf attached

    I’m interested so please post any improvements.  I will post same also.

     

    #116862

    Thanks GraHal – I actually got it working. I changed the code to that of what Robert suggested at lines 35 and 36.

    There are a couple of tweaks that I think are worthy of testing. Limiting the profits with a trend system based on ATR could be counter-productive as one needs to collect maximum rent from the trends that keep going. Would it be better to implement a trailing stop as Carver suggests?

    Also, when calling an indicator how can we ‘test’ for differing lengths in Carver 1? Carver conducted extensive back testing in his book and the best lengths for Carver 1 are 10,20,40,80,160 and 320. When calling an indicator does it use the value on the chart being tested? Can it be changed in the code (ie tested under an ‘n’ variable)?

    Also, this system doesn’t add on. Carver recommends taking a ‘nibble’ at the first entry signal and then scaling in, protecting profits with a trailing stop. Could this be added to the code as it’s a little beyond my capabilities.

    I have also added a 10ema to the Carver 1- the reason  being I only want to initiate a trade (long) if Carver 1 is >0 but ALSO >10ema to prove value is not falling.

    I don’t want to complicate the system as that goes against the simplicity of a trend breakout system. Many of the big hedge funds will tell you that overly complex systems that backtest well will nearly always fail in real markets. The fewer rules, the better the expected Sharpe Ratio of the system. To increase the Sharpe you are better adding more markets than more trading rules – you achieve a much better payoff!

     

     

    #116905

    Ok, so I have added a Trailing stop to the code and the changes to the system (DAX anyway) seem impressive. I backtested in 50% of the data available and then did WF analysis on the other half of the data, and came out with around the same results of 60% winning trades and Gain/Loss of 6.4 times

    Since this seems too good to be true I wonder what I’m missing? I also added spread of 1.5

    I’ve used ATR of 21 and also the 21ema and 63ema (3x this as one business quarter) as I know from my time in the City, that the ‘machine’ (algos) at many CTA/Hedge funds are mainly interested in 1 month momentum.

     

    2 users thanked author for this post.
    #116908

    Wow! Looks great … you are flying man!! 🙂

    What did you do in the City? Good to have an ex Gordon Gekko on board!! 🙂

    #116910

    Haha that’s why I think the backtest is throwing up bad results!

    Just worked at NYSE Euronext for a year (which is why I think most lower TF trading is pointless as the Algos have all those timeframes sewn-up – they will always be quicker, have co-location with the matching engines etc). Then worked in Private Wealth mostly since…

    1 user thanked author for this post.
    #116923

    which is why I think most lower TF trading is pointless

    Finally someone who thinks like I do!

    1 user thanked author for this post.
    #116931

    Hi Grimweasel,

    Thanks for sharing your strategy but I cannot test it as the Indicator “Carver 1” doesn’t work.

    it seems there is a problem with zero ?

    Can you check ? Thanks in advance

    #116934

    Hi Lifen

    Sorry I’m not sure why? Did you create the indicator and place into your local library and charts, otherwise the call function won’t work? The code is exactly as I have added to my chart.

     

    #116960

    @Lifen comment out (with //) zero=0 as it is not used anyway??

     

    #116973

    When i try to run the strategy the system says: The “Carver 1″ function retrieved from the strategy is named with 1 parameter instead of 0 expected”

Viewing 15 posts - 1 through 15 (of 45 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login