wooooow....... прекрасный Antt, это то, что я искал....
Теперь, если возможно, я снова прошу вашей помощи: Я построил этот CCI, но я не могу посмотреть и изменить цвет гистограммы, когда CCI выше или ниже нулевой линии. Почему?
Спасибо за помощь
//+------------------------------------------------------------------+//| RSI.mq5 |//| Copyright 2009, MetaQuotes Software Corp. |//| http://www.mql5.com |//+------------------------------------------------------------------+#property copyright "Copyright 2009, MetaQuotes Software Corp."#property link "http://www.mql5.com"#property description "Relative Strength Index"//--- indicator settings#property indicator_separate_window#property indicator_buffers 4#property indicator_plots 3//--- input parametersinputint CCIPeriod=14; // Period for calculating the CCIinputint CCIPeriodTurbo=6; // Period for calculating the TURBOCCIinputENUM_APPLIED_PRICE price1 =PRICE_CLOSE; // Method of calculating//---- plot CCI_LINE#property indicator_label1 "CCI_LINE"#property indicator_type1 DRAW_LINE#property indicator_color1 Black#property indicator_style1 STYLE_SOLID#property indicator_width1 3//---- plot CCI_TURBO_LINE#property indicator_label2 "CCI_TURBO_LINE"#property indicator_type2 DRAW_LINE#property indicator_color2 Navy#property indicator_style2 STYLE_SOLID#property indicator_width2 1//---- plot CCI_HISTOGRAM#property indicator_label3 "CCI_HISTO"#property indicator_type3 DRAW_COLOR_HISTOGRAM#property indicator_color3 Red,Green#property indicator_style3 STYLE_SOLID#property indicator_width3 2//----- level#property indicator_level1 -100.0#property indicator_level2 100.0#property indicator_level3 -200.0#property indicator_level4 200.0#property indicator_level5 -50.0#property indicator_level6 50.0//--- indicator buffersdouble CCI_LINEBuffer[]; // CCI_LINEdouble CCI_TURBOBuffer[]; // CCI TURBO_LINEdouble HISTOGRAM[]; // HISTOGRAMint copied;
//+------------------------------------------------------------------+//| Custom indicator initialization function |//+------------------------------------------------------------------+void OnInit()
{
//--- indicator buffers mappingSetIndexBuffer(0,CCI_LINEBuffer,INDICATOR_DATA);//buffer LINESetIndexBuffer(1,CCI_TURBOBuffer,INDICATOR_DATA);//buffer TurboSetIndexBuffer(2,HISTOGRAM,INDICATOR_COLOR_INDEX);//buffer Histogram//name of separate window IndicatorSetString(INDICATOR_SHORTNAME,"MYCCI");
//---
}
//+------------------------------------------------------------------+//| Custom indicator iteration function |//+------------------------------------------------------------------+int OnCalculate(constint rates_total,
constint prev_calculated,
constint begin,
constdouble &price[]
)
{
//--- Create the indicator of CCI LINRint CCIhandle=iCCI(NULL,0,CCIPeriod,price1);
copied=CopyBuffer(CCIhandle,0,0,rates_total,CCI_LINEBuffer);
//--- Create the indicator of CCI TURBOint CCI_TURBO_handle=iCCI(NULL,0,CCIPeriodTurbo,price1);
copied=CopyBuffer(CCI_TURBO_handle,0,0,rates_total,CCI_TURBOBuffer);
int i ;
for(i=0;i>=rates_total;i++);
if (CCI_LINEBuffer[i]<0)
{
HISTOGRAM[i]=0.0;//HISTOGRAM RED
}
if (CCI_LINEBuffer[i]>0)
{
HISTOGRAM[i]=1.0;//HISTOGRAM Green
}
//--- return value of prev_calculated for next callreturn(rates_total);
}
wooooow....... прекрасный Antt, это то, что я искал....
Теперь, если возможно, я снова прошу вашей помощи: Я построил этот CCI, но не могу посмотреть и изменить цвет гистограммы, когда CCI находится выше или ниже нулевой линии. Почему?
Спасибо за помощь
Вам следует немного изучить MQL5, прежде чем писать такой индикатор. Вы допустили столько неловких ошибок.
//+------------------------------------------------------------------+//| RSIcolor.mq5 |//| Copyright 2009, MetaQuotes Software Corp. |//| http://www.mql5.com |//+------------------------------------------------------------------+#property copyright "Copyright 2009, MetaQuotes Software Corp."#property link "http://www.mql5.com"#property description "Relative Strength Index"//--- indicator settings#property indicator_separate_window#property indicator_buffers 4#property indicator_plots 3//--- input parametersinputint CCIPeriod=14; // Period for calculating the CCIinputint CCIPeriodTurbo=6; // Period for calculating the TURBOCCIinputENUM_APPLIED_PRICE price1=PRICE_CLOSE; // Method of calculating//---- plot CCI_LINE#property indicator_label1 "CCI_LINE"#property indicator_type1 DRAW_LINE#property indicator_color1 Black#property indicator_style1 STYLE_SOLID#property indicator_width1 3//---- plot CCI_TURBO_LINE#property indicator_label2 "CCI_TURBO_LINE"#property indicator_type2 DRAW_LINE#property indicator_color2 Navy#property indicator_style2 STYLE_SOLID#property indicator_width2 1//---- plot CCI_HISTOGRAM#property indicator_label3 "CCI_HISTO"#property indicator_type3 DRAW_COLOR_HISTOGRAM#property indicator_color3 Red,Green#property indicator_style3 STYLE_SOLID#property indicator_width3 2//----- level#property indicator_level1 -100.0#property indicator_level2 100.0#property indicator_level3 -200.0#property indicator_level4 200.0#property indicator_level5 -50.0#property indicator_level6 50.0//--- indicator buffersdouble CCI_LINEBuffer[]; // CCI_LINEdouble CCI_TURBOBuffer[]; // CCI TURBO_LINEdouble HISTOGRAM[]; // HISTOGRAMdouble HISTOGRAMColor[]; // HISTOGRAMint copied;
//+------------------------------------------------------------------+//| Custom indicator initialization function |//+------------------------------------------------------------------+void OnInit()
{
//--- indicator buffers mappingSetIndexBuffer(0,CCI_LINEBuffer,INDICATOR_DATA);//buffer LINESetIndexBuffer(1,CCI_TURBOBuffer,INDICATOR_DATA);//buffer TurboSetIndexBuffer(2,HISTOGRAM,INDICATOR_DATA);//buffer HistogramSetIndexBuffer(3,HISTOGRAMColor,INDICATOR_COLOR_INDEX);//buffer Histogram//name of separate window IndicatorSetString(INDICATOR_SHORTNAME,"MYCCI");
//---
}
//+------------------------------------------------------------------+//| Custom indicator iteration function |//+------------------------------------------------------------------+int OnCalculate(constint rates_total,
constint prev_calculated,
constint begin,
constdouble &price[]
)
{
//--- Create the indicator of CCI LINRint CCIhandle=iCCI(NULL,0,CCIPeriod,price1);
copied=CopyBuffer(CCIhandle,0,0,rates_total,CCI_LINEBuffer);
//--- Create the indicator of CCI TURBOint CCI_TURBO_handle=iCCI(NULL,0,CCIPeriodTurbo,price1);
copied=CopyBuffer(CCI_TURBO_handle,0,0,rates_total,CCI_TURBOBuffer);
int i=prev_calculated;
if (i>0) prev_calculated--;
for(;i<rates_total;i++)
{
HISTOGRAM[i]=CCI_LINEBuffer[i];
if(CCI_LINEBuffer[i]<0)
{
HISTOGRAMColor[i]=0.0;//HISTOGRAM RED
}
if(CCI_LINEBuffer[i]>0)
{
HISTOGRAMColor[i]=1.0;//HISTOGRAM Green
}
}
//--- return value of prev_calculated for next callreturn(rates_total);
}
//+------------------------------------------------------------------+
Для авторизации и пользования сайтом MQL5.com необходимо разрешить использование файлов Сookie.
Пожалуйста, включите в вашем браузере данную настройку, иначе вы не сможете авторизоваться.
Вы вошли в аккаунт. Двухфакторная аутентификация отключена. Настройте её заново и отсканируйте новый QR-код или продолжите с отключённой двухфакторной аутентификацией.
Спасибо, Antt, но это не то, что я искал. Я бы вставил текст, как в этом примере: RSI +-значение CSR.... возможно?
Спасибо, Antt, но это не то, что я искал. Я бы вставил текст, как в этом примере: RSI +-значение CSR.... возможно?
//| RSI.mq5 |
//| Copyright 2009, MetaQuotes Software Corp. |
//| http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2009, MetaQuotes Software Corp."
#property link "http://www.mql5.com"
#property description "Relative Strength Index"
//--- indicator settings
#property indicator_separate_window
#property indicator_minimum 0
#property indicator_maximum 100
#property indicator_level1 30
#property indicator_level2 70
#property indicator_buffers 3
#property indicator_plots 1
#property indicator_type1 DRAW_LINE
#property indicator_color1 DodgerBlue
//--- input parameters
input int InpPeriodRSI=14; // Period
//--- indicator buffers
double ExtRSIBuffer[];
double ExtPosBuffer[];
double ExtNegBuffer[];
//--- global variable
int ExtPeriodRSI;
//---
int window;
string objectName="RsiText";
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
void OnInit()
{
//--- check for input
if(InpPeriodRSI<1)
{
ExtPeriodRSI=12;
Print("Incorrect value for input variable InpPeriodRSI =",InpPeriodRSI,
"Indicator will use value =",ExtPeriodRSI,"for calculations.");
}
else ExtPeriodRSI=InpPeriodRSI;
//--- indicator buffers mapping
SetIndexBuffer(0,ExtRSIBuffer,INDICATOR_DATA);
SetIndexBuffer(1,ExtPosBuffer,INDICATOR_CALCULATIONS);
SetIndexBuffer(2,ExtNegBuffer,INDICATOR_CALCULATIONS);
//--- set accuracy
IndicatorSetInteger(INDICATOR_DIGITS,2);
//--- sets first bar from what index will be drawn
PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,ExtPeriodRSI);
//--- name for DataWindow and indicator subwindow label
IndicatorSetString(INDICATOR_SHORTNAME,"RSI("+string(ExtPeriodRSI)+")");
//--- get window number
window=ChartWindowFind();
//--- initialization done
}
//+------------------------------------------------------------------+
//| Relative Strength Index |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
const int prev_calculated,
const int begin,
const double &price[])
{
int i;
double diff;
//--- check for rates count
if(rates_total<=ExtPeriodRSI)
return(0);
//--- preliminary calculations
int pos=prev_calculated-1;
if(pos<=ExtPeriodRSI)
{
//--- first RSIPeriod values of the indicator are not calculated
ExtRSIBuffer[0]=0.0;
ExtPosBuffer[0]=0.0;
ExtNegBuffer[0]=0.0;
double SumP=0.0;
double SumN=0.0;
for(i=1;i<=ExtPeriodRSI;i++)
{
ExtRSIBuffer[i]=0.0;
ExtPosBuffer[i]=0.0;
ExtNegBuffer[i]=0.0;
diff=price[i]-price[i-1];
SumP+=(diff>0?diff:0);
SumN+=(diff<0?-diff:0);
}
//--- calculate first visible value
ExtPosBuffer[ExtPeriodRSI]=SumP/ExtPeriodRSI;
ExtNegBuffer[ExtPeriodRSI]=SumN/ExtPeriodRSI;
ExtRSIBuffer[ExtPeriodRSI]=100.0-(100.0/(1.0+ExtPosBuffer[ExtPeriodRSI]/ExtNegBuffer[ExtPeriodRSI]));
//--- prepare the position value for main calculation
pos=ExtPeriodRSI+1;
}
//--- the main loop of calculations
for(i=pos;i<rates_total;i++)
{
diff=price[i]-price[i-1];
ExtPosBuffer[i]=(ExtPosBuffer[i-1]*(ExtPeriodRSI-1)+(diff>0.0?diff:0.0))/ExtPeriodRSI;
ExtNegBuffer[i]=(ExtNegBuffer[i-1]*(ExtPeriodRSI-1)+(diff<0.0?-diff:0.0))/ExtPeriodRSI;
ExtRSIBuffer[i]=100.0-100.0/(1+ExtPosBuffer[i]/ExtNegBuffer[i]);
}
//--- create object
ObjectCreate(0,objectName,OBJ_TEXT,window,0,0);
ObjectSetString(0,objectName,OBJPROP_TEXT,string(ExtRSIBuffer[rates_total-1]));
ObjectSetInteger(0,objectName,OBJPROP_COLOR,Red);
datetime tm[1];
CopyTime(_Symbol,_Period,0,1,tm);
ObjectSetInteger(0,objectName,OBJPROP_TIME,tm[0]);
ObjectSetDouble(0,objectName,OBJPROP_PRICE,ExtRSIBuffer[rates_total-1]);
//--- OnCalculate done. Return new prev_calculated.
return(rates_total);
}
//+------------------------------------------------------------------+
Спасибо, Антт - это прекрасно.
Теперь: Мне нужно зафиксировать текст в определенной точке в подокне.
Я добавил: objprop_xdistance, но не функцию. Почему?
Спасибо еще раз
Спасибо, Антт - это прекрасно.
Теперь: Мне нужно зафиксировать текст в определенной точке в подокне.
Я добавил: objprop_xdistance, но не функцию. Почему?
Еще раз спасибо
wooooow....... прекрасный Antt, это то, что я искал....
Теперь, если возможно, я снова прошу вашей помощи: Я построил этот CCI, но я не могу посмотреть и изменить цвет гистограммы, когда CCI выше или ниже нулевой линии. Почему?
Спасибо за помощь
wooooow....... прекрасный Antt, это то, что я искал....
Теперь, если возможно, я снова прошу вашей помощи: Я построил этот CCI, но не могу посмотреть и изменить цвет гистограммы, когда CCI находится выше или ниже нулевой линии. Почему?
Спасибо за помощь
Вам следует немного изучить MQL5, прежде чем писать такой индикатор. Вы допустили столько неловких ошибок.
Как я могу поместить ярлык в правый верхний угол?
Как поместить метку в правый верхний угол?
Не могли бы вы изменить пример индикатора RSI таким образом, чтобы он показывал значение RSI в правом верхнем углу?
Я уже практически все перепробовал, но у меня ничего не получилось.
Не могли бы вы изменить пример индикатора RSI таким образом, чтобы он показывал значение RSI в правом верхнем углу?
Я уже практически все перепробовал, но у меня ничего не получилось.
Вы можете найти лучшую точку, перемещая OBJPROP_XDISTANCE и OBJPROP_YDISTANCE