Multi Time Frame RSI MQL 4

 
I got struggling to plot a multi time frame RSI on the chart!
It will be initiallized and it is calculating values in the expert watch window.

At the beginning I choosed from MQL Wizard the Coustomize Indicator template.

But it won´t be ploting a line on the chart.

Does anyone know a solution.

A code snippet is below. Thanks in advance!


#property indicator_chart_window
#property strict

// Define input parameters
input int periodH4 = 240;  // H4 time frame
input int periodH1 = 60;   // H1 time frame

// Global variables for line handles
int lineHandle;

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
{
   // Create a line on the chart
   lineHandle = ObjectCreate(0, "RSI Line", OBJ_TREND, 0, 0, 0);
   ObjectSetInteger(0, "RSI Line", OBJPROP_COLOR, clrBlue);
   ObjectSetInteger(0, "RSI Line", OBJPROP_STYLE, STYLE_SOLID);
   ObjectSetInteger(0, "RSI Line", OBJPROP_WIDTH, 2);

   return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Indicator calculation function                                   |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
{
   // Calculate RSI values from different time frames
   double rsiH4 = iRSI(NULL, periodH4, 14, PRICE_CLOSE, 0);
   double rsiH1 = iRSI(NULL, periodH1, 14, PRICE_CLOSE, 0);

   // Print the RSI values in the Experts tab (for debugging purposes)
   Print("RSI H4: ", rsiH4, " RSI H1: ", rsiH1);

   // Calculate the average of the two RSI values
   double rsiAvg = (rsiH4 + rsiH1) / 2;

   // Modify the existing line based on the RSI average
   ObjectSetInteger(0, "RSI Line", OBJPROP_RAY_RIGHT, 1);
   ObjectSetInteger(0, "RSI Line", OBJPROP_COLOR, clrBlue);
   ObjectSetDouble(0, "RSI Line", OBJPROP_PRICE1, rsiAvg);

   return(rates_total);
}
//+------------------------------------------------------------------+

 
  1. Wir können hier Deutsch reden :)
  2. MTF ist kompliziert - aber es gibt (fast alles) schon:
    Such mal: https://www.mql5.com/en/search#!keyword=multi%20timeframe%20indicator&module=mql5_module_codebase&method=2&page=8
    Dann sortierst Du nach der Zeit und beginnst bei den ältesten - da sind die meisten in MT4, zB. https://www.mql5.com/en/code/7717 oder https://www.mql5.com/en/code/10972
    Kopieren und nach eigenen Ideen ändern, ist schneller, weil man mit funktionierendem Code beginnt. ;)
  3. Warum MT4 lernen als Anfänger? Das sagt der CEO über MT4: https://www.mql5.com/en/forum/454319
  4. Hier ist eine Liste mit Links für Anfänger: https://www.mql5.com/de/forum/455957#comment_50048608
    Einfach überfliegen und bleiben bei dem, was man braucht.
Grund der Beschwerde: