Einzelnen Beitrag anzeigen
  #5 (permalink)  
Alt 25.03.13
feuervogt feuervogt ist offline
Neues Mitglied
 
Registriert seit: Mar 2013
Beiträge: 4
feuervogt befindet sich auf einem aufstrebenden Ast
Standard

Hallo zusammen,

danke für die angebotene Hilfe.

Ich habe es jetzt anders gelöst. In einem anderen Forum (mql4.com) habe ich code gefunden, den ich für mich modifizieren konnte.

Das Zwischenergebnis sieht nun so aus:

Code:
//+------------------------------------------------------------------+
//|                                           Bewegungsindikator.mq4 |
//|                                                   Lustiger Vogel |
//|                                           http://www.irgendwo.de |
//+------------------------------------------------------------------+

#property copyright ""
#property link      ""


#property indicator_separate_window    
#property indicator_buffers 3
#property indicator_minimum 0
#property indicator_maximum 100
#property indicator_level1 90             //Orientierungslinie
#property indicator_level2 80             //Orientierungslinie
#property indicator_level3 70             //Orientierungslinie
#property indicator_level4 30             //Orientierungslinie  
#property indicator_level5 20             //Orientierungslinie
#property indicator_level6 10             //Orientierungslinie
#property indicator_color1 DarkSlateGray  //Farbe RSI Indikator
#property indicator_color2 Red            //Farbe schneller Moving Average
#property indicator_color3 Green          //Farbe langsamer Moving Average           
#property indicator_levelcolor DimGray    //Grenzlinienfarbe
#property indicator_width1 2              //Dicke der Indikatorlinien
#property indicator_width2 2
#property indicator_width3 2

//+------------------------------------------------------------------+
//| Voreinstellung Eingabeparameter                                  |
//+------------------------------------------------------------------+
extern int RSI_Period    = 5;    
extern int RSI_Price     = 0;
extern int RSI_MA_Fast_Period = 3; 
extern int RSI_MA_Fast_Type = 1; 
extern int RSI_MA_Slow_Period = 20;
extern int RSI_MA_Slow_Type = 1;

//+------------------------------------------------------------------+
//| Arrays                                                           |
//+------------------------------------------------------------------+
double RSIBuf[];
double MaFastBuf[];
double MaSlowBuf[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
{
IndicatorShortName("RSI mit Moving Average ->");

//+------------------------------------------------------------------+
//| Graphen zeichnen                                                 |
//+------------------------------------------------------------------+
SetIndexBuffer(0,RSIBuf);
SetIndexLabel(0,"RSI 5");                    
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1);  

SetIndexBuffer(1,MaFastBuf);
SetIndexLabel(1," ("+RSI_MA_Fast_Period+") Schneller MA auf RSI");       
SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,1);                       

SetIndexBuffer(2,MaSlowBuf);
SetIndexLabel(2," ("+RSI_MA_Slow_Period+") Langsamer MA auf RSI");       
SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,1); 


return(0);
}
//+------------------------------------------------------------------+
//| Berechnung RSI und MA  auf RSI                               |
//+------------------------------------------------------------------+
int start()
{

double MAFast,MASlow,RSI[];
ArrayResize(RSI,RSI_MA_Slow_Period);
int counted_bars=IndicatorCounted();
int limit = Bars-counted_bars-1;
for(int i=limit; i>=0; i--)

RSIBuf[i] = (iRSI(NULL,0,RSI_Period,RSI_Price,i)); 
MAFast = 0; MASlow=0;
for(int x=i; x<i; x++) {
RSI[x-i] = RSIBuf[x];
MAFast += RSIBuf[x]/RSI_MA_Fast_Period;
MASlow += RSIBuf[x]/RSI_MA_Slow_Period;
}

for(int j=limit; j>=0; j--)       //was missing
   {MaFastBuf[j] = (iMAOnArray(RSIBuf,0,RSI_MA_Fast_Period,0,RSI_MA_Fast_Type,j));
   MaSlowBuf[j] = (iMAOnArray(RSIBuf,0,RSI_MA_Slow_Period,0,RSI_MA_Slow_Type,j));}

//+------------------------------------------------------------------+
//| Absolutwerte runden                                              |
//+------------------------------------------------------------------+
string valRSI, valMaFast, valMaSlow;
valRSI=DoubleToStr(RSIBuf[0],1);
valMaFast=DoubleToStr(MaFastBuf[0],1);
valMaSlow=DoubleToStr(MaSlowBuf[0],1);

//+------------------------------------------------------------------+
//| Absolutwerte im Hauptfenster ausgeben                            |
//+------------------------------------------------------------------+

Comment("RSI              = "+valRSI+"\nMA schnell    = "+valMaFast+"\nMA langsam  = "+valMaSlow);

//----
return(0);

}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
Damit wird in einem Subfenster der RSI und die MA angezeigt und die Werte im Hauptfenster ausgegeben, wie ich es zum ausprobieren wollte.