### Stock Portfolio Organizer

The ultimate porfolio management solution.

### WiseTrader Toolbox

**#1** Selling **Amibroker** Plugin featuring:

### Schaff Trend Cycle for Amibroker (AFL)

Code is an Amibroker port of the EasyLanguage TradeStation Schaff Trend Cycle code

Description of indicator and EasyLanguage code can be found here

### Screenshots

### Similar Indicators / Formulas

### Indicator / Formula

/* Ported directly from original STC Tradestation code results differ from other Amibroker versions that are not based directly on original EasyLanguage code http://mediaserver.fxstreet.com/Reports/99afdb5f-d41d-4a2c-802c-f5d787df886c/ebfbf387-4b27-4a0f-848c-039f4ab77c00.pdf */ MA1=23; MA2=50; TCLen=10; MA1=Param("ShortMACDLen",23,5,36); MA2=Param("LOngMACDLen",50,10,100); TCLen=Param("TCLen(StochPeriod)",10,5,20); Factor=.5; //Calculate a MACD Line XMac = MACD(MA1,MA2) ; // MACD in Amibroker always uses Close for MACD calculation //1st Stochastic: Calculate Stochastic of a MACD Value1 = LLV(XMac, TCLen); Value2 = HHV(XMac, TCLen) - Value1; //Frac1=1; // prime Frac1 to a default of 1 //Frac1 = IIf(Value2 > 0, ((XMac - Value1) / Value2) * 100, Ref(FRAC1,-1)); // have to "prime" first value so that reference to "i-1" does not result in subscript out of range // since MACD for both periods is not defined until MA2 period, 0 seems to be mathematically correct priming value frac1=0; for (i = 1; i < BarCount; i++) { if (Value2[i] > 0) { frac1[i] = ((XMac[i] - Value1[i])/Value2[i])*100; } else { frac1[i]= frac1[i-1]; } } //Smoothed calculation for %FastD of MACD PF[0]=frac1[0]; PF[1]=frac1[1]; for (i = 2; i < BarCount; i++) { PF[i]=PF[i-1]+(Factor*(frac1[i]-PF[i-1])); } //2nd Stochastic: Calculate Stochastic of Smoothed Percent FastD, above. Value3 = LLV(PF, TCLen); Value4 = HHV(PF, TCLen) - Value3; //%FastK of PF /* Frac2=1; Frac2 = IIf(Value4 > 0, ((PF - Value3) / Value4) * 100, Ref(FRAC2,-1)); */ frac2[0]=0; for (i = 1; i < BarCount; i++) { if (Value4[i] > 0 ) { frac2[i]=((PF[i] - Value3[i])/Value4[i])*100; } else { frac2[i]=frac2[i-1]; } } //Smoothed calculation for %FastD of PF PFF[0]=frac2[0]; PFF[1]=frac2[1]; for (i = 2; i < BarCount; i++) { PFF[i]=PFF[i-1]+(Factor*(frac2[i]-PFF[i-1])); } Plot(pff,"STLC",colorRed,styleLine); Plot(75,"",colorBlue,styleLine|styleDashed); Plot(25,"",colorYellow,styleLine|styleDashed);

### 7 comments

#### Leave Comment

Please login here to leave a comment.

Back
1.mahesh.aranakeHow to get buy sell signals using this trend cycle

2.administratorHi mahesh please check my post in the forum here

3.chan123This looks like simple but it shows definite trend and is very useful in 5 min. chart. Pls. provide the details about to get buy sell signals using this trend cycle. The link above posted by admin. is not found. chan6123@gmail.com

4.cnbondreHi,

Admin the link is not available.

Would you be kind enough to repost the matter here if possible ?

So it will be a permanent record at this place.

Sorry to bother you,

Regards,

cnbondre

5.administratorHello,

I have re-posted the information in the resources section of the forum.

6.niladriSchaff Trend Cycle (STC) oscillates in between 0 and 100 scale.

The 25 level is called a Buy level, the 75 – a Sell level.

The default settings for STC are (10, 23, 50).

Buy Entry:

1. While indicator stays below the 25 – the downtrend is in progress.

2. Once it crosses up above the 25 level – it’s the first warning of a changing trend:

place a pending Buy order above the corresponding candle on a chart.

3. Wait for the Buy order to be filled. If the order is not filled, and the price continues lower – not a problem. Keep the pending order further while observing Schaff Trend Cycle behavior and new signals.

Opposite true for Sell entries, where the indicator has to cross the 75 level down to send a signal about a trend change setup.

7.niladriHere is a jitter free STC code ( using Weighted Moving average & smoothing ):

/* Schaff Trend Cycle

Schaff is nothing more than a stochastic of a MACD i.e.

X = EMA; // Chose the type of Moving Average

Y = EMA;

XY = X – Y;

LLXY = LLV;

HHXY = HHV;

Schaff = 100 * (XY – LLXY) / (HHXY – LLXY);

*/

SetChartOptions(0,chartShowArrows|chartShowDates);

SetChartBkColor(ParamColor(“Outer panel”,colorDarkOliveGreen));

pdsCy=Param(“Schaff cycle periods”,10,2,40,1);

pdsSh=Param(“Short periods”,23,2,60,1);

pdsLg=Param(“Long periods”,50,2,200,1);

MCD=WMA-WMA; // Using Weighted Moving Average

ST=(MCD-LLV)/(HHV-LLV)*100;

STC=WMA;

Plot(STC,“Schaff Trend Cycle”,colorRed,styleLine|styleThick);

Plot(70,"",colorBlue,1);

Plot(30,"",colorYellow,1);