Trend Following

mittens

Active Member
#1
This is a theoretical thread to learn about Trend Following by mutually helping each other.

Over the time I have learned a few things about Trend Following, I would like to share and also like others to share so that we all can learn more and be better traders.

I am putting my learning's and views, and welcome everyone else to put their views for mutual benefit.
 

mittens

Active Member
#2
Trend Following

Wikipedia explains Trend Following as this :
"Trend following strategy believes that prices tend to move upwards or downwards over time. They try to take advantage of these market trends by observing the current direction and using this to decide whether to buy or sell."

So what we need to do is buy when prices are going up and Sell when prices are going down. So simple yet so difficult.

Here's my approach to finding an answer.
There are many ways of doing the same thing, and I believe each one of them are correct. There are many great people in this forum and each has something to give, we should mix and match everything and then take it all in. Find what works for us. Anything which works is correct :), does not matters what methodology it follows.
Hence I do not say this is the best method, it's just one more method which works for me.
 

mittens

Active Member
#3
Mittens

When I searched the internet for Trend Following, I found this beautiful quote

"Gloves fit individual hands very well.
While mittens do not fit anyone very well, they fit everyone pretty well."
- Ed Seykota

So trying to understand this quote, I looked at various methods to figure out what will be too generic to be called mittens.
Something which cannot be optimized and backfitted, Something which should fit everywhere.
It appears that we need not look further than the price itself, the pivots (as explained by Saint) do fit the price nicely as mittens.
Also, the pivots cannot be changed they are created by the price itself.
Hence I named it mittens :)
 

mittens

Active Member
#4
Price Movement

About price movement, which you all already know, just revisiting.
Prices don’t move in a straight way, they slither like a snake.
So when price has to go up it will go in a zig-zag fashion, doing up / down movement all the way.

Rally : The up movement is called rally.
Decline : The down movement is called decline.

Up Trend : When the Rallies are bigger than Declines, we get a net upward movement.
Down Trend : When the Decline are bigger than Rallies, we get a net downward movement.

 

mittens

Active Member
#5
Finding an Answer

Usually prices trend around 30% of the time, and rest of the time they just oscillate and remain almost directionless.

The extreme points of Rally and Decline are called Higher High, Higher Low or Lower High or Lower Low. But since I learned this from Saint so I also use the same terms Pivot High and Pivot Low.

Let's assume we trade the pivots, for a Long trade we keep using the Pivot Low as Exit and vice versa for Short Trade. The problem occurs when we are in a trend and a small pivot forms ( in sideways congestion ) and takes us out of the trade while continuing the original trend.

So to avoid this, we can use a moving average to choose the pivots which we want to trade. Then take only those pivots which are on the other side of the average.
After looking at various types of averages, I wanted something to have the following behavior.
a) When price moves in one direction quickly then the average should move quickly.
b) When price is in sideways condition, then the average should not move much. Which will avoid the chopping which is death sentence for any moving averages based method.
So looking at all the averages, Found that the average which fits the bill is Kaufman Adaptive Moving Average (KAMA).
We can read more about this here : Stockcharts
 

mittens

Active Member
#6
Putting it all in one place
----------------------------

After putting the KAMA average and the pivots on the chart we get this, but since if we use a fixed period average then we are optimizing it based on that period.
So, to remove the period bias (not completely), I used a combination of periods forming a guppy (https://www.youtube.com/watch?v=LNxxGVuiFvE) like band.
This band I call cloud, and it acts as a dynamic Support/Resistance level. A jump from this level in the direction of the existing trend is a good entry opportunity.



The pivots I am identifying by checking the highest candles in an area and vice versa.
Technically the correct pivots should be identified based on zigzag in amibroker, but since it looks into future and hence I decided to just find based on candles.
But since a pivot is not a candle but a area when the price rests, hence we can not use the pivot based on this code without filtering by an average.

So I divided the pivots in 3 category
a) Minor pivots
b) Major Pivots
c) Mittens

Minor pivots are the pivots which are in the direction of average as the trend, Major ones are in the opposite side of the average.
And mittens are the above all the farthest pivots.

