Welcome to the Traders Laboratory Forums.
Coding Forum Collaborate, receive help, or discuss coding related issues.

Reply
Old 07-03-2009, 03:21 AM   #1

Join Date: Nov 2008
Location: Kialla
Posts: 55
Ignore this user

Thanks: 16
Thanked 1 Time in 1 Post

MA Slope

I am trying to either get hold of code or code myself an MA indicator that changes color depending on the slope of the MA. Say maybe blue for up trending red for downtrending and yellow for flat. I have adjusted the code of an MA to give two colors depending on the plot being > or < than the prior but I am a little stumped on working out exactly how I could achieve the slope measurement that I require.

I have had a bit of a look around and cannot locate where this has been done before. I would have thought someone would have posted one somewhere as the codies out there are very good at this sort of stuff, unlike me. But step by step I guess.

Any ideas?
PeterBrazel is offline  
Reply With Quote
Old 07-03-2009, 08:13 AM   #2

Tams's Avatar

Join Date: Sep 2008
Location: Geelong
Posts: 3,779
Ignore this user

Thanks: 2,084
Thanked 1,474 Times in 912 Posts

Re: MA Slope

if you post what you have tried, maybe someone will chime in...
Tams is offline  
Reply With Quote
Old 07-03-2009, 07:21 PM   #3

Join Date: Nov 2008
Location: Kialla
Posts: 55
Ignore this user

Thanks: 16
Thanked 1 Time in 1 Post

Re: MA Slope

[LegacyColorValue = false];

{************************ *Peter's MA Slope Indicator**************** *****************

This indicator seeks to plot color changes on an MA indicator according to the slope
of an MA.

************************* ************************* ************************* **********}

inputs:
Price( Close ),
Length( 9 ),
Displace( 0 ),
colourDeltaBar(1),
UpColor(blue),
DnColor(red),
NColor(yellow);

variables:
var0( 0 ) ;



Value1 = AverageFC( Price, Length ) ;

Plot1(Value1, "MA Neutral");

{***********Color change criteria*************** }
if (Value1 > Value1[2]) then
SetPlotColor[colourDeltaBar](1, upColor)
else if (Value1 < Value1[2]) then
SetPlotColor[colourDeltaBar](1, dnColor);


if Displace <= 0 then
begin
condition1 = Price crosses over var0 ;
if condition1 then
Alert( "Price crossing over average" )
else
begin
condition1 = Price crosses under var0 ;
if condition1 then
Alert( "Price crossing under average" ) ;
end ;
end;
PeterBrazel is offline  
Reply With Quote
Old 07-03-2009, 07:24 PM   #4

Join Date: Nov 2008
Location: Kialla
Posts: 55
Ignore this user

Thanks: 16
Thanked 1 Time in 1 Post

Re: MA Slope

The above code is a work in progress and currently changes color ONLY dependent on the MA being either > or < the prior close. I would like to change this to make it dependent on the slope of the MA [input].
PeterBrazel is offline  
Reply With Quote
Old 07-03-2009, 07:50 PM   #5

Tams's Avatar

Join Date: Sep 2008
Location: Geelong
Posts: 3,779
Ignore this user

Thanks: 2,084
Thanked 1,474 Times in 912 Posts

Re: MA Slope

how would you like to define the slope?


how do you perceive the color change?

can you post a mock up?

Last edited by Tams; 07-03-2009 at 08:22 PM.
Tams is offline  
Reply With Quote
Old 07-03-2009, 11:20 PM   #6

Join Date: Nov 2008
Location: Kialla
Posts: 55
Ignore this user

Thanks: 16
Thanked 1 Time in 1 Post

Re: MA Slope

An upward sloping MA indicates an uptrend condition.
A downward sloping MA indicates a downtrend condition.
A flat MA indicates an area of congestion.

I think the condition that changes the color would have to be one of percentages, that is unless an angle can be defined.

Having trouble with attachment. Will include in seperate post.

Thanks
PeterBrazel is offline  
Reply With Quote
Old 07-03-2009, 11:53 PM   #7

Tams's Avatar

Join Date: Sep 2008
Location: Geelong
Posts: 3,779
Ignore this user

Thanks: 2,084
Thanked 1,474 Times in 912 Posts

Re: MA Slope

Attached Thumbnails
MA Slope-graph_of_sliding_derivative_line.gif  

Last edited by Tams; 07-04-2009 at 12:05 AM.
Tams is offline  
Reply With Quote
Old 07-04-2009, 12:02 AM   #8

Tams's Avatar

Join Date: Sep 2008
Location: Geelong
Posts: 3,779
Ignore this user

Thanks: 2,084
Thanked 1,474 Times in 912 Posts

Re: MA Slope

Attached Thumbnails
MA Slope-300px-tangent-calculus.svg.png  
Tams is offline  
Reply With Quote

Reply

Thread Tools
Display Modes Help Others By Rating This Thread
Help Others By Rating This Thread:


Similar Threads
Thread Thread Starter Forum Replies Last Post
Determine Slope End or Start januson Technical Analysis 11 11-20-2008 04:39 PM

All times are GMT -4. The time now is 01:25 PM.
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
CS to VB integration by DeskLancer
©2006-2011 Traders Laboratory, All Rights Reserved.