Forex
Google
New signals service!

Go Back   Forex Trading > Discussion Areas > Metatrader 4


Register in Forex TSD!
Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time).
Click here to register and get more information

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-01-2007, 04:43 PM
Member
 
Join Date: Dec 2006
Location: Minnesota, USA
Posts: 84
mrebersv is on a distinguished road
MA Angle Indicator help

I'm trying to create an indicator that is based on the angles of a few moving averages. I figured that since this has been done before that I'll start by recreating a previously made indicator to make sure I'm doing this correctly, then modify the code after that.

The indicator I chose to clone is the Sidewinder (SideWinder for CCI: My first release). The code for this indicator as I can understand it is by adding the angle (in degrees) of the LSMA25 and the EMA34 of a given chart. If the sum is greater than 100, the sidewinder is represented by a green block. If the sum is 75 to 100, it's yellow. Less than 75 is red.

Since the angle is simply the arctangent of the slope, and based on what I (think?) I remember reading something in the link above about the slope being taken only from the last two bars of the MA in the sidewinder. Since the slope is simply the change in the y-axis divided by the change in x-axis, I'm computing slope by subtracting the old bar's close from the new bar's close (and divide by one since it's only one timeframe apart, but that doesn't need to actually be computed since it doesn't affect the number). This gives me the slope of the MA. I then use the MathArctan() function with my newly-found slope value and that returns the angle of the slope in radians. A simply conversion (multiply by 180/pi) and we have the angle in degrees.

Unfortunately, I'm doing something wrong and can't figure out what the hell it is. It might be in the way I'm going about this (in which case the error could be found in the previous few paragraphs). It might be the way I'm implementing the code (which is found below). Any help or guidance would be greatly appreciated.
Code:
   double lsma25 = LSMA(25,1);
   double oldLsma = LSMA(25,2);
   double slopeLsma = (lsma25/oldLsma)*1000;
   double angleLsma = MathArctan(slopeLsma)*(180.0/3.14159);
      
   double ema34 = iMA(NULL,0,34,0,MODE_EMA,PRICE_CLOSE,1);
   double oldEma = iMA(NULL,0,34,0,MODE_EMA,PRICE_CLOSE,2);
   double slopeEma = (ema34/oldEma)*1000;
   double angleEma = MathArctan(slopeEma)*(180.0/3.14159);
   
   double sidewinderValue = angleLsma + angleEma;
The function LSMA() takes two values, the number of periods and the shift from the current bar (it uses the Close of a bar). So, the function call "LSMA(25,1)" returns the 25-period LSMA with the final bar being the bar before the current bar (the final complete bar).

I don't know if I'm missing any important information, so if anyone needs any more information just post what you need and I'll get you what I can do. I really appreciate any help you guys can give me.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 09-04-2007, 11:52 AM
Junior Member
 
Join Date: Oct 2006
Posts: 23
Jagg is on a distinguished road
Did you finish your sidewinder indicator?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 09-05-2007, 03:22 AM
ralph.ronnquist's Avatar
Senior Member
 
Join Date: Oct 2006
Posts: 280
ralph.ronnquist is on a distinguished road
The slope would be obtained by subtraction and not division....

PHP Code:
double lsma25 LSMA(25,1);
double oldLsma LSMA(25,2);
double slopeLsma lsma25 oldLsma
etc. I'm not sure about the "angle", since that depends on aspect ratio. But slopeLsma in the above is the derivative or "direction" of the movement.

Personally I would look back a bit more than one bar, like 5 or 10 bars, in order to reduce the brittleness of the logic; the 1-bar delta tends to hover around 0 a bit when the line turns, whereas, say, the 10-bar delta moves more distinctly through 0. As you may know, with any N-bar delta, you find the actual turning point in middle between the pair where the delta changes sign.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old Today, 09:06 AM
Junior Member
 
Join Date: Sep 2008
Posts: 2
mikelina is on a distinguished road
Slope calculation

When you want to calculate the slope of the MA in the code you present, you divide instead of substracting. In my opinion the slope should be slope=lsma-oldlsma instead of slope=lsma/oldlsma
Try the calculation I propose and inform us.

mikelina
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Ema Angle Zero forexts Indicators - Metatrader 4 16 Today 09:29 AM
LSMA and EMA with angle ? frantacech Indicators - Metatrader 4 12 07-09-2007 10:02 PM
Request: JMA Angle Histogram camisa Metatrader 4 5 12-22-2005 01:02 PM


All times are GMT. The time now is 04:02 PM.



Search Engine Friendly URLs by vBSEO 3.2.0 ©2008, Crawlability, Inc.