Non-crossover of moving averages
Forums › ProRealTime English forum › ProScreener support › Non-crossover of moving averages
- This topic has 6 replies, 3 voices, and was last updated 4 years ago by Nicolas.
Tagged: average, averages, crossover, Moving, moving average, moving averages
-
-
12/30/2019 at 8:18 PM #115624
Dear forum members,
This is my first post on this forum.
I am looking for help in programming proscreeners and in first place a non-crossover indicator between two moving averages.
Let us cut it down into subcomponents and to start with in case of a bullish non-crossover the screener requires for a moving average – let’s take a standard 7-period moving average – to have a negative orientation in three successive period and to reverse higher during a fourth period.If forum members can help with this first piece we will then move to the next part of the screener.
Thanks for help.
12/30/2019 at 10:52 PM #115629There you go (not tested):
123MyAvg = average[7](close)Result = MyAvg > MyAvg[1] and (summation[3](MyAvg < MyAvg[1])[1] = 3)Screener[Result]1 user thanked author for this post.
12/31/2019 at 9:56 AM #115640Thank you Roberto, seems the code is working.
Could we now please add the following criteria:
a) Standard 20-period moving average is positive (last value > previous value), and
b) Last stock price close is above last M7 valueThank you.
12/31/2019 at 10:31 AM #115644There you go:
12345Sma20 = average[20,0](close)MyAvg = average[7,0](close)Result = MyAvg > MyAvg[1] and (summation[3](MyAvg < MyAvg[1])[1] = 3)Result = Result AND Sma20 > Sma20[1] AND close > MyAvgScreener[Result]adding ,0 to averages is useless, I added it just to show that there’s an optional parameter to calculate different types, see https://www.prorealcode.com/documentation/average/.
1 user thanked author for this post.
01/01/2020 at 8:46 AM #115676Great. Thank you so much. Works perfectly.
Have added lines of code to select minimum capital exchanged I had obtained long time ago.
Although it works I am wondering if it can be streamlined.Happy 2020.
12345678910// Non-crossover M7/M20Sma20 = average[20,0](close)MyAvg = average[7,0](close)KapitalMini = 2000 // Minimum Capital (in K)Kapital = Volume * WeightedClose / 1000KapitalOK = ( Kapital > KapitalMini )Result = MyAvg > MyAvg[1] and (summation[3](MyAvg < MyAvg[1])[1] = 3)Result = Result AND Sma20 > Sma20[1] AND close > MyAvg AND KapitalOKScreener[Result]01/01/2020 at 2:02 PM #115679Some suggestions:
- For clarity of messages on ProRealCode’s forums, please use the “insert code PRT” button to separate the text from the code part!
- Do NOT quote all posts, as it makes reading topics slower and more dificult. Do it when many people update that topic and you need to refer to someone specifically. This topic is just us two! Thank you 🙂
As to streamlining it can always be done, depending on what are your goals. Post your details and myself or someone else may help you further.
01/05/2020 at 5:08 PM #115948Another topic for non-crossover of moving average: https://www.prorealcode.com/topic/codage-non-croisement-d-mm/
-
AuthorPosts
Find exclusive trading pro-tools on