Let me explain
Minor Pivot High : A pivot high which is below the average.
Major Pivot High : A pviot high which is above the average.
Mittens : Major price fluctuations.
 

mittens

Active Member
#7
Setup

Image :


We should have two different timeframes at all times, It will just not work watching only 1 timeframe. To avoid chopping and trading in the trend direction we need two timeframes. Various combinations can be used 1h/5mi, 1h/15min, 30min/5min, 30min/15min, find the one which suits you and the instrument.
 

mittens

Active Member
#8
Trading rules
------------------------------
Entry

The trend is decided based on the mittens channel. The rally and Decline are decided by the cloud (average band).
So when we have up trend and rally on HTF(higher time frame) chart we take long trades on LTF(Lower time frame) chart and vice versa.
Entry Long above a pivot and Short below a pivot (check the trend).

Stop/Exit
a) Initially the Stop is on any nearest pivot ( calculate your MM based on this )
b) When the stops turn into green are Breakeven, we put stops only on major pivots.
c) When major pivots gives a favorable movement, we put stops on Mittens
This way we start with a seed and let it grow to a tree if it wants to, else we cut fast.

We always take a trade entry when it hits the mittens channel, SL nearest pivot.
 

mittens

Active Member
#9
Mittens AFL
----------------------------
It’s a visual AFL, it has nothing automated and I prefer it this way.
Because the best processor in the world is in our head not in a CPU, so get all the information and decide what to do.
You need to understand what you are doing to override the AFL, hence don’t look at it in a mechanical way.
It's more a fuzzy logic method with charts as a decision helper (not decision maker).


