Request for a simple strategy to be coded for spread betting
Forums › ProRealTime English forum › ProOrder support › Request for a simple strategy to be coded for spread betting
- This topic has 15 replies, 7 voices, and was last updated 2 months ago by JC_Bywan.
-
-
09/22/2019 at 4:49 PM #108174
Dear ProRealCoders,
I’ve enjoyed using this site for a few years now, checking out and testing all the cool systems you guys have coded. This is the first time I’ve posted on the forum, and I hope that this isn’t against any regulation to request a build of a strategy, but I thought I’d ask anyway. The thing that I have no idea how to achieve here is the way I’d like the trailing stop loss to work, need some people with actual mad skills to help me get it live!
I’m looking to build a simple price action strategy using the following criteria:
New Daily Hi/Lo with Trailing Stop
Assets to trade
- FTSE 100.
Bet Size
- £1 per pip.
Time Frame
- Daily.
Conditions for BUY
- Price is greater than the previous candle’s high. (NOT the close, the high!)
- Stop loss should be placed 15 pips below the low of the previous candle.
- With each new candle that’s formed where you’re not stopped out, move the stop loss to 15 pips lower than the previous candles’ low.
- Open BUY bet on next candle open
Conditions for SELL
- Price is less than the previous candle’s low. (NOT the close, the low!)
- Stop loss should be placed 15 pips above the high of the previous candle.
- With each new candle that’s formed where you’re not stopped out, move the stop loss to 15 pips higher than the previous candles’ high.
- Open SELL bet on next candle open
Condition for EXIT
- When trailing stop loss is triggered.
Times to trade
- No limitations on time of day to trade.
EXTRA NOTES
- I don’t plan for this simple system to open any new positions when there’s already a trade open.
- This is for spread betting NOT CFD trading
I’m incredibly grateful for any help or guidance provided here.
Many thanks coders!
Matt
09/22/2019 at 9:12 PM #108183AugustusKing – Welcome to the forums. Your topic is about an automated strategy code so I have moved it to the ProOrder forum which is dedicated to automated strategies. I will move the topic to that forum. Please try to post in the most relevant forum with any future topics.
1 user thanked author for this post.
09/22/2019 at 9:26 PM #108185Well done @AugustusKing your strategy specification is one of the best laid out / formatted I’ve ever seen on here … I’m sure somebody will help you out soon! 🙂
1 user thanked author for this post.
09/22/2019 at 10:16 PM #108186I really appreciate that, I have manually backtested over various assets including main fx pairs, indices and commodities and it appears to be profitable to a realistic and sustainable level. Drawdowns are low and it performs robustly across various market conditions. I’m excited to see if anyone is willing to help me code this so that I can test it more extensively and then apply it across multiple asset classes. Appreciate the support.
09/22/2019 at 10:38 PM #108187This does what you describe but not profitably! Image shows FTSE100 daily. Even if you separate the long and short parts of the strategy it is not pretty.
12345678910111213141516171819202122defparam cumulateorders = falsec1 = close > high[1]c2 = close < low[1]if c1 thenbuy 1 contract at marketsell at low[1] - 15 stopendifif longonmarket thensell at low[1] - 15 stopendifif c2 thensellshort 1 contract at marketexitshort at high[1] + 15 stopendifif shortonmarket thenexitshort at high[1] + 15 stopendif09/22/2019 at 11:16 PM #108192Hi, and thank you so much for taking a bash on the code for this. Can I just ask if this trails the stop loss with each new candle that is formed or if it fixes the stop at 15 below the low on entry?
I only ask because when I run the backtest on the code you’ve given me it gets the entries just as I would do it manually, but the exits are different to where I’m taking them manually, so I feel like I’ve possibly left something out of my description or not conveyed it well.
I have written on a screengrab of one trade example to highlight where my intended system differs from the code you’ve included. Follow the steps in the order I’ve numbered them. You can see where the PRT backtesting has entered and exited and where I’d need it to exit. Basically the SL is not moving along when a new candle is formed (it’s staying where it was initially placed). This is the major problem here from what I can see.
Additionally, I notice this code deals in ‘contracts’ rather than ‘bet size’, would this still work for automating trading on a spread bet account within PRT?
I hope this is helpful. Just want to reiterate how much I appreciate you taking the time to help with this.
Regards
Matt
09/23/2019 at 7:01 AM #108198Sorry – I got the exits one candle too far back Try this instead:
12345678910111213141516171819202122defparam cumulateorders = falsec1 = close > high[1]c2 = close < low[1]if c1 thenbuy 1 contract at marketsell at low - 15 stopendifif longonmarket thensell at low - 15 stopendifif c2 thensellshort 1 contract at marketexitshort at high + 15 stopendifif shortonmarket thenexitshort at high + 15 stopendif1 user thanked author for this post.
09/23/2019 at 8:49 AM #108202Thank you Vonasi,
That seems to all work as intended at first glance. I will dig a little deeper, but for now, it’s thrown up some unexpected surprises for me (which is a good thing, even if negative!!). I manually backtested it on EUR/USD for 2019 and it was profitable, but on this code it’s not… it’s more likely there was an error with my manual backtest I’m sure, but I’ll double-check things to make sure.
I can see that it works profitably in the long term on the following markets:
DAILY CHARTS
- NIKKEI
- DAX
- NASDAQ
- DOW
- BRENT CRUDE
4HR CHARTS
- DOW
- NATURAL GAS
1HR CHARTS
- Italy 40
- NASDAQ
- DOW
Time to dig a little deeper, actually look at drawdowns, profit factor and how it performs in the various market conditions to see if it’s a viable system to persist with developing 🙂
Do you, or anyone else have any thoughts, observations or ideas on it?
Thanks for this Vonasi
Matt
09/23/2019 at 9:16 AM #108203A fixed SL distance of +/- 15 will not fit all markets. Range on markets changes with time so something like the Dow will have a smaller range in 2010 compared to today but as a percentage of price it is lower so an adaptable SL distance will most likely work better than a fixed one.
09/23/2019 at 9:18 AM #108204A fixed SL distance of +/- 15 will not fit all markets. Range on markets changes with time so something like the Dow will have a smaller range in 2010 compared to today but as a percentage of price it is lower so an adaptable SL distance will most likely work better than a fixed one.
Yep definitely, will need to go through various markets experimenting with which SL ranges work best, that’ll help!! 🙂
Thanks, have a great week as well by the way!
09/23/2019 at 9:55 AM #108208I have written on a screengrab
Gold star for clarity of layout … what screengrab sw have you used for this?
Additionally, I notice this code deals in ‘contracts’ rather than ‘bet size’, would this still work for automating trading on a spread bet account within PRT?
Yes
1 user thanked author for this post.
09/27/2024 at 11:28 PM #23816909/28/2024 at 12:01 AM #23817109/28/2024 at 1:06 AM #238174It shouldn’t be that difficult as long as you know how to trade manually and have the “insight”. Example below.
The staircasing you see is a normal behavior. The climb vs the retrace (dropping back to a lower price level) is what you’ll try to cover with Trailing.
So would you (manually) exit at say 13:24 ? perhaps. But would you at 13:36 after you experienced the part around 13:36 ? No ? then your Trailing should bear the distance to NOT exit at both the 13:24 and 13:36. Now, when that is just covered for, your Trailing will exit at ~14:36.
This should not be found by optimizing, but by looking at the instrument’s behavior.
Btw, I hope you both are serious and don’t turn out to be some kind of spammers (up to being the same person). We’ll see …
1 user thanked author for this post.
10/03/2024 at 4:19 AM #238436 -
AuthorPosts
Find exclusive trading pro-tools on