Coding request for EMA9 / WMA30 strategy
Forums › ProRealTime English forum › ProOrder support › Coding request for EMA9 / WMA30 strategy
- This topic has 7 replies, 3 voices, and was last updated 1 year ago by Meta Signals Pro.
-
-
10/19/2021 at 9:32 PM #179990
Hello, I have a coding request for the following strategy from Galen Woods. Can someone code that for me, please?
These are the rules for a long trade signal:
The 9-period EMA must be above the 30-period WMA
The two moving averages must be separated from each other
The first bar to close below the 9 EMA is used as the trigger bar for the buy setup
Place a buy limit order above the high of the trigger bar.
If you want to go short, follow this three step process:
The 9-period EMA must be below the 30-period WMA
The two moving averages must be separated from each other
The first bar to close above the 9 EMA is used as the trigger bar for the sales setup
Place a sell limit order below the low of the trigger bar
Trailing stop loss below / above the WMA30
For better reading of the trading rules I found this website:
https://tradingstrategyguides.com/9-30-trading- strategy / # When_to_use_the_930_Trading_Method
10/20/2021 at 12:06 PM #180009There you go:
9-30 Trading Method123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566// 9-30 Trading Method////https://tradingstrategyguides.com/9-30-trading-strategy///DEFPARAM CumulateOrders = false//ONCE Trigger = 0ONCE EntryL = 0ONCE EntryS = 0ONCE SL = 0//TradeON = (OpenTime >= 090000) AND (OpenTime <= 190000)//Ema9 = average[9,1](close)Wma30 = average[30,2](close)L1 = Ema9 > Wma30S1 = Ema9 < Wma30MAgap = abs(Ema9 - Wma30)Apart = MAgap > average[20,0](MAgap)Trigger = (L1 AND (close < Ema9)) OR (S1 AND (close > Ema9))IF OnMarket OR (L1 <> L1[1]) OR (S1 <> S1[1]) THENTrigger = 0EntryL = 0EntryS = 0SL = 0ENDIFIF (Apart AND L1) AND Not Trigger THENEntryL = high + 1 * PipSizeEntryS = 0//SL = low - 1 * PipSizeSL = Wma30 - 1 * PipSizeELSIF (Apart AND S1) AND Not Trigger THENEntryS = low - 1 * PipSizeEntryL = 0//SL = high + 1 * PipSizeSL = Wma30 + 1 * PipSizeENDIF//IF TradeON THENIF EntryL AND Not LongOnMarket THENBUY 1 CONTRACT AT EntryL STOPSELL AT SL STOPELSIF EntryS AND Not ShortOnMarket THENSELLSHORT 1 CONTRACT AT EntryS STOPEXITSHORT AT SL STOPENDIFENDIFIF LongOnMarket THENSL = max(SL,Wma30)SELL AT SL STOPELSIF ShortOnMarket THENSL = min(SL,Wma30)EXITSHORT AT SL STOPENDIF//-----------------------// debugging codeEntry = EntryLIF Entry = 0 THENEntry = EntrySENDIFIF Entry > 0 THENgraphonprice EntryENDIFIF SL > 0 THENgraphonprice SL coloured(0,128,0,155)ENDIFI used the more conservative trailing stop based on WMA30, but I also commented out the more aggressive way. You can simply use either by swapping comment slashes (but I think it shouldn’t be rewarding).
I tested it on DAX € 5, 1h TF, 200K units.
3 users thanked author for this post.
10/20/2021 at 4:44 PM #180027Thank you very much Roberto, the strategy looks good. The way it should work. I think the results are better on Nasdaq or SP500.
Can you please explain the function of lines 18 and 19 to me? In words?
Can you add a take profit? In relation to the SL, 1: 1 or 1: 1.5?
10/20/2021 at 4:56 PM #180029That’s to make sure the two averages have some gap in between them. I use GAP (difference) to calculate their distance, then I set variable APART only when that gap is greater than the its average over a given period.
Replace lines 27-37 by these ones (I couldn’t test them, though):
123456789101112131415IF (Apart AND L1) AND Not Trigger THENEntryL = high + 1 * PipSizeEntryS = 0//SL = low - 1 * PipSizeSL = Wma30 - 1 * PipSizeTP = abs(EntryL - SL) * 1.5SET TARGET PROFIT TPELSIF (Apart AND S1) AND Not Trigger THENEntryS = low - 1 * PipSizeEntryL = 0//SL = high + 1 * PipSizeSL = Wma30 + 1 * PipSizeTP = abs(EntryS - SL) * 1.5SET TARGET PROFIT TPENDIFreplace 1.5 with any multiplier of your choice.
10/20/2021 at 6:32 PM #18003508/28/2023 at 4:33 PM #219959Hi Phoentz,
Thanks for digging on other sites to get new ideas ^^
did you get a good backtest on this one and on which asset ? Mine are negative before 2021 on NAS H1;
best
08/28/2023 at 5:47 PM #219964The strategy is intended intraday… I got it to work quite adequately with changed values in the TF M1 on Nasdaq. It’s been a while. But I had the feeling that it wasn’t stable. But I’m a little smarter now than I was then. It’s possible that I didn’t have much of a clue as to how the system worked.
1 user thanked author for this post.
09/06/2023 at 3:33 PM #220435Ah ok I was updating the backtest of Roberto that was in “1 ora”
https://www.prorealcode.com/topic/coding-request-for-ema9-wma30-strategy/#post-180009
here is the backtest ;
Maybe inverting the conditions can make it a winner 😉
Thanks anyway,
Chris
-
AuthorPosts
Find exclusive trading pro-tools on