_SECTION_BEGIN( "Mittens" );
SetChartOptions( 2, chartWrapTitle );
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Functions - Perry Kaufman Adaptive Moving Average
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function KAMA( series, period )
{
fast = 2 / 3;
slow = 2 / 31;
efficiencyRatio = ( abs( series - Ref( series, -1 * period ) ) ) / ( Sum( abs( series - Ref( series, -1 ) ), period ) );
smoothingConstant = ( efficiencyRatio * ( fast - slow ) + slow ) ^ 2;
return AMA( series, smoothingConstant );
}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// The price plot
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Plot( Close, "Close", colorBlack, styleNoTitle | GetPriceStyle(), Null, Null, Null );


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Pivots
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
pivotBars = 3;
start = Max( BarCount - 503, 5 );
pivotHigh = Null;
pivotLow = Null;
line = Null;
for ( barNumber = start;barNumber < BarCount - pivotBars;barNumber++ )
{
i = pivotBars;
lowCount = 0;
highCount = 0;
while ( i > 0 )
{
if ( Low[barNumber] <= Low[barNumber-i] && Low[barNumber] <= Low[barNumber+i] )
lowCount++;
if ( High[barNumber] >= High[barNumber-i] && High[barNumber] >= High[barNumber+i] )
highCount++;
i--;
}

if ( lowCount == pivotBars )
{
pivotLow[barNumber] = Low[barNumber];
line = LineArray( barNumber - pivotBars, pivotLow[barNumber], barNumber + pivotBars, pivotLow[barNumber], 0 );
Plot( line, "", colorDarkYellow, styleNoLabel | styleDashed | styleNoRescale, Null, Null, pivotBars, -3 );
}
else
pivotLow[barNumber] = pivotLow[barNumber-1];

if ( highCount == pivotBars )
{
pivotHigh[barNumber] = High[barNumber];
line = LineArray( barNumber - pivotBars, pivotHigh[barNumber], barNumber + pivotBars, pivotHigh[barNumber], 0 );
Plot( line, "", colorDarkYellow, styleNoLabel | styleDashed | styleNoRescale, Null, Null, pivotBars, -3 );
}
else
pivotHigh[barNumber] = pivotHigh[barNumber-1];
}
// Removing Inside pivots
for ( barNumber = start;barNumber < BarCount - pivotBars;barNumber++ )
{
if ( pivotHigh[barNumber] < pivotHigh[barNumber-1] )
{
for ( count = barNumber + 1;count < BarCount;count++ )
{
if ( High[count] < pivotLow[barNumber-1] )
count = BarCount;
else
pivotHigh[barNumber] = pivotHigh[barNumber-1];
}
}
if ( pivotLow[barNumber] > pivotLow[barNumber-1] )
{
for ( count = barNumber + 1;count < BarCount;count++ )
{
if ( Low[count] > pivotHigh[barNumber-1] )
count = BarCount;
else
pivotLow[barNumber] = pivotLow[barNumber-1];
}
}
}
pivotHigh = Ceil( Ref( pivotHigh, -1 * pivotBars - 1 ) );
pivotLow = Floor( Ref( pivotLow, -1 * pivotBars - 1 ) );
Plot( pivotHigh, "", colorTan, styleNoRescale | styleStaircase, Null, Null, Null, -2 );
Plot( pivotLow, "", colorTan, styleNoRescale | styleStaircase, Null, Null, Null, -2 );


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Cloud
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
startPeriod = Param("Period", 17, 7, 251, 1);
endPeriod = startPeriod + 4;
colorFactor = 255 / ( endPeriod - startPeriod );
a1 = KAMA( Close, startPeriod );
a2 = KAMA( Close, startPeriod + 1 );
a3 = KAMA( Close, startPeriod + 2 );
a4 = KAMA( Close, startPeriod + 3 );
a5 = KAMA( Close, startPeriod + 4 );
cloudTop = Max( a1, Max( a2, Max( a3, Max( a4, a5))));
cloudBottom = Min( a1, Min( a2, Min( a3, Min( a4, a5))));
side = IIf( a1 > a2 AND Ref( a1 > a2, 1 ), 1, 0.73 );
PlotOHLC( a1, a1, a2, a2, "", ColorHSB( colorFactor * 1, 83, 255 * side ), styleCloud | styleNoLabel | styleNoRescale, Null, Null, Null, -4 );
side = IIf( a2 > a3 AND Ref( a2 > a3, 1 ), 1, 0.73 );
PlotOHLC( a2, a2, a3, a3, "", ColorHSB( colorFactor * 2, 83, 255 * side ), styleCloud | styleNoLabel | styleNoRescale, Null, Null, Null, -4 );
side = IIf( a3 > a4 AND Ref( a3 > a4, 1 ), 1, 0.73 );
PlotOHLC( a3, a3, a4, a4, "", ColorHSB( colorFactor * 3, 83, 255 * side ), styleCloud | styleNoLabel | styleNoRescale, Null, Null, Null, -4 );
side = IIf( a4 > a5 AND Ref( a4 > a5, 1 ), 1, 0.73 );
PlotOHLC( a4, a4, a5, a5, "", ColorHSB( colorFactor * 4, 83, 255 * side ), styleCloud | styleNoLabel | styleNoRescale, Null, Null, Null, -4 );



////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// The Title
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
candleColor = SelectedValue( IIf( Close < Open, colorRed, colorDarkGreen ) );
_N( Title = StrFormat( "Mittens : " + Name() + ", {{INTERVAL}}, {{DATE}}, "
+ StrExtract( "SUNDAY,MONDAY,TUESDAY,WEDNESDAY,THURSDAY,FRIDAY,SATURDAY", SelectedValue( DayOfWeek() ) )
+ EncodeColor( -1 ) + "\nOpen %g, High %g, Low %g, "
+ EncodeColor( candleColor ) + "Close %g,"
+ EncodeColor( -1 ) + "\n{{VALUES}}"
, Open, High, Low, Close
) );
_SECTION_END();
 

mittens

Active Member
#10
As with any trading methodology MM (Money management) is the most important thing.
Trade management and Money management is what differentiates traders.
As with the turtles trading the same method and same markets the results were vastly different.

Always trade along the trend, never against it.

Say 1H trends is down, and we get a Long trade on 5min, with a trend change on 5min. We will take the trade with half the quantity and look to add the other half at next pivot or around the place 1H will also change trend to the upside.
 

Similar threads