Movement indicator
Forums › ProRealTime English forum › ProBuilder support › Movement indicator
- This topic has 13 replies, 3 voices, and was last updated 3 years ago by Oliviertrader2020.
-
-
01/05/2021 at 6:50 PM #156496
Hello,
The attached image shows the daily percentage movement of the S&P 500 over the last 10 years.
Someone can help me create an indicator, similar to the pivot point and its SDs, that would indicate the levels on a daily basis: +1%, +2, +3%, -1%, 2% and -3%.
Ideally, an indicator, also similar to the pivot point, would be created that would indicate the standard deviations (annualized) of daily return: 1, +2 and +3 standard deviations and -1, – 2 and -3 standard deviations:
https://blogs.cfainstitute.org/investor/2012/08/27/fact-file-sp-500s-sigma-events/Thank you.
01/06/2021 at 3:16 PM #156604Here’s a picture that shows what I want:
lines that are +/-1%, +/- 2% and +/-3% of the previous day’s close.
No need to color the buying and selling areas, just to have an indicator with lines similar to the pivot points.01/06/2021 at 3:51 PM #156613Something like this?
1234567891011121314151617if opendayofweek <> opendayofweek[1] thenperc1 = close[1]*1.01perc2 = close[1]*1.02perc3 = close[1]*1.03percd1 = close[1]*0.99percd2 = close[1]*0.98percd3 = close[1]*0.97endifdrawsegment(barindex,perc1,barindex+1,perc1) coloured(0,128,0) style(dottedline,1)drawsegment(barindex,perc2,barindex+1,perc2) coloured(0,128,0) style(dottedline,2)drawsegment(barindex,perc3,barindex+1,perc3) coloured(0,128,0) style(dottedline,3)drawsegment(barindex,percd1,barindex+1,percd1) coloured(128,0,0) style(dottedline,1)drawsegment(barindex,percd2,barindex+1,percd2) coloured(128,0,0) style(dottedline,2)drawsegment(barindex,percd3,barindex+1,percd3) coloured(128,0,0) style(dottedline,3)return1 user thanked author for this post.
01/06/2021 at 3:53 PM #15661401/06/2021 at 4:14 PM #15662101/06/2021 at 5:12 PM #156636Yes, that’s exactly it! Thank you very much.
01/06/2021 at 5:40 PM #156643Is it possible to create the same indicator but this time using 1, 2 and 3 standard deviations ?
The most commonly used calculation method is the standard deviations annualized of daily return.
It would be ideal to have such an indicator because it would indicate the levels used by many mean reversion algorithms.But if it’s too difficult to program with PRT it will be easier to create an indicator with standard deviations of daily returns that takes into account the days displayed on the graph (as on your post).
01/06/2021 at 5:44 PM #156644Hello Nicolas. Not necessarily “all time” because the markets are much more volatile these last decades.
The most commonly used calculation method is the standard deviations annualized of daily return.
But if this is too difficult to program with PRT, an indicator with standard deviations of daily returns that take into account the days displayed on the chart is a good alternative.01/07/2021 at 7:13 AM #156684Hello @Vonasi, I can’t call the indicator to use it in an algorithm.
The idea is to buy when the price has rebounded close to the -2% level.
I created a simplified version of the indicator with only this -2% level:Indicator1234567if opendayofweek <> opendayofweek[1] thenpercd2 = close[1]*0.98endifdrawsegment(barindex,percd2,barindex+1,percd2) coloured(0,128,0) style(dottedline,2)returnMais lorsque je lance le backtest de l’algo, aucuns trades ne ressort :
Mean SD-212345678910111213141516171819202122232425DEFPARAM Cumulateorders = False// Conditions pour ouvrir une position acheteuseStandardDeviation = Call "SD2"c1 = low[1] < StandardDeviation[1]c2 = close > StandardDeviationConditionsAchat = C1 AND C2IF NOT LongOnMarket AND ConditionsAchat THENBUY 1 CONTRACTS AT MARKETENDIF// Conditions pour fermer une position acheteuseC3 = close >= Average[20](close)ConditionsCloseAchat = C3If LongOnMarket AND ConditionsCloseAchat THENSELL AT MARKETENDIFCan you help me find the error?
01/07/2021 at 9:02 AM #156703Annualized Standard Deviation = Standard Deviation of Daily Returns * Square Root (250)
Annualized Standard Deviation12345//Annualized Standard Deviation = Standard Deviation of Daily Returns * Square Root (250)//you can change the observed period with "period" setting below:period = 200a=std[period](variation)*sqrt(250)return a as "annualized STD of a given period"1 user thanked author for this post.
01/07/2021 at 9:20 AM #156710Surely the SQRT(250) relates to 52 times 5 candle weeks minus holidays? On PRT’s 6 candle weeks something like 302 would be more accurate? Or perhaps we could use something like my days in year calculator from here:
https://www.prorealcode.com/topic/how-many-bars-in-a-year-indicator/
01/07/2021 at 9:23 AM #156712I can’t call the indicator to use it in an algorithm.
Your indicator does not return a value to be used in the strategy – it just draws a segment.
1 user thanked author for this post.
01/07/2021 at 10:57 PM #156826Thank you @Vonasi. I modified the last line of the indicator in several ways:
12345return percd2return percd2 as "SD2"return percd2 as "SD2", to as "0"There has been a change with a line that connects each daily segment.
But on the other hand there is still no result when I run the algorithm.
There is even an error report that is displayed at the end of the backtest regardless of the final line.Do you know how to return the result that will be taken into account by the algorithm?
01/07/2021 at 10:59 PM #156828Line 5 :
1return percd2 as "SD2", 0 as "0" -
AuthorPosts
Find exclusive trading pro-tools on