EMA with a horizontal and verticle shift
Forums › ProRealTime English forum › ProBuilder support › EMA with a horizontal and verticle shift
- This topic has 27 replies, 5 voices, and was last updated 2 years ago by robertogozzi.
-
-
05/19/2022 at 3:21 AM #19342005/19/2022 at 3:24 AM #19342105/19/2022 at 9:28 AM #193430
Only post in the language of the forum that you are posting in. For example English only in the English speaking forums and French only in the French speaking forums.
Again, please abide by the rules highlighted in yellow (below).
Thank you 🙂
05/19/2022 at 1:04 PM #19345105/19/2022 at 1:05 PM #19345205/19/2022 at 2:42 PM #193454I am finding that my code isn’t honoring the MA’s im using as i see them on the chart. I’m also measuring the distances between the MA’s to fine tune entrys and i find trades aren’t taken in situations when the gap is above the distance i have set but takes trades whenthe lines are squashed together. I i’m starting to think i have something missing with regard to the MA coding
05/19/2022 at 3:53 PM #19345505/19/2022 at 4:43 PM #193461The full code is too big to post plus it’s not mine to do so, it’s one that i’m working on as a trader. but this is the section i have for the MA’s. The top two lines determine the MA’s which are set in variable optimisation to 3 and 5.
the next line down determines the conditions which have to be met to take a long. So i want EMA 3 (EMAPer1) to be over the EMA5[1horizontal shift] (EMAPer2) by the Pointsize difference or more. This value is currently set to 5 which is shown on the 4th line down. I have this further up the page.
1234ema30HS = exponentialaverage[EMAPer1](close)ema31HS = exponentialaverage[EMAPer2](close[1])EMAbuyc = ema30HS-ema31HS>ema30HSema31HSDistance*pointsize1Once ema30HSema31HSDistance = 505/23/2022 at 4:12 PM #19372205/23/2022 at 7:58 PM #193730trades aren’t taken in situations when the gap is above the distance i have set
Are you taking into account that code is read at the close / end of a bar and (any resultant) trades are opened / closed at the open / start of the next bar?
Is it possible that you are viewing / assessing MA gap on the 1st bar that shows as trade opened?
Whereas the MA gap that met strategy conditions occured in the bar before the 1st bar that shows as trade opened?
Hope above makes sense?
05/24/2022 at 12:06 PM #193767Yes this makes sense, I have accounted for this and look for when trends are extended and MA’s are spread out for many candles and see that entrys aren’t taken or taken at the end of a move like this when the MA’s are closing back up or in situations where MA’s are squashed together with smaller gaps trades are taken
05/24/2022 at 4:39 PM #19379605/28/2022 at 9:20 AM #194035This a shifted version of a Moving Average. It can be shifted both horizontally (number of bars to be shifted, + or -) and vertically (% to be shifted, + or -, with decimal digits):
12345678910111213141516171819202122232425// Shifted MA////ONCE Periods = 200//ONCE AvgType = 0//ONCE Hshift = 0//ONCE Vshift = 0.0Hshift = min(Hshift,Periods)MyMA = Average[Periods,AvgType](close)Result = MyMA + (MyMA * Vshift / 100)r = 0g = 0b = 255t = 0IF BarIndex > Periods THENIF Hshift = 0 THENt = 255ELSEx1 = BarIndex + (Hshift - 1)y1 = Result[1]x2 = BarIndex + Hshifty2 = ResultDrawSegment(x1,y1,x2,y2) coloured(0,128,155,255)ENDIFENDIFRETURN Result AS "MA" coloured(r,g,b,t)If you replace line 8 with:
1MyMA = Rsi[Periods](close)you will get a shifted RSI (you can change the variable’s name MyMA, or leave it as is).
-
AuthorPosts
Find exclusive trading pro-tools on