help me ,the array's value is where come from

 

#property copyright "Copyright ?2006, Forex-TSD.com "
#property link "https://www.forex-tsd.com/"

#property indicator_buffers 4
#property indicator_color1 Red
#property indicator_color2 Blue
#property indicator_color3 Red
#property indicator_color4 Blue

string str = "DEM063011hp";
int mod = MODE_EMA;
int period1 = 20;
double shuzu1[];
double shuzu2[];
double shuzu3[];
double shuzu4[];
int barsshu = 0;

int init()
{
SetIndexStyle(0, DRAW_NONE, STYLE_SOLID, 2, Red);
SetIndexBuffer(0, shuzu1);
SetIndexStyle(1, DRAW_NONE, STYLE_SOLID, 2, Yellow);
SetIndexBuffer(1, shuzu2);
SetIndexStyle(2, DRAW_HISTOGRAM, STYLE_SOLID, 3, Red);
SetIndexBuffer(2, shuzu3);
SetIndexStyle(3, DRAW_HISTOGRAM, STYLE_SOLID, 3, Yellow);
SetIndexBuffer(3, shuzu4);
SetIndexDrawBegin(0, 5);
SetIndexBuffer(0, shuzu1);
SetIndexBuffer(1, shuzu2);
SetIndexBuffer(2, shuzu3);
SetIndexBuffer(3, shuzu4);
return (0);
}

int deinit() {
return (0);
}

int start()
{
double a1;
double a2;
double a3;
double a4;
double c1;
double c2;
double c3;
double c4;
if (Bars <= 10) return (0);
barsshu = IndicatorCounted();
if (barsshu < 0) return (-1);
if (barsshu > 0) barsshu--;
for (int i = Bars - barsshu - 1; i >= 0; i--)
{
a1 = iMA(NULL, 0, period1, 0, mod, PRICE_CLOSE, i);
a2 = iMA(NULL, 0, period1, 0, mod, PRICE_LOW, i);
a3 = iMA(NULL, 0, period1, 0, mod, PRICE_OPEN, i);
a4 = iMA(NULL, 0, period1, 0, mod, PRICE_HIGH, i);
c1 = (shuzu3[i + 1] + (shuzu4[i + 1])) / 2.0; in front of here,shuzuj3[i+1] value is what
// Alert("shuzu3[i + 1="+shuzu3[i + 1]);
// Alert("shuzu4[i + 1="+shuzu4[i + 1]);
c4 = (a1 + a4 + a3 + a2) / 4.0;
c2 = MathMax(a4, MathMax(c1, c4));
c3 = MathMin(a3, MathMin(c1, c4));
if (c1 < c4)
{
shuzu1[i] = c3;
shuzu2[i] = c2;
}
else
{
shuzu1[i] = c2;
shuzu2[i] = c3;
}
shuzu3[i] = c1;
shuzu4[i] = c4;
}
return (0);
}
 

From here....

for (int i = Bars - barsshu - 1; i >= 0; i--) 
        {
        
                a1 = iMA(NULL, 0, period1, 0, mod, PRICE_CLOSE, i);
                a2 = iMA(NULL, 0, period1, 0, mod, PRICE_LOW, i);
                a3 = iMA(NULL, 0, period1, 0, mod, PRICE_OPEN, i);
                a4 = iMA(NULL, 0, period1, 0, mod, PRICE_HIGH, i);
                c1 = (shuzu3[i + 1] + (shuzu4[i + 1])) / 2.0; in front of here,shuzuj3[i+1] value is what
                // Alert("shuzu3[i + 1="+shuzu3[i + 1]);
                // Alert("shuzu4[i + 1="+shuzu4[i + 1]);
                c4 = (a1 + a4 + a3 + a2) / 4.0; 
                c2 = MathMax(a4, MathMax(c1, c4));
                c3 = MathMin(a3, MathMin(c1, c4));
                if (c1 < c4)
                        {
                                shuzu1[i] = c3;
                                shuzu2[i] = c2;
                        }
                else 
                        {
                                shuzu1[i] = c2;
                                shuzu2[i] = c3;
                        }
                shuzu3[i] = c1;
                shuzu4[i] = c4;
        }

shuzu4 is (average high + average low +average close +average open) / 4

c1 = (shuzu3[i + 1] + (shuzu4[i + 1])) / 2.0

c1 gets his value because (shuzu4[i + 1]) will get a value so that way shuzu3[i] = c1; will get also his value

Next posting of you Please use SRC button for source code

 

thank your reply.

ok

shuzu4 is (average high + average low +average close +average open) / 4 but shuzu4[i+1] is what? no media cal the value

shuzu3[i] = c1 ? c1 value is what? in front of cal c1,c1 value is?

 
zdj229:

thank your reply.

ok

shuzu4 is (average high + average low +average close +average open) / 4 but shuzu4[i+1] is what? no media cal the value

shuzu3[i] = c1 ? c1 value is what? in front of cal c1,c1 value is?

for (int i = Bars - barsshu - 1; i >= 0; i--) //What no media call the value ???   Learn the working of loops to calculate

Read the Book

Ever tried ???

Print(" shuzu4[i+1] =    " ,shuzu4[i+1])   

very helpfull....

 

thank you deVries

i can't understand you mean

examp bars=100 barshu=1

then for (int i = Bars - barsshu - 1; i >= 0; i--) = =for(i=98;i>=0;i++).....................

sorry,i really can't understand the loop

shuzu4[i+1] is what, i+1 have exceed the calculate range

 
for (int i = Bars - barsshu - 1; i >= 0; i--) 
        {
        
                a1 = iMA(NULL, 0, period1, 0, mod, PRICE_CLOSE, i);
                a2 = iMA(NULL, 0, period1, 0, mod, PRICE_LOW, i);
                a3 = iMA(NULL, 0, period1, 0, mod, PRICE_OPEN, i);
                a4 = iMA(NULL, 0, period1, 0, mod, PRICE_HIGH, i);
                c1 = (shuzu3[i + 1] + (shuzu4[i + 1])) / 2.0; in front of here,shuzuj3[i+1] value is what
                // Alert("shuzu3[i + 1="+shuzu3[i + 1]);
                // Alert("shuzu4[i + 1="+shuzu4[i + 1]);
                c4 = (a1 + a4 + a3 + a2) / 4.0; 
                c2 = MathMax(a4, MathMax(c1, c4));
                c3 = MathMin(a3, MathMin(c1, c4));
                if (c1 < c4)
                        {
                                shuzu1[i] = c3;
                                shuzu2[i] = c2;
                        }
                else 
                        {
                                shuzu1[i] = c2;
                                shuzu2[i] = c3;
                        }
                shuzu3[i] = c1;
                shuzu4[i] = c4;
          Print(i," shuzu4[i+1] =    " ,shuzu4[i+1]);    //   <<==== Play and trie out...  
        }