79 lines
2.7 KiB
MQL5
79 lines
2.7 KiB
MQL5
|
|
//+------------------------------------------------------------------+
|
||
|
|
//| Indikator_XAUUSD.mq5 |
|
||
|
|
//| Copyright 2026, MetaQuotes Software Corp. |
|
||
|
|
//| https://www.mql5.com |
|
||
|
|
//+------------------------------------------------------------------+
|
||
|
|
#property copyright "Copyright 2026"
|
||
|
|
#property version "1.00"
|
||
|
|
#property strict
|
||
|
|
#property indicator_separate_window
|
||
|
|
#property indicator_buffers 2
|
||
|
|
#property indicator_plots 2
|
||
|
|
#property indicator_type1 DRAW_LINE
|
||
|
|
#property indicator_color1 clrRed
|
||
|
|
#property indicator_width1 2
|
||
|
|
#property indicator_type2 DRAW_LINE
|
||
|
|
#property indicator_color2 clrWhite
|
||
|
|
#property indicator_width2 1
|
||
|
|
|
||
|
|
// --- LEVEL KHUSUS EMAS XAUUSD ---
|
||
|
|
#property indicator_level1 10.0 // Zona FULL BUY
|
||
|
|
#property indicator_level2 15.0 // Zona BUY
|
||
|
|
#property indicator_level3 50.0 // Garis Tengah
|
||
|
|
#property indicator_level4 85.0 // Zona SELL
|
||
|
|
#property indicator_level5 90.0 // Zona FULL SELL
|
||
|
|
|
||
|
|
#property indicator_levelcolor clrBlueViolet
|
||
|
|
#property indicator_levelwidth 1
|
||
|
|
#property indicator_levelstyle STYLE_SOLID
|
||
|
|
|
||
|
|
double RSI_merah[];
|
||
|
|
double RSI_putih[];
|
||
|
|
int rsi_handle;
|
||
|
|
|
||
|
|
//+------------------------------------------------------------------+
|
||
|
|
//| Custom indicator initialization function |
|
||
|
|
//+------------------------------------------------------------------+
|
||
|
|
int OnInit()
|
||
|
|
{
|
||
|
|
SetIndexBuffer(0,RSI_merah);
|
||
|
|
SetIndexBuffer(1,RSI_putih);
|
||
|
|
IndicatorSetString(INDICATOR_SHORTNAME,"Zona Sinyal Emas");
|
||
|
|
IndicatorSetInteger(INDICATOR_DIGITS,0);
|
||
|
|
rsi_handle = iRSI(_Symbol,_Period,14,PRICE_CLOSE);
|
||
|
|
return(INIT_SUCCEEDED);
|
||
|
|
}
|
||
|
|
//+------------------------------------------------------------------+
|
||
|
|
//| Custom indicator iteration 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[])
|
||
|
|
{
|
||
|
|
if(rates_total<14) return(0);
|
||
|
|
|
||
|
|
int limit=rates_total-prev_calculated;
|
||
|
|
if(prev_calculated>0) limit++;
|
||
|
|
|
||
|
|
double rsi_val[];
|
||
|
|
ArraySetAsSeries(rsi_val,true);
|
||
|
|
CopyBuffer(rsi_handle,0,0,limit,rsi_val);
|
||
|
|
|
||
|
|
ArraySetAsSeries(RSI_merah,true);
|
||
|
|
ArraySetAsSeries(RSI_putih,true);
|
||
|
|
|
||
|
|
for(int i=0; i<limit; i++)
|
||
|
|
{
|
||
|
|
RSI_merah[i] = rsi_val[i];
|
||
|
|
RSI_putih[i] = rsi_val[i];
|
||
|
|
}
|
||
|
|
return(rates_total);
|
||
|
|
}
|
||
|
|
//+------------------------------------------------------------------+
|