Print Page | Close Window

Impulse

Printed From: BullCharts Forum
Category: BullCharts
Forum Name: BullScript
Forum Discription: Technical discussion related specifically to the BullScript programming language.
URL: http://www.bullcharts.com.au/forum/forum_posts.asp?TID=647
Printed Date: 20 May 2024 at 6:47am
Software Version: Web Wiz Forums 9.69 - http://www.webwizforums.com


Topic: Impulse
Posted By: Bana
Subject: Impulse
Date Posted: 11 May 2010 at 4:57pm

I have been using Dr Alexander Elder trading strategy (triple screen) using the impulse indicator and channels (“Come into my Trading Room”).

 

The entry point (3rd screen) is defined by the impulse indicator.

 

Background of impulse indicator

1. When the moving average and the MACDH are both ticking up, it indicates bullish momentum. The impulse system prescribes that you can go long but it is not advisable to go short.

 

2. When the moving average and the MACDH are both ticking down, it indicates bearish momentum. The impulse system prescribes that you can go short but it is not advisable to go long.

 

3. When the moving average and the MACDH are not in sync, bulls and bears are neutral. Do whatever. 

 

Impulse is included in Bullchart indicators but is not attached to the author (Elder). You can find it under “all indicators’. For visual representation, the price bars are colored for each of the 3 conditions. Eg - bullish (green), bearish (red) and neutral (yellow).

 

Anyway, coming back to my question/problem at hand –

 

I want to be able to figure out the value at which situation 1 and 2 will cease to exist (on any time period – daily or weekly).

 

For example –

 

1. When the moving average and the MACDH are both ticking up, it gives a buy signal. However, how much will the price have to decline for either the moving average or the MACDH to decline instead of rise, which will then negate the green impulse?

 

2. When the moving average and the MACDH are both ticking down, it gives a sell signal. However, how much will the price have to rise for either the moving average or the MACDH to rise instead of decline, which will then negate the red impulse?

 

The ‘forecast’ value of change indicator can be marked by an icon on right side of the last bar.  

 

 

Why I think this will be useful?

 

Say I have done my homework on screen 1 and 2 and found a nice bearish divergence developing which I want to trade. However, the impulse is still green meaning there is still bullish momentum and it might not be the right time to go short yet. However, the green impulse might cease to exist during a trade day but I cant be there watching the screen intra day (screen 3) to enter.

 
If I know in advance at what price I am not prohibited by the impulse system to enter, I can place conditional orders.

 

Same applies for bullish divergence.

 

In situation 3, neutral bar, it is not that important to know the turning point of the impulse since momentum if neutral. There is no prohibition on entering. However, if trend trading, it will be useful to know at what price the MA and MACDH will sync in same direction, confirming the continuation of a trend and hence an entry point.

 
Any help on creating the indicator signal is welcome.
 
Cheers

Bana




Replies:
Posted By: maximo
Date Posted: 12 May 2010 at 5:38pm
Hi Bana,
 
I've created a Rate Of Change indicator to determine how much the price must move in order for the Moving Average to be facing up or down.    The zero line represents the 13 ema as being flat, so I worked out the change from it being flat will give the price value required to change the bar colour.     Now all thats needed is to indicate this on the price bar(s) with marker point(s).
 

[Description="Rate of Change of EMA"]

EMA := input("EMA period", 13, 1, 40);

exponent:= 2/(EMA+1) *.5;

[color=lime green]

roc(ma(C,EMA,E),1,%) * exponent * Close;

[color=gray]

0;



Posted By: maximo
Date Posted: 12 May 2010 at 6:15pm
 
 Apply this modified impulse indicator to chart and the dots on the bars represent the level at which the price needs to close at or above or below in order to change the bar colour. ie. The ‘forecast’ value .
 
Looking at COH the impulse indicator has been changing frequently around the EMA.
 
The last 6 lines are the mod.
 
if you want only the last dot plotted let me know..  it's interesting to see all the dots plotted, because you can see that any Close thats 3/4's of 1 percent either side of the EMA(13) will cause a change of bar colouring. 
 

[description="Elder Impluse."]

[citation="Dr. Elder - Come Into My Trading Room, p.157-162 Copyright (c) 2002, John Bruns and Financial Trading Inc."]

[target=Price; linestyle=PriceColor]

macShort := input("MACD Short MA", 12, 1, 100);

macLong := input("MACD Long MA", 26, 1, 100);

macSmooth := input("MACD Smoothing Period", 9, 1, 100);

EMA := input("Short EMA", 13, 1, 40);

macTime := input("Time Ratio", 1, 1, 22);

macShort2 := macShort*macTime;

macLong2 := macLong*macTime;

macSmooth2 := macSmooth*macTime;

EMA2 := EMA*MacTime;

mac := ma(C,macShort2,E) - ma(C,macLong2,E);

macSig := ma(mac,macSmooth2,E);

macplot:= (mac-macSig);

impulse2 := if(macplot >= hist(macplot, macTime), 1,0) + if(C > ma(C,EMA2,E),1,0)-1;

[color=Blue; name=Zone 1]

impulse2>0;

[color=Red; name=Zone 2]

impulse2<0;

[color=Black; name=Zone 3]

true;

{Come Into My Trading Room page 157-162}

[color=lawn green; linestyle=solid]

ma(C,EMA,E);

{ Plot a dot where price would have to move in order to change bar colour, Max}

exponent:= 2/(EMA+1) *.5;

dot:=roc(ma(C,EMA,E),1,%) * exponent * Close;

[linestyle=points; color=dodger blue]

if(dot < 0 ,C-dot,undefined);

[linestyle=points; color=coral]

if(dot > 0 ,C-dot,undefined);



Posted By: Bana
Date Posted: 13 May 2010 at 10:16am
I just got I one word to say ---- WOW.
 
This is exactly what I need.
 
thanks a ton maximo.
 
I will post some examples of its application in next couple of days.


Posted By: Bana
Date Posted: 13 May 2010 at 2:39pm

Hello Maximo

 

I have hit a stumbling block with the indicator you have created – lets call it the “iforecaster”.

 

It does not appear to be showing the correct values at which the bar will change color. I am having trouble attaching image. So I will try to describe the issue using this indicator on XKO weekly chart as an example.  

  

Week of 10/08/09. Impulse is bullish. The iforecaster shows value of 3844 at which impulse should change color. However, the next bar (17/08/09) changes color to neutral while remaining much above the iforecaster dot value.

 

The bar of 24/08/09 again changes from neutral to bullish with the iforecaster, showing a much lower value.

 

The impulse changes again to neutral and then to bullish in next 2 bars while remaining much above the iforecaster value.

 

I think the reason for this is that iforecaster does not take into account the MACDH movement. In above cases each time the bar turned from bullish to neutral, it was because of MACDH ticking down while MA was still rising.

 

First I thought the above issue related to bars turning to neutral and back. But then I noticed, bar of 11/01/10 which has bullish impluse with iforecaster value of 4682. However, the next bar turns to bearish impluse while remaining above 4682.

 

I know above narration might be confusing. If you can PM me your email id, I can send you my chart.

 

 

The bearish divergence on XKO weekly was confirmed on bar of 19/04/10 which it turned from bullish to neutral. This is an example of a chart where a conditional order can be placed at known value where bullish impulse conditions would cease to exist.  

 

Kind regards

BAna

 

 
 


Posted By: maximo
Date Posted: 13 May 2010 at 10:19pm
Hi Bana,
 
The forcast values are for the red & blue colours only and do not include neutral bars which are neutral because only the MACDH has changed direction and not the small EMA(13).    When both the small EMA(13) changes direction from up to down and the MACDH also changes direction, only then will a bar change colour to either blue or red.   Remember  the bar must also close at or below the predicted value to change as well.  If it touches the predicted value and doesn't close on the opposite side then it will be coloured neutral as per impulse logic.
 
Hope I've cleared it up, I can always PM.
 
Max


Posted By: Bana
Date Posted: 13 May 2010 at 11:08pm
The forcast values are for the red & blue colours only and do not include neutral bars which are neutral because only the MACDH has changed direction and not the small EMA(13).    When both the small EMA(13) changes direction from up to down and the MACDH also changes direction, only then will a bar change colour to either blue or red.
I understand this part and have contemplated on it in my post above. Thanks for confirming it.
 
Can MACDH movements be factored into the formula to forecast the neutral zone. It is quite infrequent that trade turns bullish to bearish (or vice versa) straight away. And when it does, it usually moves far quickly for a decent entry. The neutral zones represent good entry points.
 
Remember  the bar must also close at or below the predicted value to change as well.  If it touches the predicted value and doesn't close on the opposite side then it will be coloured neutral as per impulse logic.
 
This is what I thought is happening. But set the following parameters-
MACDH Short MA - 11
MACDH Long MA - 25
MACD Smooting period - 8
Short EMA - 12
Time ratio - 1
Chart - XKO weekly
 
The bar of 11/01/10 has bullish impluse. The dot value is 4682.674.
Next bar of 18/01/10 turn bearish impluse. However, it closed above the previous bar's dot value of 4682.674. Even the low of 18/01/10 did not cross below the dot value.
 
You will find another pair of bars with similar situation on 03/12/07 and 10/12/07.
 
This is where I got confused about its accuracy.
 
