balance

Trends indicator

Category: Indicators By: balance Created: May 21, 2017, 7:47 PM
May 21, 2017, 7:47 PM
Indicators
1 Comment
Trends indicator

Hi,
This is my first development.
And I’m happy to share it with you.

This is a simple indicator to identify a trend.
Using the position of the moving averages.

If the short average above the long average = trend increases
But, if the long average above the short average = trend declines.

So far everything is simple,
The idea in this indicator is that it does not tell when the short average began to rise above the long average
But counting the number of candles chosen – and only if during all this time they are still arranged in the same order – he will signal.

Reading the signals:
0 = No trend
1 = upward trend
1 = downward trend

The following data is subject to change:
– Number of candles in the short average.
– The number of candles of the long average.
– Number of candles that the indicator will count (before the signal).

I personally think of using it as a database for scanning.
But it can also be used for other things …

I’m happy to share this with everyone. Because I believe that in this way we can all contribute to each other for progress and success.

Note: I’d love to get ideas for improving …

//Indicator for trend identification (based on position of moving averages)
//Editor - balance.
//21/05/2017


count1 = 0
count2=0
upcount=0
downcount=0

lma = Average[longma](close)
sma = Average[shortma](close)

increase = sma>lma
decrease=lma>sma

while (increase[count1]) do
 upcount =upcount  +1
 count1=count1+1
wend

while (decrease[count2]) do
 count2 = count2+1
 downcount=downcount-1
wend

UPtrend = upcount > unitsforthetrend
DOWNtrend= downcount < -unitsforthetrend

v=0

if (uptrend)then
 v=1
elsif (downtrend)then
 v=-1
else
 v=0
endif

a=0

return v coloured(0,0,0)as "trend line",a coloured(255,0,0)as "zero line"

Download
Filename: Trends-Indicator.itf
Downloads: 453
balance
balance Junior
As an architect of digital worlds, my own description remains a mystery. Think of me as an undeclared variable, existing somewhere in the code.
Author’s Profile

Comments

David
9 years ago
#

Balance thanks for sharing this excellent indicator. 

Here are some thoughts.

  1.  please add comments to code (many people here are not coders and would greatly benefit from comments to understand and learn learn from you)
  2. reviewing the indicator visually It seems to be reasonable at picking a change to the trend but of course we are dealing with historic data so it's lagging and will always be. In my reading people suggest weighting the newer data over the older data - something to consider. 
  3. generally there are 3 states in the market (1) UPTREND, (2) DOWNTREND and (3) SIDEWAYS/consolidation/lack of trend. Within those states there is HIGH/AVERAGE/LOW volatility but let's leave that for now. 

Is there a way to include (3) sideways/consolidation/lack of trend? = 0 

Also: 1 and -1 is a great start but almost too black and white. We need to know how strong the trend actually is 10/-10 = very strong to 0 no trend - how could we do this?

ProRealCode ProRealCode
Loading...