Trend continuation strategy
Forums › ProRealTime English forum › ProOrder support › Trend continuation strategy
- This topic has 7 replies, 2 voices, and was last updated 5 years ago by robertogozzi.
-
-
07/25/2018 at 12:42 PM #76705
Hi all,
A little help/advice required please. I have a breakout FX strategy that involves buying/selling under certain trending conditions (using MAs and close above/below)
What I would like to do is only buy/sell above the most recent swing low/high to the left of the chart. Ie the previous high or low visible on the chart. It’s easy to see with the eye manually, but less so to code.
I have been using the code below:
1234567891011121314151617181920ema = exponentialaverage[50](close)ema2 = exponentialaverage[12](close)//set trend using highs and lowstrend1= highest[1](high)trend2= highest[7](high)Trend3 = (trend1-trend2)///trend4= lowest[1](low)trend5= lowest[7](low)Trend6 = (trend4-trend5)EMAabove = ema2>emaEMAbelow = ema2<emaatr = averagetruerange[24]hh = highest[2](high)+2ll = lowest[2](low)-2//Filter = ema2-ema2[16]Filter2 = ema2-ema2[2]Long = (emaabove and trend3<0 and filter2>0 )Short = (emabelow and trend6>-1 and filter2<0 )..but wondered if our community had spotted a better definition of ‘trend’ that would be more applicable? Maybe Donchain channel?
The issue with the above code is that, in this case, highest[1] and highest[7] seems to produce the best results for pair in question on backtest, but I want it to be more dynamic, that is spotting the previous H1 swing high or low, not a calculation of the past [n] bars?
Any help appreciated!
07/25/2018 at 2:46 PM #76725Line 4 can be written
1trend1= highsince the highest price within the most recent bar (just 1 bar) is the current one refernced by [0] or by null.
Line 5 should reference, if I understood what you want to achieve, HIGH[1], rather than HIGH, since you already found a high in line 4 and you want to find another higher previously form, so it should be:
1trend2= highest[7](high[1])otherwise you would have a chance that both HIGHs are the same, if they happen in the last of 7 bars.
A BULLish trend is defined as HIGHER highs and HIGHER lows.
A BEARish trend is defines as LOWER highs and LOWER lows.
You may search this forum to find examples.
07/26/2018 at 9:54 PM #76844Thanks for that Robert, yes I was trying to check the trend using the definition of high highs/lower lows for a given chart using the candle at activation time – ie if I want the strategy to start at 0800 and go long then only if price goes higher than the highest high over the last [n] bars.
07/28/2018 at 10:17 AM #769431234ONCE n = 10IF OpenTime = 080000 AND close > highest[n](high) THENBUY 1 CONTRACT AT MARKETENDIFIs that what you mean?
07/29/2018 at 11:08 AM #76994Thanks Robert – I think so yes. I just want to ensure that at pixel time the trade only opens subject to method other rules and final check is that order long/short is only placed above/below the most recent swing high. Is there a more dynamic way of getting PRT to recognise the major swings or do we have to rely on highest [n] bars?
Thanks07/30/2018 at 10:56 AM #77066There’s no workaround. Automated strategies cannot do anything different from manual ones, just faster.
When you sit in front of your PC watching charts you happen very often to spot higher highs (or lower lows), but they are not always swing points. You can tell good swing points from bad ones, when they you see some empty space to their left. In an automated strategy you can estimate empty space with the number of bars to look back. The more they are the more accurate is the swing point.
The attached pic shows some swing points, one of which is maked with a red cross since it is NOT a swing point, the empty space on the left side is too small!
So, to go back to your question:
- n
- highest[n]/lowest[n]
are the best way to identify a swing point.
07/30/2018 at 1:10 PM #77074Super -thanks for the reply Robert. As I thought! It seems with backtesting that some FX pairs that [n] can be 6 hours and others 24. Would you hypothesise this as being individual characteristics of each pair (zone, liquidity, interest rates etc) or data mining?
07/30/2018 at 2:42 PM #77083The number of LookBack bars, as the periods for MA’s and so on… for DAX is different from those for EUR/USD or SP500.
Also, those same numbers for EUR/USD h1 are different from those for EUR/USD daily,….
It’s a matter of spending (hopefully not wasting) many hours testing different settings!
-
AuthorPosts
Find exclusive trading pro-tools on