static array ? - page 5

 
AHHHHHHHHH! Now he tells me LOL

Ok here is what I got something a little better with some results, I don't completely understand the results but I think I can figure it out from there and understand why I could NEVER get a result

Thanks

//+------------------------------------------------------------------+
//|                                                  Agent86_5min.mq4 |
//|                                                    Unfinished POS |
//|                                    
//+------------------------------------------------------------------+
#property copyright "Unfinished POS by Agent86"


//---- input parameters
extern double    TakeProfit=20.0;
extern double    Lots=0.1;
extern double    StopLoss=15.0;
extern int MagicNumber=123486;

double v1[5];
double v2[];
double v3[];
double val1;
double val2;
double val3;


//++++ These are adjusted for 5 digit brokers.

int     pips2points;    // slippage  3 pips    3=points    30=points
double  pips2dbl;       // Stoploss 15 pips    0.0015      0.00150
int     Digits.pips;    // DoubleToStr(dbl/pips2dbl, Digits.pips)

    // OrderSend(... Slippage.Pips * pips2points, Bid - StopLossPips * pips2dbl
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
   if (Digits == 5 || Digits == 3)
   {    // Adjust for five (5) digit brokers.
      pips2dbl    = Point*10; pips2points = 10;   Digits.pips = 1;
   } 
   else 
    {    
      pips2dbl    = Point;    pips2points =  1;   Digits.pips = 0; 
    }
    // OrderSend(... Slippage.Pips * pips2points, Bid - StopLossPips * pips2dbl
     
   
    
//---- 

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 
   
//----
   return(0);
  }
   
    
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
  
  
   double   faster = iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,1), //MODE_MAIN
            slower = iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,1); //MODE_SIGNAL
            
  
          
   
    for(int i=Bars; i >= 0; i--)
     {
      val1=iFractals(NULL, 0, MODE_UPPER,i);
   
      // Print (val1, (" val1")); //will print some 0's
      if (val1 > 0)
         {        
          v1[i]=High[i];
 
         }
      else          
         {
         v1[i]=v1[i+1];
         }
        

      val2=iFractals(NULL, 0, MODE_LOWER,i);
     
      if (val2 > 0) 
         {
         v2[i]=Low[i];
         }
      else          v2[i]=v2[i+1];
       
     }   
     
     for(i=Bars; i >= 0; i--)
     {
     val1=iFractals(NULL, 0, MODE_UPPER,i);
     if(val1>0)
      {
      double v1[6];
      v1[5]=High[i];
      Print ("v1[", 5, "]= ", v1[5]);
      }
     }
     
        
                       
        
           

//---- 

 
                    
        

                
   return(0);
  }    

