indicator trend or range

Questions about MultiCharts and user contributed studies.
hendrix
Posts: 54
Joined: 27 Dec 2013
Has thanked: 21 times
Been thanked: 5 times

indicator trend or range

Postby hendrix » 14 May 2014

Hello

I wish compute an indic which shows me if it's a trend market or range market.

By browsing this http://www.abctradinggroup.com/easylang ... rendlines/ I think I could use support and resistance to do that.

example (please look the attachement and my draft below) :

My idea : if the lines (support and resistance) are parallele AND these lines have a horizontal position, then it's a range. Perhaps 0 is too strict, it would be better to use a level of tolerance +/- 5 point or %.

Code: Select all

value1 : resistance[5] - resistance[0] = 0
value2 : support[5] - support[0] = 0

While check 20 last bars if value1 and value 2 then begin,
range market = true
End ;

If range market = true then
indicator = 1

Code: Select all

//extrait from http://www.abctradinggroup.com/

Variables :
DayHigh (high),
DayLow (low);

//reset on a date change
if date <> date[1] then
begin
dayhigh = Highest(high,0) ;
daylow = Lowest (low,0) ;
end ;

//update the variable tracking the highest high
if high > dayhigh then
Dayhigh = High;

//update the variable tracking the lowest low
if low < Daylow then
Daylow = low ;

//plot variables on the chart
Plot1 ( Dayhigh, "DayHigh" ) ;
Plot2 ( Daylow, "Daylow") ;
Anybody could help be to use key words "while" and "for" please?

http://www.multicharts.com/trading-soft ... .php/While
Attachments
exemple.png
(5.74 KiB) Downloaded 319 times

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: indicator trend or range

Postby TJ » 14 May 2014

::
Anybody could help be to use key words "while" and "for" please?

http://www.multicharts.com/trading-soft ... .php/While
Here's my primer:
All About Loops
viewtopic.php?f=16&t=7351

hendrix
Posts: 54
Joined: 27 Dec 2013
Has thanked: 21 times
Been thanked: 5 times

Re: indicator trend or range

Postby hendrix » 14 May 2014

hello TJ

thanks to your answer :)
I have tried to code my idea but finally, I think my idea is not appropriated and too hard to code for me.

So, I have thought to use a adaptative moving average : the slope of the moving average gives me a indication : I consider a range market if it is nearly 0 or ]+0,001] ama [-0,001[

Code: Select all

inputs:
Price( Close ),
EffRatioLength( 10 ),
FastAvgLength( 2 ),
SlowAvgLength( 30 ) ,

Lengthchgmt2 (1) ;

variables:
var1 ( 0 ),
var2 ( 0 );

var1 = AdaptiveMovAvg (price, EffRatioLength, FastAvgLength, SlowAvgLength );
var2 = 1000 * PercentChange( var1, Lengthchgmt2 ) ;

Plot4( var2, "slope");
see u
Attachments
slope.png
(36.61 KiB) Downloaded 336 times


Return to “MultiCharts”