Einzelnen Beitrag anzeigen
  #1 (permalink)  
Alt 13.02.12
Dennis Dennis ist offline
Neues Mitglied
 
Registriert seit: Feb 2012
Beiträge: 4
Dennis befindet sich auf einem aufstrebenden Ast
Standard in EA: EMA auf RSI

Hallo Leute,

bevor ich Fragen frage, betreibe ich immer erst einige Eigenrecherche. In diesem Fall hat sie leider nicht zum Ziel geführt. Deswegen hier mein Anliegen.

In der aktuellen Candle werden die RSIs der 3 aktuellsten Candles benötigt. Diese RSIs sollen mit einem EMA geglättet werden.

Hört sich recht simpel an, aber als MQL4-Anfänger habe ich's für den EA auch nach längerem Probieren leider nicht hingekriegt.

Im Indicator habe ich es durch Umfrimeln eines anderen Indicators umsetzen können. Aber im EA habe ich auch durch Lesen und Testen nicht herausgefunden, wie iMAOnArray angewendet werden muß.

Die Print-Funktionen dienen nur der Kontrolle der Werte.

Würde mich echt freuen, wenn mir da jemand weiterhelfen könnte

EA:
Code:
extern int EMA = 10;
extern int RSI =  5;

int start()
{
    double RSI0 = iRSI (NULL, 0, RSI, PRICE_CLOSE, 0);
    double RSI1 = iRSI (NULL, 0, RSI, PRICE_CLOSE, 1);
    double RSI2 = iRSI (NULL, 0, RSI, PRICE_CLOSE, 2);

    Print ("RSI0: ", RSI0);
    Print ("RSI1: ", RSI1);
    Print ("RSI2: ", RSI2);
/*
    double MaRSI0 =
    double MaRSI1 =
    double MaRSI2 =

    Print ("MaRSI0: ", DoubleToStr (MaRSI0, 0));
    Print ("MaRSI1: ", DoubleToStr (MaRSI1, 1));
    Print ("MaRSI2: ", DoubleToStr (MaRSI2, 2));
*/
}
Indicator:
Code:
#property indicator_separate_window
#property indicator_buffers 2

#property indicator_color1 C'44,177,44' // High
#property indicator_color2 Blue         // Low

extern int EMA = 10;
extern int RSI =  5;

double RSIclose[];
double MaRSIclose[];

int init()
{
    IndicatorBuffers (2);
    IndicatorDigits (Digits);

    SetIndexBuffer (0, MaRSIclose);
    SetIndexStyle (0, DRAW_LINE);
    SetIndexLabel (0, "close");
    SetIndexDrawBegin (0, EMA);

    SetIndexBuffer (1, RSIclose);

    IndicatorShortName ("EMAonRSI  ["+EMA+",  "+RSI+"] ");
    return (0);
}

int start()
{
    int counted, i;
    counted = IndicatorCounted();

    if (counted < 1)
        for (i = Bars - 2 * EMA; i < Bars; i++)
        {
            RSIclose[i]   = 0.0;
            MaRSIclose[i] = 0.0;
        }

    counted = Bars - counted - 1;

    for (i = counted; i >= 0; i--)
        RSIclose[i]  = iRSI (NULL, 0, RSI, PRICE_CLOSE, i);
    
    for (i = counted; i >= 0; i--)
        MaRSIclose[i] = iMAOnArray (RSIclose, 0, EMA, 0, MODE_EMA, i);
    
    return (0);
}