Seric29: There is a need to hide objects according to a criterion. How can I hide objects on a graph (mainly lines)? The objects can be selected by prefix.
OBJPROP_TIMEFRAMES helps to do it. But not all in a bunch, but in a loop one by one.
1. var.- if you write universal functions. In this case, the number of checks increases, but the amount of code decreases, because in the end there are fewer functions, less initialized variables, but there is a disadvantage mentioned earlier.
The 2nd variant is if we write more functions that will perform less complex calculations. In this case, the amount of code increases, more variables are initialized and the compiler will have to run code idly often to find the right function, but there is a plus, the number of checks decreases.
1. var.- if you write universal functions. In this case, the number of checks increases, but the amount of code decreases, because in the end there are fewer functions, less initialized variables, but there is a disadvantage mentioned earlier.
The 2nd variant is if we write more functions that will perform less complex calculations. In this case, the amount of code increases, more variables are initialized and the compiler will have to run code idly often to find the right function, but there is a plus, the number of checks decreases.
Who thinks about it?
Option 2, lots of small functions, but you're 2 months in the dark about the difference between compiler and interpreter, the compiler doesn't run code idly, it creates tables of links to functions, variables, constants... and then uses those tables to jump in at runtime
Делиться с ближним своим для нас, божьих тварей, это очень характерно, считается добродетелью, и вообще, как утверждает первоисточник, положительно отражается на карме. Однако в мире, созданном архитекторами микропроцессоров, такое поведение не всегда приводит к хорошим результатам, особенно если это касается разделения памяти между потоками...
It's just amazing. How can you read documentation to see DRAW_HISTOGRAM2 and not see DRAW_COLOR_HISTOGRAM2
Oh, and there are extra buffers declared.
Good evening. Tried for a long time and in vain. The histogram draws correctly, but the coloring in different colours (above and below level 50) has not won. Please tell me where I screwed up. Text below, file is linked.
//+------------------------------------------------------------------+//| Stoch_HISTOGRAM_MQL5_4.mq5 |//| Copyright 2009-2017, MetaQuotes Software Corp. |//| http://www.mql5.com |//+------------------------------------------------------------------+#property copyright"2009-2017, MetaQuotes Software Corp."#property link"http://www.mql5.com"//--- indicator settings#property indicator_separate_window#property indicator_buffers8#property indicator_plots3#property indicator_type1DRAW_LINE// основная#property indicator_color1clrLightSeaGreen#property indicator_style1STYLE_SOLID#property indicator_type2DRAW_LINE// сигнальная#property indicator_color2clrYellow#property indicator_style2STYLE_SOLID#property indicator_type3DRAW_COLOR_HISTOGRAM2#property indicator_color3clrGreen,clrRed#property indicator_style3STYLE_SOLID#property indicator_width13#property indicator_width22#property indicator_width31//--- input parametersinputint InpKPeriod=5; // K periodinputint InpDPeriod=3; // D periodinputint InpSlowing=3; // Slowing//--- indicator buffersdouble ExtMainBuffer[];
double ExtSignalBuffer[];
double ColorHistogram_2Buffer1[];
double ColorHistogram_2Buffer2[];
double ExtHighesBuffer[];
double ExtLowesBuffer[];
double ColorHistogram_2Colors[];
color colors[]={clrRed,clrGreen};
int cl;
//+------------------------------------------------------------------+//| Custom indicator initialization function |//+------------------------------------------------------------------+voidOnInit()
{
//--- indicator buffers mappingSetIndexBuffer(0,ExtMainBuffer,INDICATOR_DATA);
SetIndexBuffer(1,ExtSignalBuffer,INDICATOR_DATA);
SetIndexBuffer(2,ColorHistogram_2Buffer1,INDICATOR_DATA);
SetIndexBuffer(3,ColorHistogram_2Buffer2,INDICATOR_DATA);
SetIndexBuffer(4,ExtHighesBuffer,INDICATOR_CALCULATIONS);
SetIndexBuffer(5,ExtLowesBuffer,INDICATOR_CALCULATIONS);
SetIndexBuffer(6,ColorHistogram_2Colors,INDICATOR_COLOR_INDEX);
PlotIndexSetDouble(2,PLOT_EMPTY_VALUE,0);
//--- set accuracyIndicatorSetInteger(INDICATOR_DIGITS,2);
//--- set levelsIndicatorSetInteger(INDICATOR_LEVELS,3);
IndicatorSetDouble(INDICATOR_LEVELVALUE,0,20);
IndicatorSetDouble(INDICATOR_LEVELVALUE,1,50);
IndicatorSetDouble(INDICATOR_LEVELVALUE,2,80);
////--- установим пустое значение для HISTOGRAM2// PlotIndexSetDouble(2,PLOT_EMPTY_VALUE,0); //--- set maximum and minimum for subwindow IndicatorSetDouble(INDICATOR_MINIMUM,0);
IndicatorSetDouble(INDICATOR_MAXIMUM,100);
//--- name for DataWindow and indicator subwindow labelIndicatorSetString(INDICATOR_SHORTNAME,"Stoch_HISTOGRAM("+(string)InpKPeriod+","+(string)InpDPeriod+","+(string)InpSlowing+")");
//PlotIndexSetDouble(2,PLOT_EMPTY_VALUE,0);PlotIndexSetString(0,PLOT_LABEL,"Main");
PlotIndexSetString(1,PLOT_LABEL,"Signal");
PlotIndexSetString(2,PLOT_LABEL,"UP");
PlotIndexSetString(3,PLOT_LABEL,"LOW");
//--- sets first bar from what index will be drawnPlotIndexSetInteger(0,PLOT_DRAW_BEGIN,InpKPeriod+InpSlowing-2);
PlotIndexSetInteger(1,PLOT_DRAW_BEGIN,InpKPeriod+InpDPeriod);
PlotIndexSetInteger(2,PLOT_DRAW_BEGIN,InpKPeriod+InpSlowing-2);
PlotIndexSetInteger(3,PLOT_DRAW_BEGIN,InpKPeriod+InpSlowing-2);
//--- initialization done
}
//+------------------------------------------------------------------+//| Stochastic Oscillator |//+------------------------------------------------------------------+intOnCalculate(constint rates_total,
constint prev_calculated,
constdatetime &time[],
constdouble &open[],
constdouble &high[],
constdouble &low[],
constdouble &close[],
constlong &tick_volume[],
constlong &volume[],
constint &spread[])
{
int i,k,start;
//PlotIndexSetInteger(2,PLOT_LINE_COLOR,0);//--- check for bars countif(rates_total<=InpKPeriod+InpDPeriod+InpSlowing)
return(0);
//---
start=InpKPeriod-1;
if(start+1<prev_calculated) start=prev_calculated-2;
else
{
for(i=0;i<start;i++)
{
ExtLowesBuffer[i]=0.0;
ExtHighesBuffer[i]=0.0;
}
}
//--- calculate HighesBuffer[] and ExtHighesBuffer[]for(i=start;i<rates_total && !IsStopped();i++)
{
double dmin=1000000.0;
double dmax=-1000000.0;
for(k=i-InpKPeriod+1;k<=i;k++)
{
if(dmin>low[k]) dmin=low[k];
if(dmax<high[k]) dmax=high[k];
}
ExtLowesBuffer[i]=dmin;
ExtHighesBuffer[i]=dmax;
}
//--- %K
start=InpKPeriod-1+InpSlowing-1;
if(start+1<prev_calculated) start=prev_calculated-2;
else
{
for(i=0;i<start;i++) ExtMainBuffer[i]=0.0;
}
//--- main cyclefor(i=start;i<rates_total && !IsStopped();i++)
{
double sumlow=0.0;
double sumhigh=0.0;
for(k=(i-InpSlowing+1);k<=i;k++)
{
sumlow +=(close[k]-ExtLowesBuffer[k]);
sumhigh+=(ExtHighesBuffer[k]-ExtLowesBuffer[k]);
}
if(sumhigh==0.0) ExtMainBuffer[i]=100.0;
else ExtMainBuffer[i]=sumlow/sumhigh*100;
if(ExtMainBuffer[i]>50){
cl=0;
ColorHistogram_2Buffer1[i]=50;
ColorHistogram_2Buffer2[i]=ExtMainBuffer[i];
ColorHistogram_2Colors[i]=colors[cl];
}
if(ExtMainBuffer[i]<50){
cl=1;
ColorHistogram_2Buffer1[i]=ExtMainBuffer[i];
ColorHistogram_2Buffer2[i]=50;
ColorHistogram_2Colors[i]=colors[cl];
}
}
//--- signal
start=InpDPeriod-1;
if(start+1<prev_calculated) start=prev_calculated-2;
else
{
for(i=0;i<start;i++) ExtSignalBuffer[i]=0.0;
}
for(i=start;i<rates_total && !IsStopped();i++)
{
double sum=0.0;
for(k=0;k<InpDPeriod;k++) sum+=ExtMainBuffer[i-k];
ExtSignalBuffer[i]=sum/InpDPeriod;
}
//--- OnCalculate done. Return new prev_calculated.return(rates_total);
}
//+------------------------------------------------------------------+
Good evening. Tried for a long time and in vain. The histogram draws correctly, but the coloring in different colours (above and below level 50) has not won. Please tell me where I screwed up. Text below, file is linked.
In debug mode I was looking through the values step by step:
ExtMainBuffer[i]
cl
ColorHistogram_2Buffer1[i]
ColorHistogram_2Buffer2[i]
ColorHistogram_2Colors[i]
It seems to get everything right, but the bar graphs are only green, those below 50 are not coloured red.
Индикатор Normalized Volume - индикатор нормализованного объёма. Отображает средний объём в диапазоне баров в виде цветной гистограммы с пороговым уровнем. Имеет два настраиваемых параметра:
There is a need to hide objects according to a criterion. How can I hide objects on a graph (mainly lines)? The objects can be selected by prefix.
OBJPROP_TIMEFRAMES helps to do it. But not all in a bunch, but in a loop one by one.
OBJPROP_TIMEFRAMES would help with that. But not all in a bunch, but in a loop one at a time.
I will do so, I want a period-by-period mapping and will experiment, thanks for the advice.
How will the program run faster?
1. var.- if you write universal functions. In this case, the number of checks increases, but the amount of code decreases, because in the end there are fewer functions, less initialized variables, but there is a disadvantage mentioned earlier.
The 2nd variant is if we write more functions that will perform less complex calculations. In this case, the amount of code increases, more variables are initialized and the compiler will have to run code idly often to find the right function, but there is a plus, the number of checks decreases.
Who thinks about it?
How will the program run faster?
1. var.- if you write universal functions. In this case, the number of checks increases, but the amount of code decreases, because in the end there are fewer functions, less initialized variables, but there is a disadvantage mentioned earlier.
The 2nd variant is if we write more functions that will perform less complex calculations. In this case, the amount of code increases, more variables are initialized and the compiler will have to run code idly often to find the right function, but there is a plus, the number of checks decreases.
Who thinks about it?
Option 2, lots of small functions, but you're 2 months in the dark about the difference between compiler and interpreter, the compiler doesn't run code idly, it creates tables of links to functions, variables, constants... and then uses those tables to jump in at runtime
here readhttps://habr.com/ru/company/intel/blog/143446/
the developers wrote the same thing here somewhere search the threadhttps://www.mql5.com/ru/forum/304239/page36#comment_11049194
SZZ: here's how the compiler workshttps://habr.com/ru/sandbox/114988/
It's just amazing. How can you read documentation to see DRAW_HISTOGRAM2 and not see DRAW_COLOR_HISTOGRAM2
Oh, and there are extra buffers declared.Good evening. Tried for a long time and in vain. The histogram draws correctly, but the coloring in different colours (above and below level 50) has not won. Please tell me where I screwed up. Text below, file is linked.
Good evening. Tried for a long time and in vain. The histogram draws correctly, but the coloring in different colours (above and below level 50) has not won. Please tell me where I screwed up. Text below, file is linked.
In debug mode I was looking through the values step by step:
- ExtMainBuffer[i]
- cl
- ColorHistogram_2Buffer1[i]
- ColorHistogram_2Buffer2[i]
- ColorHistogram_2Colors[i]
It seems to get everything right, but the bar graphs are only green, those below 50 are not coloured red.In debug mode, looked through the values step by step:
- ExtMainBuffer[i]
- cl
- ColorHistogram_2Buffer1[i]
- ColorHistogram_2Buffer2[i]
- ColorHistogram_2Colors[i]
It seems to count correctly, but histograms are only green, those below 50 are not coloured red.In debug mode, looked through the values step by step:
- ExtMainBuffer[i]
- cl
- ColorHistogram_2Buffer1[i]
- ColorHistogram_2Buffer2[i]
- ColorHistogram_2Colors[i]
It seems to get everything right, but histograms are only green, those below 50 are not colored in red.but you're on the pull ...
Well that's understandable I just figuratively called the program a compiler, but in general in which case would it be better?