Various conding requests
Forums › ProRealTime English forum › ProOrder support › Various conding requests
- This topic has 3 replies, 2 voices, and was last updated 32 minutes ago by
robertogozzi.
-
-
02/25/2025 at 12:55 PM #244336
Hello everyone! How are you doing?
I have some coding requests, i hope you can help me 🙂
1- The price has increased by x percent over the last x candles.
2- The price has remained within a certain range (moved sideways) over the last x candles
3- The price has remained over a moving average over the last x candles
4- Set the stop loss at the low of the last x candles.Bonus: The price has formed higher highs over the last x candles.
Thanks.
02/25/2025 at 3:51 PM #244346There you go:
1234567891011121314151617181920212223242526272829303132// 1ONCE X = 10ONCE PC = 5Gap = ((close / close[X - 1]) - 1) * 100RETURN (Gap >= PC) AS "%rise"// 2ONCE X = 10HH = highest[X](high[1])LL = lowest[X](low[1])Signal = 0IF high <= HH AND low >= LL THENSignal = 1ENDIFRETURN Signal AS "Signal"// 3ONCE X = 10ONCE P = 20Sma = average[P,0](close)//Above= close > SmaBelow = close < SmaNumber = BarsSince(Below)RETURN Number AS "Number of Bars Above"// 4ONCE X = 5SET STOP PRICE lowest[X](low)// BonusONCE X = 10Result = summation[X](high > high[1])02/25/2025 at 5:20 PM #244354Thank you Roberto!
Just a question: in n.3 where is “X” used? And why did you greyed out the above condition? Since the price need to stay over the moving average the below condition should be greyed out no?
So it should be something like
1234Above= close > Sma//Below = close < SmaNumber = BarsSince(Above)RETURN Number AS "Number of Bars Above"02/25/2025 at 8:34 PM #244358- I forgot to remove that line that I had copied from the prior lines.
- Because I coded that line, but then I realized that we don’t need to know it. Since once we know what is the last bar BELOW, all the next ones will be ABOVE for sure!
-
AuthorPosts