Distance between two SMAs
Forums › ProRealTime English forum › ProOrder support › Distance between two SMAs
- This topic has 11 replies, 5 voices, and was last updated 2 years ago by JS.
-
-
01/03/2022 at 7:22 PM #18443901/03/2022 at 7:39 PM #184444
There you go:
1PerCent = (Sma20 * 100 / Sma200) - 1001 user thanked author for this post.
01/03/2022 at 7:45 PM #18444801/03/2022 at 8:10 PM #18445101/03/2022 at 9:19 PM #184455distance in percent?
Distance in percent of what … the faster average / SMA20?
So where SMA20 > SMA200 …
((SMA20-SMA200)/SMA20)*100
1 user thanked author for this post.
01/03/2022 at 9:29 PM #18445601/03/2022 at 10:24 PM #18446301/06/2022 at 8:16 AM #184697Hi. New to this forum. Such a great comunity.
My firt try with an algo. Inspiration from PhoentzsIs this someting to build on or what do u think, Too much time in market? How to improve thos without curvefitting?
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158// Wallstreet 1H - SMA Distance// SnorreDK @ prorealcode.com//2022-01-06//To do - Better entrys - more standard filters?//Try other trailing//****************************************** **************************************DEFPARAM CumulateOrders = False // Cumulating positions deactivatedONCE sl = 1.5ONCE sl2 = 1.0ONCE A1 = 70.0ONCE A2 = 60.0ONCE tsm = 4.0ONCE tst = 4.6ONCE tst1 = 1.5ONCE st = 0.28ONCE A11 = 10.0ONCE A22 = 20.0ONCE y1 = -3.1positionsize = 1Timeframe(4h, updateonclose)AA=RSI[14](close)Timeframe(default)CB2 = (AA<A1 and AA>A11) //4H RSI filterCS2 = (AA<A2 and AA>A22) //4H RSI filterS1 = Average[20](Close)S2 = Average[200](Close)Dist = S1 - S2DistPerc = (Dist / Close) * 100CB1 = DistPerc > y1CS1 = DistPerc < y1If not (DayOfWeek = 2) thenIf CB1 and CB2 and not shortonmarket thenBUY positionsize contracts AT MARKETEndifIf CS1 and CS2 and not longonmarket thenSELLSHORT 1 CONTRACTS AT MARKETEndifendif//****************************************************************************************// trailing stop atronce trailingstoptype = 1 // trailing stop - 0 off, 1 ononce tsincrements = st // typically between 0 and 0.25once tsminatrdist = tsm // typically between 1 and 4once tsatrperiod = 14 // ts atr parameteronce tsminstop = 12 // ts minimum stop distance, set to IG min valueonce tssensitivity = 1 // [0]close;[1]high/lowif trailingstoptype thenif barindex=tradeindex thentrailingstoplong = tst // ts atr distance, typically between 4 and 10trailingstopshort = tst1 // ts atr distance, typically between 4 and 10elseif longonmarket thenif tsnewsl>0 thenif trailingstoplong>tsminatrdist thenif tsnewsl>tsnewsl[1] thentrailingstoplong=trailingstoplongelsetrailingstoplong=trailingstoplong-tsincrementsendifelsetrailingstoplong=tsminatrdistendifendifendifif shortonmarket thenif tsnewsl>0 thenif trailingstopshort>tsminatrdist thenif tsnewsl<tsnewsl[1] thentrailingstopshort=trailingstopshortelsetrailingstopshort=trailingstopshort-tsincrementsendifelsetrailingstopshort=tsminatrdistendifendifendifendiftsatr=averagetruerange[tsatrperiod]((close/10)*pipsize)/1000//tsatr=averagetruerange[tsatrperiod]((close/1)*pipsize) // (forex)tgl=round(tsatr*trailingstoplong)tgs=round(tsatr*trailingstopshort)if not onmarket or ((longonmarket and shortonmarket[1]) or (longonmarket[1] and shortonmarket)) thentsmaxprice=0tsminprice=closetsnewsl=0endifif tssensitivity thentssensitivitylong=hightssensitivityshort=lowelsetssensitivitylong=closetssensitivityshort=closeendifif longonmarket thentsmaxprice=max(tsmaxprice,tssensitivitylong)if tsmaxprice-tradeprice(1)>=tgl*pointsize thenif tsmaxprice-tradeprice(1)>=tsminstop thentsnewsl=tsmaxprice-tgl*pointsizeelsetsnewsl=tsmaxprice-tsminstop*pointsizeendifendifendifif shortonmarket thentsminprice=min(tsminprice,tssensitivityshort)if tradeprice(1)-tsminprice>=tgs*pointsize thenif tradeprice(1)-tsminprice>=tsminstop thentsnewsl=tsminprice+tgs*pointsizeelsetsnewsl=tsminprice+tsminstop*pointsizeendifendifendifif longonmarket thenif tsnewsl>0 thensell at tsnewsl stopendifif tsnewsl>0 thenif low crosses under tsnewsl thensell at market // when stop is rejectedendifendifendifif shortonmarket thenif tsnewsl>0 thenexitshort at tsnewsl stopendifif tsnewsl>0 thenif high crosses over tsnewsl thenexitshort at market // when stop is rejectedendifendifendifendifIf shortonmarket thenSET STOP %loss SL2endifIf Longonmarket thenSET STOP %loss SLendif01/06/2022 at 2:49 PM #184764Personally, I think it’s been on the market for a long time, maybe too long. I can see that the setup is modeled on my H4 breakout. This type of setup works very well for me. But my little timeframe is M1. At the moment I’m also working on a setup with RSI. But with RSI2 in the H4 as a reversal. Build it yourself with the timeframes like H4 breakout. But it is still in progress.
01/09/2022 at 12:41 PM #18493001/09/2022 at 12:57 PM #184935I’ve put this type of calculation aside for now. Even if it would be nice to calculate it so easily, it somehow doesn’t work that way. I continue to use my classic pullbacks. So MACD pullback or RSI pullback in connection with the MAs. That works pretty well.
01/09/2022 at 2:15 PM #184946Distance MA123456S1 = Average[20](Close)S2 = Average[200](Close)Dist = S1 - S2DistPerc = (Dist / Close) * 100CB1 = DistPerc > y1CS1 = DistPerc < y1The distance between the MA’s can be positief or negatief and zero for the crossing of the MA’s
For a Long signal use DistPerc > “Positief Value” (for example yl = 0.5)
For a Short signal use DistPerc < "Negative Value" (for example ys = -0.5) In your code there is only a negative value y1 = -3.1 -
AuthorPosts
Find exclusive trading pro-tools on