//+------------------------------------------------------------------+
2011.09.21 10:54:46 2011.01.03 02:28 Agent86_5min EURUSD,M5: v1[5]= 1.3312
2011.09.21 10:54:46 2011.01.03 02:28 Agent86_5min EURUSD,M5: v1[5]= 1.3315
2011.09.21 10:54:46 2011.01.03 02:28 Agent86_5min EURUSD,M5: v1[5]= 1.3301
2011.09.21 10:54:46 2011.01.03 02:28 Agent86_5min EURUSD,M5: v1[5]= 1.3301
2011.09.21 10:54:46 2011.01.03 02:28 Agent86_5min EURUSD,M5: v1[5]= 1.3302
2011.09.21 10:54:46 2011.01.03 02:28 Agent86_5min EURUSD,M5: v1[5]= 1.3296
2011.09.21 10:54:46 2011.01.03 02:28 Agent86_5min EURUSD,M5: v1[5]= 1.3293
2011.09.21 10:54:46 2011.01.03 02:28 Agent86_5min EURUSD,M5: v1[5]= 1.3292
2011.09.21 10:54:46 2011.01.03 02:28 Agent86_5min EURUSD,M5: v1[5]= 1.3293
2011.09.21 10:54:46 2011.01.03 02:28 Agent86_5min EURUSD,M5: v1[5]= 1.3292
2011.09.21 10:54:46 2011.01.03 02:28 Agent86_5min EURUSD,M5: v1[5]= 1.3284
2011.09.21 10:54:46 2011.01.03 02:28 Agent86_5min EURUSD,M5: v1[5]= 1.3299
2011.09.21 10:54:46 2011.01.03 02:28 Agent86_5min EURUSD,M5: v1[5]= 1.3306
2011.09.21 10:54:46 2011.01.03 02:28 Agent86_5min EURUSD,M5: v1[5]= 1.3325
2011.09.21 10:54:46 2011.01.03 02:28 Agent86_5min EURUSD,M5: v1[5]= 1.3361
2011.09.21 10:54:46 2011.01.03 02:28 Agent86_5min EURUSD,M5: v1[5]= 1.3343
2011.09.21 10:54:46 2011.01.03 02:28 Agent86_5min EURUSD,M5: v1[5]= 1.3399
2011.09.21 10:54:46 2011.01.03 02:28 Agent86_5min EURUSD,M5: v1[5]= 1.3419
2011.09.21 10:54:46 2011.01.03 02:28 Agent86_5min EURUSD,M5: v1[5]= 1.3422
2011.09.21 10:54:46 2011.01.03 02:28 Agent86_5min EURUSD,M5: v1[5]= 1.3422
2011.09.21 10:54:46 2011.01.03 02:28 Agent86_5min EURUSD,M5: v1[5]= 1.3398
2011.09.21 10:54:46 2011.01.03 02:28 Agent86_5min EURUSD,M5: v1[5]= 1.3374
2011.09.21 10:54:46 2011.01.03 02:28 Agent86_5min EURUSD,M5: v1[5]= 1.3375
2011.09.21 10:54:46 2011.01.03 02:28 Agent86_5min EURUSD,M5: v1[5]= 1.3378
2011.09.21 10:54:46 2011.01.03 02:28 Agent86_5min EURUSD,M5: v1[5]= 1.3387
2011.09.21 10:54:46 2011.01.03 02:28 Agent86_5min EURUSD,M5: v1[5]= 1.3389
2011.09.21 10:54:46 2011.01.03 02:28 Agent86_5min EURUSD,M5: v1[5]= 1.3389
2011.09.21 10:54:46 2011.01.03 02:28 Agent86_5min EURUSD,M5: v1[5]= 1.3383
2011.09.21 10:54:46 2011.01.03 02:28 Agent86_5min EURUSD,M5: v1[5]= 1.3373
2011.09.21 10:54:46 2011.01.03 02:28 Agent86_5min EURUSD,M5: v1[5]= 1.3372
2011.09.21 10:54:46 2011.01.03 02:28 Agent86_5min EURUSD,M5: v1[5]= 1.3368
2011.09.21 10:54:46 2011.01.03 02:28 Agent86_5min EURUSD,M5: v1[5]= 1.3356
2011.09.21 10:54:46 2011.01.03 02:28 Agent86_5min EURUSD,M5: v1[5]= 1.3366
2011.09.21 10:54:46 2011.01.03 02:28 Agent86_5min EURUSD,M5: v1[5]= 1.3369
2011.09.21 10:54:46 2011.01.03 02:28 Agent86_5min EURUSD,M5: v1[5]= 1.3386
2011.09.21 10:54:46 2011.01.03 02:28 Agent86_5min EURUSD,M5: v1[5]= 1.3361
2011.09.21 10:54:46 2011.01.03 02:28 Agent86_5min EURUSD,M5: v1[5]= 1.3301
2011.09.21 10:54:46 2011.01.03 02:28 Agent86_5min EURUSD,M5: v1[5]= 1.3296
2011.09.21 10:54:46 2011.01.03 02:28 Agent86_5min EURUSD,M5: v1[5]= 1.3297
2011.09.21 10:54:46 2011.01.03 02:28 Agent86_5min EURUSD,M5: v1[5]= 1.3297
2011.09.21 10:54:46 2011.01.03 02:28 Agent86_5min EURUSD,M5: v1[5]= 1.3297
2011.09.21 10:54:46 2011.01.03 02:28 Agent86_5min EURUSD,M5: v1[5]= 1.3301
2011.09.21 10:54:46 2011.01.03 02:28 Agent86_5min EURUSD,M5: v1[5]= 1.3303
2011.09.21 10:54:46 2011.01.03 02:28 Agent86_5min EURUSD,M5: v1[5]= 1.3314
2011.09.21 10:54:46 2011.01.03 02:28 Agent86_5min EURUSD,M5: v1[5]= 1.3307
2011.09.21 10:54:46 2011.01.03 02:28 Agent86_5min EURUSD,M5: v1[5]= 1.3307
2011.09.21 10:54:46 2011.01.03 02:28 Agent86_5min EURUSD,M5: v1[5]= 1.3302
2011.09.21 10:54:46 2011.01.03 02:28 Agent86_5min EURUSD,M5: v1[5]= 1.3301
2011.09.21 10:54:46 2011.01.03 02:28 Agent86_5min EURUSD,M5: v1[5]= 1.3294
2011.09.21 10:54:46 2011.01.03 02:28 Agent86_5min EURUSD,M5: v1[5]= 1.3297
2011.09.21 10:54:46 2011.01.03 02:28 Agent86_5min EURUSD,M5: v1[5]= 1.3292
2011.09.21 10:54:46 2011.01.03 02:28 Agent86_5min EURUSD,M5: v1[5]= 1.3292
2011.09.21 10:54:46 2011.01.03 02:28 Agent86_5min EURUSD,M5: v1[5]= 1.3292
2011.09.21 10:54:46 2011.01.03 02:28 Agent86_5min EURUSD,M5: v1[5]= 1.3293
2011.09.21 10:54:46 2011.01.03 02:28 Agent86_5min EURUSD,M5: v1[5]= 1.329
 
