Stocks&Commodities - Traders Tips

Hello Tomasz,

AFL code examples supporting feature articles in Stocks&Commodities trades tips section have disappeared - in the last two editions (SEP & OCT). Have you stopped publishing AFL code for S&C magazine?
It was very valuable AFL learning tool for me. I used it all the time to study how to code in AFL language.

Kind Regards
RIchard

3 Likes

Here is September one (as it didn't take much time). It's just smoothed Stoch.

// TASC Sep 2018
// Description:     
// Daily & Weekly Stochastics
// by Vitali Apirine
// http://traders.com/Documentation/FEEDbk_docs/2018/09/TradersTips.html#item4
// AFL code suggestion by fxshrat@gmail.com
LengthDay = Param( "Daily Stoch Length", 14, 1, 100, 1);
LengthWeek = Param( "Weekly Stoch Length", 70, 1, 100, 1);
DailyMALength = Param( "Daily MA Length", 3, 1, 100, 1);
WeeklyMALength = Param( "Weekly MA Length", 3, 1, 100, 1);

Smooth_D = MA(StochD(LengthDay, 1, 1), DailyMALength);
Smooth_W = MA(StochD(LengthWeek, 1, 1), WeeklyMALength);

Plot( Smooth_D, "Daily", colorAqua );
Plot( Smooth_W, "Weekly", colorViolet );
PlotGrid( 20, colorGreen );
PlotGrid( 50, colorOrange );
PlotGrid( 80, colorRed );

October one is bit more code...

4 Likes

@richpach in the October article the author refers back to several of his previous articles which have been coded.

https://www.amibroker.com/members/traders/01-2014.html

https://www.amibroker.com/members/traders/05-2018.html

https://www.amibroker.com/members/traders/07-2018.html

What appears to me to be missing (or new) is the code fragment to measure indicator probability distribution for each of the above indicators. This would collect the data into "bins" for export into Excel and creation of the histograms. Although I am pretty sure even the histograms can be created in AmiBroker but require more coding expertise.

I hope the above links can help get those interested started on coding the rest.

5 Likes

Thank @fxshrat and @portfoliobuilder for your reply.
I like John Ehlers and his approach to trading so, I always try to follow up on his articles.
This time however, I have not had time to read Oct issue as yet.
Maybe @portfoliobuilder is right that, is it not going to be too hard to code the rest.

Once I work it out, I will share the code under this post or maybe Tomasz will publish an update on AB website.

Kind Regards
Richard

There will be updates posted later. I had vacation in August when S&C wanted code for the article.

September's code are just built-in stochastics, so actually there is no extra coding required Basics: Fast Stochastics

October code is pretty much yet another tweak of earlier Ehlers' articles.

1 Like

Thank you Tomasz!

I, kind of expected that you are taking advantage of the Polish hot summer in August.

Kind Regards
Richard

There is no official AmiBroker code for the Trader's Tips section of the February 2019 TASC issue.

Here below is my quick adaptation from other systems code:

_SECTION_BEGIN( "SVEStochRSI" );
// Indicator: SVE Stochastic RSI
// Based on the article titled “The V-Trade, Part 6: Technical Analysis—Divergence Indicators.”
// by Sylvain Vervoort in the August 2018 issue of STOCKS & COMMODITIES magazine.
// Adapted from code published in the Trader's Tips - TASC Feb 2019

function sveStochRSI( RSIPeriod, stochLookBack, stochAverage )
{
    local RSIValue,	RSILowest, RSIHighest,
          RSILow, HiLow, AvgRSILow, AvgHiLow;

    RSIValue = RSIa( Close, RSIPeriod ) ;
    RSILowest = LLV( RSIValue, StochLookBack ) ;
    RSIHighest = HHV( RSIValue, StochLookBack ) ;
    RSILow = RSIValue - RSILowest ;
    HiLow = RSIHighest - RSILowest ;
    AvgRSILow = MA( RSILow, StochAverage ) ;
    AvgHiLow = MA( HiLow, StochAverage ) ;

    return( AvgRSILow / ( 0.1 + AvgHiLow ) * 100 );

}

RSILength = Param( "RSI periods", 13, 13, 75, 1 );
StochLength = Param( "Stoch periods", 5, 5, 25, 1 );
StochAvgLength = Param( "Stoch MA periods", 8, 8, 40, 1 );

GraphXSpace = 3;
SVEStochRSIArray = SVEStochRSI( RSILength, StochLength, StochAvgLength ) ;
Plot( SVEStochRSIArray, _DEFAULT_NAME(), ParamColor( "Color", colorOrange ), ParamStyle( "Style", styleThick ) );

// OverBought = 80;
// OverSold = 20;
PlotGrid( 80, colorRed, 2 );
PlotGrid( 20, colorGreen, 2 );
_SECTION_END();

Read the magazine article to understand how to use this oscillator correctly.

Moving in a range between zero and 100, it becomes overbought after reaching 80 and oversold after dropping below 20, but in his article, the author highlights its usage, in particular, as a tool for confirming price reversals based on divergences between price and indicator.

The extra code needed to automatically display such divergences (as shown in some Tips implementations) may be a good exercise for someone that has the spare time to write it.

3 Likes

@beppe thanks for the effort. In terms of looking for AmiBroker codes for divergence, there may be some useful examples listed in this older forum post to help anyone looking to finish coding the article.

1 Like

Hello Tomasz,

AFL code example supporting John Ehlers feature article in Stocks&Commodities August 2019 trades tips section is missing. Is this the same or similar code you posted from Ehlers in the earlier article?
This is very valuable AFL learning tool for me and I like use/test John Ehlers indicators.

Can you please give us some idea when will you have time to post Traders Tips code for S&C August issue?

Kind Regards
RIchard

1 Like

I will add that code to members area soon.

4 Likes

Hi everybody.

Here is my personal interpretation of the article. Results seems similar to the article's plot.
The original article from Henning Voss is interesting, it is available here
https://www.researchgate.net/publication/328943166_A_delayed-feedback_filter_with_negative_group_delay

The claim that the filter is "predictive" is a little bit exagerated (as usual!). Actually, the filter cancels a significant part of the lag generated by the band pass filter.

period = 20;
bw = 0.25;
order = 9;
maxorder = 20;
twopi = 3.141593 * 2;
input = C;

// Initialize filters
filt = C;
voss = filt;

// Band pass filter
f1 = cos( twopi / period );
g1 = cos( bw * twopi / period );
s1 = 1 / g1 - sqrt( 1 / ( g1 * g1 ) - 1 );
b0 = 0.5 * ( 1 - s1 );
b1 = 0;
b2 =  - b0;
a1 = f1 * ( 1 + s1 );
a2 = -s1;

filt = IIR(input, b0, a1, b1, a2, b2);

// Voss filter
for( i = order; i < BarCount; i++ )
{
	sumC = 0;
	for( k = 0; k < order; k++ )
	{
		sumC += ( ( k + 1 ) / order ) * voss[ i - order + k ];
	}
	voss[ i ] = ( ( 3 + order ) / 2 ) * filt[ i ] - sumC;
}
		

Plot(filt, "", colorred );
Plot(voss, "", colorblue );


7 Likes

Hello Waz,

Thank you very much for posting this code. The result does match article example very well.
I am sorry for the late reply. I was out of action due to illness for a while.
I read the original article from Henning Voss (researchgate link - you posted) - I cannot say that I understand it all. However, I agree that, its predictive nature is very difficult to interpret.
Removing "lag" is all we want - right?

Kind Regards
Richard

Hello Richard.

I agree with you but I would say "reducing lag" rather than "removing lag". :slightly_smiling_face: