![]() |
deviation to moving average |
Post Reply ![]() |
Page 12> |
Author | |
john ![]() Newbie ![]() Joined: 18 Aug 2005 Posts: 7 |
![]() ![]() ![]() ![]() Posted: 30 Aug 2005 at 10:57pm |
thanks pipsqueek i will see what your coding gives me. used with indices, chart two can give early warning signals. regards, John
|
|
![]() |
|
pipsqueek ![]() Regular ![]() Joined: 03 Jan 2005 Location: Australia Posts: 34 |
![]() ![]() ![]() ![]() |
HI John, Try this for chart2 pd:=input("moving average period",20,1,250); Devo:=(close-ma(c,pd,e))/ma(c,pd,e)*100; {or Devo:=(close/ma(c,pd,e)-1)*100 is exactly the same thing} NormDevo:=sum(Devo,pd)/pd; (Devo - NormDevo)*100 Looks like I've just calculated the difference between (the %deviation of the close from its moving average) and (the average of this deviation). Multiplied by 100 to give a bigger number. If you don't multply by 100, then you can plot your chart1 and chart2 in the same pane as their scales will be the same. They have the same basic shape. Not quite sure what this is all about John, but hope it does what you wanted. Pipsqueek
|
|
failing to plan is planning to fail.
|
|
![]() |
|
john ![]() Newbie ![]() Joined: 18 Aug 2005 Posts: 7 |
![]() ![]() ![]() ![]() |
G'Day Pipsqueek, Thanks for persisting... -------------------- Is the "Devo" you refer to equal to the percentage deviation of the close from the moving average?? I'm guessing that it is. Correct? ->Yep What do you mean by "NormDevo"? -> Norm meaning normalisation. NormDevo is the average of Devo for the Period. You are using 2 period references in "Chart two" ... one is the period for summing the "Devo data points" and the other is the period for "NormDevo". Do you want these periods to be the same as the period you used in Chart1 or are they different? The period remains constant across all calculations. The Period is equal to the reference i. So in the last part of chart two calcs we are subtracting the average Devo from Devo. Hope this is clearer. Thanks, John |
|
![]() |
|
pipsqueek ![]() Regular ![]() Joined: 03 Jan 2005 Location: Australia Posts: 34 |
![]() ![]() ![]() ![]() |
John I'm a bit confused here .... Is the "Devo" you refer to equal to the percentage deviation of the close from the moving average?? I'm guessing that it is. Correct? What do you mean by "NormDevo"? You are using 2 period references in "Chart two" ... one is the period for summing the "Devo data points" and the other is the period for "NormDevo". Do you want these periods to be the same as the period you used in Chart1 or are they different? Regards, Pipsqueek |
|
failing to plan is planning to fail.
|
|
![]() |
|
john ![]() Newbie ![]() Joined: 18 Aug 2005 Posts: 7 |
![]() ![]() ![]() ![]() |
Thanks for your valuable posts pipsqueek and cobra. I have been able to use a hybrid between both suggestions to get my first chart. There was one other chart. Great if you could help me get this one. Thanks guys, John REFERENCES: |
|
![]() |
|
pipsqueek ![]() Regular ![]() Joined: 03 Jan 2005 Location: Australia Posts: 34 |
![]() ![]() ![]() ![]() |
Hi John Yep, you are right. What I suggested should plot the difference between the close and the moving average. If the close is above the moving average then this difference is positive, if the close is below the moving average then the differnce is negative. I see your point about wanting to display this difference as a percentage. Makes comparisons easier. Try this [target =default]pd:= input("moving average period",20,1,250);( close-ma(c,pd,e))/ma(c,pd,e)*100;The difference between the close and the moving average has been expressed as a percentage of the moving average. Plonk the indicator into a new pane (it will go there anyway by default) and add a horizontal line at x = 0 if you wish. When the indicator is zero, then the close and the moving average are equal. Regards, pipsqueek |
|
failing to plan is planning to fail.
|
|
![]() |
|
Cobra ![]() Regular ![]() ![]() Joined: 08 Nov 2004 Location: Australia Posts: 76 |
![]() ![]() ![]() ![]() |
John,
I use this basic script for deviation from 200 day moving average - [target=price] [horzlines=1] C/(sum(C,200)/200) Save as a indicator then add it to a new pane. Any use?. Let me know if you find a way of displaying the scale in percent, I'm sure there would be a way, I just haven't had time to look into it. One problem I find with this indicator is that each stock is different, as to what constitutes a large deviation away from the average and hence a buy or sell signal, from a scan viewpoint. If the divergence from 1 could be converted into a percentage it may be more meaningful??. |
|
BullCharts version:3.4.1.28129
Windows XP SP2 |
|
![]() |
|
john ![]() Newbie ![]() Joined: 18 Aug 2005 Posts: 7 |
![]() ![]() ![]() ![]() |
Pipsqueek, This shoul be plotting the difference (above or below) between the price and the ma value. is that what its doing? John |
|
![]() |
|
john ![]() Newbie ![]() Joined: 18 Aug 2005 Posts: 7 |
![]() ![]() ![]() ![]() |
Thanks Pip, Got close there. An input function would work well. I don't know how to display the scale as a %. Regards, John |
|
![]() |
|
pipsqueek ![]() Regular ![]() Joined: 03 Jan 2005 Location: Australia Posts: 34 |
![]() ![]() ![]() ![]() |
Hi John What kind of deviations from the moving average? Are you just talking about the actual distance of the close from a moving average? Or something a bit more exotic? If its the former, then wouldn't you just do something like... close-ma(c,20,e); 0; You could use an input function to allow you to change the moving average period as you apply the indicator. Don't know if this what you were after .... Pipsqueek
|
|
failing to plan is planning to fail.
|
|
![]() |
Post Reply ![]() |
Page 12> |
Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |