PureBytes Links
Trading Reference Links
|
I found this code in the TASC articles in the member section. I was trying to add some code to be able to run an explore to possible divergences. When I plot the indicator it seems to be correct but in the columns both conditions show true. It is a simple code mistake but at the moment it escapes me why. Can anyone point out the obvious to me?
Thanks
DM
/*TWO-POINT PROBLEM OF THE RATE OF CHANGE
In the "Two-point problem of the Rate Of Change" article Martti Luoma AND Jussi Nikkinen
present the modification of classic ROC indicator that can be constructed two ways in AmiBroker.
First way does NOT require writing any single line of code. You can construct ROCadj AND other
indicators using AmiBroker's powerful drag AND drop technology. To create ROCadj, select Chart tab,
go to Indicators folder, double click on ROC - Rate Of Change - this will create new chart pane with ROC.
Then go to Averages folder, click AND drag EMA - Exponential Moving Average onto ROC chart.
Your indicator is ready. Now simply adjust ROC period to 1 AND EMA smoothing period to 21 using
Parameters window. Second way is to use the formula presented in Listing 1. Just type it into
Formula Editor AND press Insert Chart button.
*/
periods = Param("Periods", 21, 2, 200, 1 );
ROCadj = periods * EMA( ROC( C, 1 ), periods );
/*Added Divergence to original formula*/
RocSlope=LinRegSlope(ROC(C,periods),periods);
MARocSlope=LinRegSlope(ROCadj,periods);
PosDiv=MARocSlope>=RocSlope;
NegDiv=MARocSlope<RocSlope;
//Plots
Plot( ROCadj, "ROCadj "+periods, colorRed, styleThick );
// the line below adds standard ROC overlay
Plot( ROC( C, periods ), "ROC "+periods, colorBlue );
Plot(PosDiv,"Positive",colorLime,styleOwnScale);
Plot(NegDiv,"Positive",colorRed,styleOwnScale);
IIf(PosDiv>0,AddTextColumn("Positive","Positive Divergence",1.2,colorLime),0);
IIf(NegDiv>0,AddTextColumn("Negative","Negative Divergence",1.2,colorRed),0);
Filter=1;
------------------------------------
**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.
TO GET TECHNICAL SUPPORT send an e-mail directly to
SUPPORT {at} amibroker.com
TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)
For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/amibroker/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/amibroker/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:amibroker-digest@xxxxxxxxxxxxxxx
mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx
<*> To unsubscribe from this group, send an email to:
amibroker-unsubscribe@xxxxxxxxxxxxxxx
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|