So now I can get back to figuring out how to refer to the previous fractals

Thanks

 
There is always an explanation . . . you just need to find it. :-)
 
RaptorUK:

Yes, Indicator buffers are handled differently to ordinary arrays.

v[i] is not declaring the Array, it's just one of the elements . . but double v[]; is an array with zero elements . . so v[anything] always = 0

this is confusing to me.
so you can actually put values into the array and yet since it's not declared there is no way to access those elements without knowing which element it was/is ? right ?

So how does the buffer know how to draw the line of v1[i] if there is zero elements in the array. ?

Is it because it's really more of just a static bool and not really acting like like an array at that point. meaning High[i] = True, so draw High[i] ?
But draws it with NO value actually in the element just True and ok to draw High[i] at that moment ?

Please clarify if I'm not even close on this

And thanks for the tutoring
 

Indicator buffers are special Arrays . . . don't mix up Arrays and Buffers, they are similar yet different.

In the original code v1[] and v2[] are buffers, in your latest code they are Arrays, when you declare an Array you have to give it a size, for example, v1[50] has 50 elements from v1[0] to v1[49]. The Buffer automatically Resizes when there are more elements needed and the values shift along in the Buffer automatically. Consider the currently forming bar, bar 0, when this bar completes an Indicator value associated with that bar has to shift to index 1 . . . this is done automatically with Buffers . . if you want to so something similar with Arrays you can, but you have to code it yourself.

 
Ok, I see, I just didn't know that buffers were not really the same, this is the very thing I needed to understand and I likely would have figured this out a while ago.

Thanks
 
for(i=Bars; i >= 0; i--)
      {
      val3=iFractals(NULL, 0, MODE_UPPER,i);
      if(val3>0)
         {      
         v3[1]=High[i];
         double v3[9];
// if I put v3[1]=High[i]; here in stead of above it will not draw the line, probably because of this buffer topic again
         Print ("v1[", 1, "]= ", v3[1]);
         }
      }

Anyhow I think I might make some good progress now


I see that I can put this line just above the declaration of the array and it shows the indicator, however will only print 0, and if I put it below it prints the value

 
May I ask about iFractals and when val1>0

I'm assuming this means ==True and then continues

So at the point that this is true, how can I know this value since simply printing would print an ongoing changes in the value as long as it is true

And also declaring the array and then declaring an element in the array such as v1[3]=High[i] print results also continue to change as val1>0

So I'm trying to understand this and how I might freeze time at the moment it will be val1>0 or how do I know what the actual fractal value is without using the [i] value in the buffer since I cannot get the value from the buffer as we discussed earlier that [i] is not declaring the array and is itself undeclared. Well partially undeclared.

So I guess declaring the array and assigning a value as High[i] will produce the printing results I want however, it's not fixed as it is with the indicator so how does the indicator have a fixed value and how would I reproduce this in order to use this value or rename it as some other variable to be useful.

Please advise

Thanks






 
Maybe you should start by explaining what you are trying to do . . . . without mentioning any code at all . . just plain English. It will probably make things clearer for both of us . . ;-)
 
RaptorUK:
Maybe you should start by explaining what you are trying to do . . . . without mentioning any code at all . . just plain English. It will probably make things clearer for both of us . . ;-)
LOL ok

I guess I just want to learn to refer to the ifractals which the signal itself would show on the chart
Not all of them in general but to pick 1, or a previous one, of a high and/or a low and select them for use.
To use in a sort of ABCD naming scheme

Since iFractals seems to almost do what I was going to create on my own for this use I wanted to be able to give these fractals a variable name

So that I might design code to refer to these fixed iFractals as shown in the indicator and as shown for v1[i]=High[i] which continues to be shown until a new one is formed. The indicator show the value which stays fixed

So I was going to attempt to create a code that would create a variable for lets say the current v1[i]=High[i] and this might be A but I want a fixed value like in the indicator not a moving value like my Print statement.

Then I might like to select from a previous High[i] to mark it as A or B it might be C if(A>High[i] at that time) and so on. To try and come up with a good ABCD scheme for using in another part of a completely different strategy. But I noticed a lot of people use this type of ABCD scheme with fibs and many other parts and indicators but I was just wanting to learn how to create a basic ABCD scheme and perhaps even later make it draw trend lines based on these ABCD's etc.

And many other things, but for now just an ABCD type of thing.

Thanks