MA yield curve
Forums › ProRealTime English forum › ProBuilder support › MA yield curve
- This topic has 7 replies, 2 voices, and was last updated 7 years ago by viggy.
-
-
06/13/2017 at 10:50 AM #38203
Hello,
I am interested in making a yield curve out of the different MAs. I am having a bit of trouble working out how to draw it, I was thinking points on a line but a historgram would probably be best or a line but I would want it to be uncorrelated to to the time areas.
once ma3= Average[3](Close)once ma5= Average[5](Close)once ma10= Average[10](Close)once ma15= Average[15](Close)once ma30= Average[30](Close)once ma50= Average[50](Close)once ma100= Average[100](Close)once ma200= Average[200](Close)if barindex>0 thenExtMapBuffer3 = close[0] -ma3ExtMapBuffer5 = close[0] -ma5ExtMapBuffer10 = close[0] -ma10ExtMapBuffer15 = close[0] -ma15ExtMapBuffer30 = close[0] -ma30ExtMapBuffer50 = close[0] -ma50ExtMapBuffer100 = close[0] -ma100ExtMapBuffer200 = close[0] -ma200endifDRAWLINE(ExtMapBuffer3,ExtMapBuffer5,ExtMapBuffer10,ExtMapBuffer30,ExtMapBuffer50,ExtMapBuffer100,ExtMapBuffer200) coloured(r,g,b)// error as draw line isnt right, I was thinking a list and a historgram or something like that?Any help would be most appreciated.Kind regards,Vignas06/14/2017 at 8:03 AM #38250I’m not sure to understand your request. You want to draw the points differences between multiple moving average fixed values with the current Close? I count 8 returned buffers to draw, they will be drawn in the past individually from the 8th bar to the current one? Sounds possible but I need to be sure before coding it 🙂
06/14/2017 at 8:15 AM #38252Hi Nicolas,
Sorry for not being clear, I basically was reading trading psychology 2.0 and he mentioned that instead of a yield curve for bond yields, he implements the same idea with moving averages instead of different bond dates. I’ve added a picture of what I mean, if that helps.
Yeah the 8 past bars works well, I wasn’t sure if it was possible. 🙂 I was thinking of doing it in excel but I didn’t think that would be as useful.
06/14/2017 at 8:22 AM #3825506/14/2017 at 8:59 AM #38256This is what I made so far, is it how it should look? We can join the X with segments if you like.
With graphical objects, the auto scale of the window isn’t working, so that’s why you see white dots .. they are there to tell the platform what is the high/low of the scale so it automatically adapt the chart. I don’t know how to make it look better actually… 😐
06/14/2017 at 9:38 AM #38262I think it looks perfect, the line isn’t really necessary and the white dots are barely visible. From what I read, it was only comparing how it moves over time, if it turns into a U bend, its likely to be reversion or ranging where as if its all a lovely straight line/curve, its probably more likely to be a trend.
Be interesting to play around with it and see how it moves 🙂
06/14/2017 at 9:45 AM #38264This is the code, a bit rough one but that do the job 😉
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647defparam drawonlastbaronly=trueif barindex=200 thenma3= Average[3](Close)ma5= Average[5](Close)ma10= Average[10](Close)ma15= Average[15](Close)ma30= Average[30](Close)ma50= Average[50](Close)ma100= Average[100](Close)ma200= Average[200](Close)endifExtMapBuffer3 = close - ma3ExtMapBuffer5 = close - ma5ExtMapBuffer10 = close - ma10ExtMapBuffer15 = close - ma15ExtMapBuffer30 = close - ma30ExtMapBuffer50 = close - ma50ExtMapBuffer100 = close - ma100ExtMapBuffer200 = close - ma200drawtext("●",barindex[8],extmapbuffer3,Dialog,Bold,10)drawtext("●",barindex[7],extmapbuffer5,Dialog,Bold,10)drawtext("●",barindex[6],extmapbuffer10,Dialog,Bold,10)drawtext("●",barindex[5],extmapbuffer15,Dialog,Bold,10)drawtext("●",barindex[4],extmapbuffer30,Dialog,Bold,10)drawtext("●",barindex[3],extmapbuffer50,Dialog,Bold,10)drawtext("●",barindex[2],extmapbuffer100,Dialog,Bold,10)drawtext("●",barindex[1],extmapbuffer200,Dialog,Bold,10)if day<>day[1] and month=currentmonth thenlowscale = ExtMapBuffer3highscale = extmapbuffer200endifdiff=abs(extmapbuffer3-extmapbuffer5)drawtext("MA3",barindex[8],lowscale-diff,Dialog,Bold,10) coloured(200,100,0)drawtext("MA5",barindex[7],lowscale-diff,Dialog,Bold,10)coloured(200,100,0)drawtext("MA10",barindex[6],lowscale-diff,Dialog,Bold,10)coloured(200,100,0)drawtext("MA15",barindex[5],lowscale-diff,Dialog,Bold,10)coloured(200,100,0)drawtext("MA30",barindex[4],lowscale-diff,Dialog,Bold,10)coloured(200,100,0)drawtext("MA50",barindex[3],lowscale-diff,Dialog,Bold,10)coloured(200,100,0)drawtext("MA100",barindex[2],lowscale-diff,Dialog,Bold,10)coloured(200,100,0)drawtext("MA200",barindex[1],lowscale-diff,Dialog,Bold,10)coloured(200,100,0)return lowscale coloured(0,0,0,255) style(point),highscale coloured(0,0,0,255) style(point)06/14/2017 at 10:07 AM #38265 -
AuthorPosts