Thread: Oscillators
View Single Post
  #6 (permalink)  
Old 09-22-2008, 12:30 AM
Linuxser's Avatar
Linuxser Linuxser is offline
User Root
 
Join Date: May 2006
Location: Helliconia (Winter)
Posts: 4,410
Blog Entries: 56
Linuxser has a reputation beyond reputeLinuxser has a reputation beyond reputeLinuxser has a reputation beyond reputeLinuxser has a reputation beyond reputeLinuxser has a reputation beyond reputeLinuxser has a reputation beyond reputeLinuxser has a reputation beyond reputeLinuxser has a reputation beyond reputeLinuxser has a reputation beyond reputeLinuxser has a reputation beyond reputeLinuxser has a reputation beyond repute
Quote:
Originally Posted by MrM View Post
Here is the code for what I meant to do.

It plots the difference between the price and a moving average as an oscillator. It looks very similar to an RSI...

//+------------------------------------------------------------------+
//| MApricediff.mq4 |
//| Copyright © 2008, MetaQuotes Software Corp.|
//| Forex Trading Software: Forex Trading Platform MetaTrader 4 |
//+------------------------------------------------------------------+

// indicator based MAdistance.mq4 by Tim Hyder aka Hiachiever
// http://www.forex-tsd.com/blogs/newdi...ce-itself.html

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Black

#property indicator_level1 0

extern int MA.Period = 10;
extern int MA.Method = MODE_SMA;
extern int MA.Price = PRICE_CLOSE;
extern int MA_Shift=0;
extern bool UseTickdata = True;
double diff[];

int init()
{
IndicatorBuffers(1);
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,diff);
return(0);
}


int start()
{
int MA.Shift = 1;
if(UseTickdata) MA.Shift = 0;

for( int i = Bars - IndicatorCounted() - 1; i >= MA.Shift; i-- )
{
double MA = iMA(Symbol(),Period(),MA.Period, 0, MA.Method, MA.Price, i);
diff[ i ] = (Close[i] - MA)/Point;
}
return(0);
}
This is far away from RSI calculation. This indicator its doing just what you said on previous post.

You said: Ok, maybe the most simple oscillator would be the price (close) - the moving average (close) over N periods.

So, set MACD to Fast 1 on and Slow to what you like. Signal to 1. And you have it.

Btw:

RSI = 100-(100/(1+U/D))
Where:
U — is the average number of positive price changes;
D — is the average number of negative price changes.
Reply With Quote