Impulse |
Post Reply | Page <12 |
Author | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
maximo
BullCharts Guru Joined: 02 Sep 2006 Location: Australia Posts: 232 |
Post Options Quote Reply Posted: 16 May 2010 at 3:42pm | |||||||||||||||||||||||||||||||||||||||||||||||||||||
Here is the Rate of Change indicator for it.
[Description ="Rate of Change of EMA"]EMA := input("EMA period", 13, 1, 40);[color =lime green]roc (ma(C,EMA,E),1,%) * (0.0048*EMA) * Close;[color =gray]0; Edited by maximo - 16 May 2010 at 4:48pm |
||||||||||||||||||||||||||||||||||||||||||||||||||||||
maximo
BullCharts Guru Joined: 02 Sep 2006 Location: Australia Posts: 232 |
Post Options Quote Reply Posted: 16 May 2010 at 5:20pm | |||||||||||||||||||||||||||||||||||||||||||||||||||||
{ MACD indicator with histogram } [description ="One of the simplest and most reliable indicators, MACD uses 2 moving averages.compares two moving averages of prices, with 9 day Exponential Moving average as a signal." ][target =Default; category=Moving Average; dp=4][horzline =0]n1 := input("Short moving average",12,1);n2 := input("Long moving average",26,1);ns := input("Signal periods",9,1);{Note: The true MACD is not quite a 12 & 26 exponential moving average } r1 := 2/(n1+1); r2 := 2/(n2+1); ma12 := C*r1 + previous(C)*(1-r1);ma26 := C*r2 + previous(C)*(1-r2);res := wait(ma12 - ma26,25);signal := ma(res,ns,E);[Name =MACD; color=dodger blue]res; [name =Signal; linestyle=solid; color=red]signal; [Name =Histogram; linestyle=Histogram; color=black]histogram:=res - signal; histogram; |
||||||||||||||||||||||||||||||||||||||||||||||||||||||
Bana
Regular Joined: 02 Jan 2007 Location: Australia Posts: 46 |
Post Options Quote Reply Posted: 16 May 2010 at 9:58pm | |||||||||||||||||||||||||||||||||||||||||||||||||||||
Maximo, I really appreciate the great effort you have put above. But we are not there yet.
I promised the mathematical representation, so here it goes - Below is the weekly data of XKO - last 6 weeks shown and 1 future forecast (last line).
I have calculated the weekly values of 12 period EMA, the MACDH (12,26,9) and the impulse, on a spreadsheet. The last column shows the price % move for the week. I have cross-checked all values against bullcharts to ensure they are accurate.
Say I want to trade on the long side but rules dont allow me to enter when impluse is bearish. The impulse for last week (20100510) is bearish and the MACDH value is -39.503.
For the impulse to stop being bearish, the MACDH has to reverse direction by at least 1 point (primary condition). I want to know at what minimum price this will happen. Since MACDH is a direct derivation of price, I should be able to forecast this with mathematical precision. Microsoft excel has a great function called "goal seek". I used this function to derive value of -39.502 for MACDH , by recalculating the price. It popped the answer = 4663.760.
At this price the MACDH will have risen by at least 1 point, thus terminating the bearish condition (so as to speak in terms of the indicator). Whether the impulse will become neutral or bullish, is secondary because my key concern is cessation of bearish impluse.
Now if i were to trade this under impulse system, I know I have to wait for the price to rise 1.26% to at least 4663.76 to go long.
Based on the spreadsheet formulas, the forecast 12 period EMA on this price is also calculated (secondary condition). Now I can determine that at a close of 4663.76 would EMA rise or decline. In this case, the answer is 'decline', so the forecast impluse is neutral.
Can this be achieved in bullscript?
cheers
Bana
PS: please substitute 'price' with 'close' when reading the above.
Edited by Bana - 17 May 2010 at 9:51am |
||||||||||||||||||||||||||||||||||||||||||||||||||||||
maximo
BullCharts Guru Joined: 02 Sep 2006 Location: Australia Posts: 232 |
Post Options Quote Reply Posted: 18 May 2010 at 5:44am | |||||||||||||||||||||||||||||||||||||||||||||||||||||
Here's a MACDH on price indicator to see where price must close in order to maintain or change impulse.
[target =price][description =MACDH impulse on price, Max][color =dodger blue; category=Momentum; linestyle=solid]mdha := (( ma(C,12,E)-ma(C,26,E)) - ma(ma(C,12,E)-ma(C,26,E),9,E));[color =dodger blue]if (C<100,C - ((mdha-ref(mdha,-1))*0.48*C),if(C<1000,C - ((mdha-ref(mdha,-1))*0.048*C),C - ((mdha-ref(mdha,-1))*0.0018*C)));This is the oscillator of the above to measure how much the price must change in dollars & cents or points in order to maintain or change impulse.
[description =MACDH impulse point change, Max][color =dodger blue; category=Momentum; linestyle=solid]mdm := (( ma(C,12,E)-ma(C,26,E)) - ma(ma(C,12,E)-ma(C,26,E),9,E));[color =indian red]if (C<100,(mdm-ref(mdm,-1))*0.48*C,if(C<1000,(mdm-ref(mdm,-1))*0.048*C,(mdm-ref(mdm,-1))*0.0018*C));[color =gray]0; Edited by maximo - 18 May 2010 at 8:15pm |
||||||||||||||||||||||||||||||||||||||||||||||||||||||
Bana
Regular Joined: 02 Jan 2007 Location: Australia Posts: 46 |
Post Options Quote Reply Posted: 18 May 2010 at 4:22pm | |||||||||||||||||||||||||||||||||||||||||||||||||||||
Its definately getting warmer (and the oscillator is cool), but still some piece is missing. I found quite a few instances of impulse change not complying with the above indicator. Some example of different type of impulse changes are:
Non-conforming bars following signal of:
19/04/10 - neutral to bear
08/02/10 - bear to neutral
06/07/09 - bear to bull
16/03/09 - neutral to bull
03/12/07 - bull to bear
I will look through in detail to see if there is anything common in these non-compliant bars.
By the way, what is the purpose of the different % of '48' you have used in above formula?
Edited by Bana - 18 May 2010 at 4:30pm |
||||||||||||||||||||||||||||||||||||||||||||||||||||||
maximo
BullCharts Guru Joined: 02 Sep 2006 Location: Australia Posts: 232 |
Post Options Quote Reply Posted: 18 May 2010 at 7:49pm | |||||||||||||||||||||||||||||||||||||||||||||||||||||
I have made an adjustment to those indicators and reposted them. The Change of angle percentage 0.48 value needed to be smaller for indicies for example, XKO. Due to the extra digits of precision required. The number is a factor of change in the angle of the MACD histogram. Rather simple %change without factoring in any momentum. However you'll often see that the line needs to be projected/extended forward from its current angle onto the next future bar. This is where momentum from the previous few bars needs to be accounted for.
Edited by maximo - 18 May 2010 at 10:38pm |
||||||||||||||||||||||||||||||||||||||||||||||||||||||
Bana
Regular Joined: 02 Jan 2007 Location: Australia Posts: 46 |
Post Options Quote Reply Posted: 18 May 2010 at 10:51pm | |||||||||||||||||||||||||||||||||||||||||||||||||||||
Its getting hot in here............. Hats off to Maximo. I have found no exceptions for following the impulse transitions - bear -> bull
bear -> neutral bull -> bear
bull -> neutral
Exception - Some neutral impulse dont confirm the indicator (some examples 29/7/02, 05/08/02, 05/05/03 five bars, 15/02/10 etc). This happened only where the EMA (second ingredient of impluse) did not confirm the MACDH direction.
However, for the purpose of using this indicator, this exception is not consequential, because once entered I am happy to stay in a neutral zone. Impulse is not a stand alone trading system. Its just an entry criteria. I would have my overall trading strategy guiding the trade management.
Cheers Max....you have done it again!!!!!!
Edited by Bana - 18 May 2010 at 10:53pm |
||||||||||||||||||||||||||||||||||||||||||||||||||||||
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 |