Request for a simple double time frame strategy to be coded for spread betting

Forums ProRealTime English forum ProOrder support Request for a simple double time frame strategy to be coded for spread betting

Viewing 15 posts - 1 through 15 (of 20 total)
  • #141184

    Request for a simple double-time-frame strategy to be coded for spread betting

    I’d love to ask you clever folk on this forum for some help in creating a ProRealCode system that uses 2 timeframes, 200 EMAs and a MACD on the shorter time frame chart.

    Here’s the proposed system for testing on EUR/USD (and other major FX pairs):

    LONG TRADE

    If price is > 200EMA on DAILY chart then execute LONG only trades

    [and]

    If price is > 200EMA on 30 min chart

    [and]

    If there’s a bullish cross on the MACD on the 30 min chart (where the 12ma moves up through the 26ma regardless of where it is).

    [If ALL of the above, then]

    BUY 1 / pip on next candle open

    STOP LOSS: 50 pips (Spread betting, so not using ‘LOTS’)

    TAKE PROFIT: 100 pips (Spread betting, so not using ‘LOTS’)

     


     

    SHORT TRADE

    If price is < 200EMA on DAILY chart then execute SHORT only trades

    [and]

    If price is < 200EMA on 30 min chart

    [and]

    If there’s a bearish cross on the MACD on the 30 min chart (where the 12ma moves down through the 26ma regardless of where it is).

    [If ALL of the above, then]

    SELL 1 / pip on next candle open

    STOP LOSS: 50 pips (Spread betting, so not using ‘LOTS’)

    TAKE PROFIT: 100 pips (Spread betting, so not using ‘LOTS’)

     


     

    BONUS POINTS

    I’d also love to see how this model would work if used with a TRAILING STOP LOSS rather than a fixed risk/reward. If you felt inclined to also include a version of the code with a trailing stop loss then, I’d probably want to test it trailing by say 25 pips.

     


    QUESTIONS?

    I’m open to them 🙂

     

    Thank you so much for taking the time to read and consider this, I’d be very grateful for any help or comments on this from the community.

    All the best!

    Matt

    #141185

    *I meant to say in parenthesis next to the MACD specification that “when the MACD line moves through the 9ma Signal line”

    #141186

    This is what I have so far from trying to do it myself. But I can’t add the second time frame on the Daily in for another level of confirmation of the trend (above the 200ema for bullish and visa versa).

     

    #141187

    Always use the ‘Insert PRT Code’ button when putting code in your posts to make it easier for others to read.

    I tidied it up for you.

    Thank you 🙂

    1 user thanked author for this post.
    #141191

    Try below, not tested, but you get the general idea?

     

     

    1 user thanked author for this post.
    #141203

    Ah excellent, many thanks for looking at this for me, it means a lot that you’ve taken the time.

    So, excuse my ignorance, that’s why I’m here haha, but do I just insert this into the pre-existing code that I’ve posted above? Will this take into account the MACD trigger crossovers that I use for entry if the price is above the 2 time-frame EMAs?

     

    Cheers

     

    Matt

    #141234

    Below is the Buy side, you do the SellShort and post the full code please.

     

    #141235

    Above is not quite what you want as I have rem’d out C2 (I’ve had a few wines and beers! 🙂 ).

    But, in your original code, you had the the MACD Signal line incorrectly coded, it should be …

     

     

    1 user thanked author for this post.
    #141245

    Thanks for that, I’ve really battled with it this evening, but like you, I’m a couple of G&Ts and some craft ales deep, and now I’m not seeing the wood for the trees. But I didn’t want to end the day without something to show for our efforts.

    I ended up running this, and it’s miles away from the expected results I had from manual backtesting, so I think I’m back to the drawing board.

    Here’s the code I ended up with:

    and the corresponding results are attached.

    However, the code I had above in the thread yielded much better results over the year, and this wasn’t using multiple time frames (also see results attached)

    I think something’s amiss, to be honest, but I’m too confused and don’t know how to code myself, I just use the ‘simplified creation’ bit normally, or I take programmed code and tinker using as much common sense/logic as I’m able to muster haha.

    Anyway, back to the drawing board. I really appreciate the help on trying to code this, my expectations of how it should perform (based on manual backtesting on GBP/USD over 7 months in 2020 are:

    • Profit = 11%
    • Trades = 37
    • Win Rate = 76.19%
    • Max Consecutive Wins = 3
    • Max Consecutive Losses = 4
    • Max Drawdown = 7%
    • Max Run up = 12%

    Hope you’ve had a great weekend GraHal. I’m sure as I get more involved in the community I’ll be able to better solve errors and contribute. But I have to find the time to start formerly learning how first!

    Cheers

     

    Matt

     

     

    #141248

    Hahah … what a pair we are!

    In my (drunken) opinion 🙂 No I’ve sobered up a bit now!

    You don’t need C1 and C2  now on the Buy side nor C3 and C4 as you have replaced with CDaily and C30m.

    Opening a Short is made using SellShort (not Sell as you have above) so I’m not surprised your results  are all over the place ! 🙂

    Come back Roberto … all is forgiven! 🙂

    #141249

    Hmm, that’s really odd, I couldn’t get it to even show results unless I did it like that. It just kept showing ‘No Data’. Do you happen to get any results show up on a backtest of the code snippet you gave me above for the buy-side trades? I’m not getting it to show any results.

    #141254

    In below, why didn’t you use CDailySell ??

    There are so many things not correct that it is best to post your latest code as you correct it.

     

     

     

    #141255

    Principally because I don’t know how to programme trading systems, and was asking for help haha. So I’m just guessing how to do it, and using trial and error. I originally did use cDailySell (which I made up in the first place), but then I figured that it would have been a constant/the same on both the buy and sell side. So, only changed the bits that I thought were different for a sell trade, as opposed to what you gave me for the buy trade.

    I don’t really have a latest code version at present other than what had been shared, because none of it came close sadly.

    #141258

    Ha … best way to learn is to try try and try again.

    I am not the best at coding and I am watching a film with one eye and trying to help you at same time.

    Why don’t you just get the Buy side working first as that means that there is only half the code to keep changing etc?

     

    #141259

    I also had a pizza and a beer, but I think this should do:

     

    2 users thanked author for this post.
Viewing 15 posts - 1 through 15 (of 20 total)

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