There were 2 instances where impluse turned from bearish to bullish in next bar. Here the forecast dot value seemed correct - 06/07/09 and 23/11/09.
 
cheers
Bana


Posted By: maximo
Date Posted: 14 May 2010 at 1:57pm
I will have a look with those indicator settings.  It seems we are missing something though, like the predicted value is being calculated and displayed from the current bar EMA and it's position will change the very next bar due to recalculation of the EMA with 1 more bar being added.   For example if the trend is rising, the next actual dot would be carried slightly higher, depending on the strength of the trend.  We can't actually see the current dot value either, since it's a predicted value for the next bar.
   I based the predicited value on half the current bars exponent percentage.  A median calculation of this is the best we can achieve, since price can go either way.   You can define the margin of error as half the exponent.   This would be half the distance between a dot and the EMA.  Not a lot, but worth noting that predictions are not certainties.
 
 
Max


Posted By: Bana
Date Posted: 15 May 2010 at 9:16pm
"worth noting that predictions are not certainties"
 
Hello Max
 
Apologies if I have unintentionally conveyed that I am trying to 'predict' price movement. I am not.
 
Since EMA and MACDH are both mathematical derivation of price, it should be a matter of using the same mathematical principle to 'forecast' the likely movement in EMA based on price. Sounds simple when I say it, but I acknowledge it is a complex mathematical problem.
 
I will try to illustrate this by using numerical data in spreadsheets. 
 
Thanks for your time.
 
Cheers
Bana


Posted By: maximo
Date Posted: 16 May 2010 at 3:38pm
G'day Bana
 
I've managed to reduce the margin of error to nearly zero.
The only time a bar remains a neutral colour is when the MACDH is not
confirming the current trend or change of trend.
 

[description="Elder Impulse."]

[citation="Dr. Elder - Come Into My Trading Room, p.157-162 Copyright (c) 2002, John Bruns and Financial Trading Inc."]

[target=Price; linestyle=PriceColor]

macShort := input("MACD Short MA", 12, 1, 100);

macLong := input("MACD Long MA", 26, 1, 100);

macSmooth := input("MACD Smoothing Period", 9, 1, 100);

EMA := input("Short EMA", 13, 1, 40);

macTime := input("Time Ratio", 1, 1, 22);

macShort2 := macShort*macTime;

macLong2 := macLong*macTime;

macSmooth2 := macSmooth*macTime;

EMA2 := EMA*MacTime;

mac := ma(C,macShort2,E) - ma(C,macLong2,E);

macSig := ma(mac,macSmooth2,E);

macplot:= (mac-macSig);

impulse2 := if(macplot >= hist(macplot, macTime), 1,0) + if(C > ma(C,EMA2,E),1,0)-1;

[color=Blue; name=Zone 1]

impulse2>0;

[color=Red; name=Zone 2]

impulse2<0;

[color=Black; name=Zone 3]

true;

{Come Into My Trading Room page 157-162}

[color=lawn green; linestyle=solid]

ma(C,EMA,E);

{ Plot a dot where price would have to move in order to change bar colour, Max}

dota:=roc(ma(C,EMA,E),1,%) * (0.0049*EMA) * Close;

dotd:=roc(ma(C,EMA,E),1,%) * (0.0047*EMA) * Close;

[linestyle=points; color=dodger blue]

if(dota < 0 ,C-dota,undefined);

[linestyle=points; color=coral]

if(dotd > 0 ,C-dotd,undefined);



Posted By: maximo
Date 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;



Posted By: maximo
Date 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;



Posted By: Bana
Date Posted: 16 May 2010 at 9:58pm
Maximo, I really appreciate the great effort you have put above. But we are not there yetCry.
 
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).
 
Date Close MACD12 MACDH IMPULSE MMT%
20100406 4,941.100 4,796.637 6.280 Bullish 0.83%
20100412 4,978.300 4,824.585 10.488 Bullish 0.75%
20100419 4,877.200 4,832.680 5.214 Neutral -2.03%
20100427 4,802.000 4,827.960 -4.086 Bearish -1.54%
20100503 4,474.600 4,773.597 -31.507 Bearish -6.82%
20100510 4,605.900 4,747.797 -39.503 Bearish 2.93%
FORECAST
20100510 4,663.760 4,734.869 -39.502 Neutral 1.26%
 
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.
 


Posted By: maximo
Date 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;



Posted By: Bana
Date 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?
 
 


Posted By: maximo
Date 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.


Posted By: Bana
Date 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!!!!!!
 Thumbs%20Up



Print Page | Close Window

Bulletin Board Software by Web Wiz Forums® version 9.69 - http://www.webwizforums.com
Copyright ©2001-2010 Web Wiz - http://www.webwiz.co.uk