А зачем это делать? В этом индикаторе линия 50 играет роль нуля, что Вам даст другое название осевой лини?
Все равно они будут масштабироваться одинаково, линии 50 у них совпадут. Подумайте, это минутное необоснованное желание и удовлетворять его принципиально не надо, хотя сделать в коде - три секунды. И что получится? У всех людей будут RSI 0..100, а у Вас -50..+50, трудно будет общаться.
granit77 >>:
Все равно они будут масштабироваться одинаково, линии 50 у них совпадут. Подумайте, это минутное необоснованное желание и удовлетворять его принципиально не надо, хотя сделать в коде - три секунды. И что получится? У всех людей будут RSI 0..100, а у Вас -50..+50, трудно будет общаться.
Ну мне очень нужно
Предпреждаю сразу. Я только начинающий. Но по-моему получится тоже самое:
//+------------------------------------------------------------------+ //| RSI-G.mq4 | //| Copyright © 2009, DonAtom. | //| DonAtom@yandex.ru | //+------------------------------------------------------------------+ #property copyright "Copyright © 2009, DonAtom." #property link "DonAtom@yandex.ru" #property indicator_separate_window #property indicator_minimum -75 #property indicator_maximum 75 #property indicator_buffers 5 #property indicator_color2 Red #property indicator_color3 Blue //---- input parameters extern int RSIPeriod=5; extern double PER = 8; extern double PER2 = 8; //---- buffers double RSIBuffer[]; double PosBuffer[]; double NegBuffer[]; double Q[],H[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { string short_name; //---- 2 additional buffers are used for counting. IndicatorBuffers(5); SetIndexBuffer(3,PosBuffer); SetIndexBuffer(4,NegBuffer); SetIndexBuffer(0,RSIBuffer); SetIndexStyle(2,DRAW_LINE); SetIndexBuffer(2,H); SetIndexStyle(1,DRAW_HISTOGRAM); SetIndexBuffer(1,Q); //---- name for DataWindow and indicator subwindow label short_name="RSI-G("+RSIPeriod+")"; IndicatorShortName(short_name); SetIndexLabel(0,short_name); //---- SetIndexDrawBegin(0,RSIPeriod); //---- return(0); } //+------------------------------------------------------------------+ //| Relative Strength Index | //+------------------------------------------------------------------+ int start() { int i,counted_bars=IndicatorCounted(); double rel,negative,positive; //---- if(Bars<=RSIPeriod) return(0); //---- initial zero if(counted_bars<1) for(i=1;i<=RSIPeriod;i++) RSIBuffer[Bars-i]=0.0; //---- i=Bars-RSIPeriod-1; if(counted_bars>=RSIPeriod) i=Bars-counted_bars-1; while(i>=0) { double sumn=0.0,sump=0.0; if(i==Bars-RSIPeriod-1) { int k=Bars-2; //---- initial accumulation while(k>=i) { rel=Close[k]-Close[k+1]; if(rel>0) sump+=rel; else sumn-=rel; k--; } positive=sump/RSIPeriod; negative=sumn/RSIPeriod; } else { //---- smoothed moving average rel=Close[i]-Close[i+1]; if(rel>0) sump=rel; else sumn=-rel; positive=(PosBuffer[i+1]*(RSIPeriod-1)+sump)/RSIPeriod; negative=(NegBuffer[i+1]*(RSIPeriod-1)+sumn)/RSIPeriod; } PosBuffer[i]=positive; NegBuffer[i]=negative; if(negative==0.0) RSIBuffer[i]=0.0; else RSIBuffer[i]=100.0-200.0/(1+positive/negative); int a; double Kum = 0; for(a=i; a<=i+(PER-1); a++) // Заголовок оператора цикла { Kum=Kum+RSIBuffer[a]; } Q[i]=Kum/PER; Kum=0; for(a=i; a<=i+(PER2-1); a++) // Заголовок оператора цикла { Kum=Kum+RSIBuffer[a]; } H[i]=Kum/PER2; i--; } //---- return(0); } //+------------------------------------------------------------------+
![MQL5 - Язык торговых стратегий для клиентского терминала MetaTrader 5](https://c.mql5.com/i/registerlandings/logo-2.png)
Вы упускаете торговые возможности:
- Бесплатные приложения для трейдинга
- 8 000+ сигналов для копирования
- Экономические новости для анализа финансовых рынков
Регистрация
Вход
Вы принимаете политику сайта и условия использования
Если у вас нет учетной записи, зарегистрируйтесь
Добрый день, я не очень понимаю в скриптах, вот хочу попросить у вас помощи, мне нужно чтобы сглаженый RSI в виде гистограммы был по обе стороны нулевой линии от "0" до "100" и "-100". Примерно вот так как на картинке (на картинке индикатор OsMA)
Вот код индикатора "Сглаженый RSI" или "MA RSI"
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Gold
#property indicator_level1 50
#property indicator_level2 90
#property indicator_level3 10
#property indicator_level4 45
#property indicator_level5 55
#property indicator_maximum 100
#property indicator_minimum 0
//---- input parameters
extern int RSI_Period= 5;
extern int RSI_Mode=0;
extern int MA_Period=5;
extern int MA_Mode =0;
extern int Limit=5440;
double RSI[];
double MA[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init() {
IndicatorBuffers(2);
SetIndexStyle(0,DRAW_HISTOGRAM);
SetIndexDrawBegin(0,RSI_Period+MA_Period);
SetIndexBuffer(0,MA);
SetIndexBuffer(1,RSI);
IndicatorShortName("MA_RSI("+RSI_Period+","+MA_Period+")");
SetIndexLabel(0,"MA(WPR)");
return(0); }
//+------------------------------------------------------------------+
int start() {
int limit;
int counted_bars=IndicatorCounted();
int i;
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
if (limit>Limit && Limit>0) limit = Limit;
for (i = limit;i>=0;i--) RSI[i] = iRSI(Symbol(),Period(),RSI_Period,RSI_Mode,i);
for (i = limit;i>=0;i--) MA[i] = iMAOnArray(RSI,0,MA_Period,0,MA_Mode,i);
return(0);
}// int start()