Indicator Question - page 2

 
1 for True, or 0 for False right ?

I'll think about it some more tomorrow, and see if I can figure this out.
 
Agent86:
1 for True, or 0 for False right ? <---- this is right, BUT

I'll think about it some more tomorrow, and see if I can figure this out.


UK is referring more to your MACD values.
 
faster and slower are doubles not bool . . . work through the loop from it's initial value and maybe 3 iterations, so for values of Bars, Bars-1, Bars-2 . . . what are the values of faster and slower ?
 
//+------------------------------------------------------------------+
//|                                   
//+------------------------------------------------------------------+


#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Red
#property indicator_color2 Blue
#property indicator_color3 White

//---- buffers
double v1[];
double v2[];
double v3[];
double val1;
double val2;
double val3;
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int init()
  {
//----
   IndicatorBuffers(3);

   SetIndexArrow(0, 111);
   SetIndexStyle(0,DRAW_ARROW,STYLE_DOT,1,Blue);
   SetIndexBuffer(0, v1);
   SetIndexLabel(0,"Resistance");
   

   SetIndexArrow(1, 111);
   SetIndexStyle(1,DRAW_ARROW,STYLE_DOT,1,Red);
   SetIndexBuffer(1, v2);
   SetIndexLabel(1,"Support");
  
   
   SetIndexArrow(2, 111);
   SetIndexStyle(2,DRAW_ARROW,STYLE_DOT,1,White);
   SetIndexBuffer(2, v3);
   SetIndexLabel(2,"High A");
   
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
  {
   
   int i=Bars;
   
   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(i=Bars; i>=0; i--)
     {
      val1=iFractals(NULL, 0, MODE_UPPER,i);
      if (val1 > 0)
         {                             
          v1[i]=High[i]; 
                         
          Print ("v1[", i, "]= ", v1[i], " if");
          Print ("i=",i, " faster=", faster);
          Print ("i=",i, " slower=",slower);
          }    
               
      else          
         {
         //v1[i]=v1[i+1];
         //Print ("v1[", i, "]= ", v1[i], " else");
         }
      
      val2=iFractals(NULL, 0, MODE_LOWER,i);
      if (val2 > 0)
         {
          v2[i]=Low[i];
          
          Print ("v2[", i, "]= ", v2[i], " if");
         }
          
      else          
         {
         //v2[i]=v2[i+1]; 
         //Print ("v2[", i, "]= ", v2[i], " else");         
         }
      }

   
     
//----
   return(0);
  }
//+------------------------------------------------------------------+




2011.09.28 16:43:30 sup_res EURUSD,M5: i=411 faster=-0.0005

2011.09.28 16:43:30 sup_res EURUSD,M5: v1[411]= 1.3522 if
2011.09.28 16:43:30 sup_res EURUSD,M5: v2[414]= 1.3495 if
2011.09.28 16:43:30 sup_res EURUSD,M5: i=414 slower=-0.0007
2011.09.28 16:43:30 sup_res EURUSD,M5: i=414 faster=-0.0005
2011.09.28 16:43:30 sup_res EURUSD,M5: v1[414]= 1.3527 if
2011.09.28 16:43:30 sup_res EURUSD,M5: i=417 slower=-0.0007
2011.09.28 16:43:30 sup_res EURUSD,M5: i=417 faster=-0.0005
2011.09.28 16:43:30 sup_res EURUSD,M5: v1[417]= 1.3528 if
2011.09.28 16:43:30 sup_res EURUSD,M5: v2[419]= 1.3506 if
2011.09.28 16:43:30 sup_res EURUSD,M5: i=420 slower=-0.0007
2011.09.28 16:43:30 sup_res EURUSD,M5: i=420 faster=-0.0005
2011.09.28 16:43:30 sup_res EURUSD,M5: v1[420]= 1.3523 if
2011.09.28 16:43:30 sup_res EURUSD,M5: i=426 slower=-0.0007
2011.09.28 16:43:30 sup_res EURUSD,M5: i=426 faster=-0.0005
2011.09.28 16:43:30 sup_res EURUSD,M5: v1[426]= 1.3522 if
2011.09.28 16:43:30 sup_res EURUSD,M5: v2[429]= 1.3481 if


Prints this when running the indicatator

But the very same code for an EA does not print the array

2011.09.28 16:43:48 2011.01.02 18:42 Agent86_5min EURUSD,M5: i=227 faster=-0.0015
2011.09.28 16:43:48 2011.01.02 18:42 Agent86_5min EURUSD,M5: v1[227]= 0 if
2011.09.28 16:43:48 2011.01.02 18:42 Agent86_5min EURUSD,M5: v2[230]= 0 if
2011.09.28 16:43:48 2011.01.02 18:42 Agent86_5min EURUSD,M5: i=232 slower=-0.0013
2011.09.28 16:43:48 2011.01.02 18:42 Agent86_5min EURUSD,M5: i=232 faster=-0.0015
2011.09.28 16:43:48 2011.01.02 18:42 Agent86_5min EURUSD,M5: v1[232]= 0 if
2011.09.28 16:43:47 2011.01.02 18:28 Agent86_5min EURUSD,M5: i=825 faster=-0.0015
2011.09.28 16:43:47 2011.01.02 18:28 Agent86_5min EURUSD,M5: v1[825]= 0 if
2011.09.28 16:43:47 2011.01.02 18:28 Agent86_5min EURUSD,M5: i=829 slower=-0.0008
2011.09.28 16:43:47 2011.01.02 18:28 Agent86_5min EURUSD,M5: i=829 faster=-0.0015
2011.09.28 16:43:47 2011.01.02 18:28 Agent86_5min EURUSD,M5: v1[829]= 0 if
2011.09.28 16:43:47 2011.01.02 18:28 Agent86_5min EURUSD,M5: i=832 slower=-0.0008
2011.09.28 16:43:47 2011.01.02 18:28 Agent86_5min EURUSD,M5: i=832 faster=-0.0015
2011.09.28 16:43:47 2011.01.02 18:28 Agent86_5min EURUSD,M5: v1[832]= 0 if
2011.09.28 16:43:46 2011.01.02 18:13 Agent86_5min EURUSD,M5: i=240 faster=-0.0011
2011.09.28 16:43:46 2011.01.02 18:13 Agent86_5min EURUSD,M5: v1[240]= 0 if
2011.09.28 16:43:46 2011.01.02 18:13 Agent86_5min EURUSD,M5: v2[241]= 0 if
2011.09.28 16:43:46 2011.01.02 18:13 Agent86_5min EURUSD,M5: v2[245]= 0 if
2011.09.28 16:43:46 2011.01.02 18:13 Agent86_5min EURUSD,M5: i=245 slower=-0.0003
2011.09.28 16:43:46 2011.01.02 18:13 Agent86_5min EURUSD,M5: i=245 faster=-0.0011
2011.09.28 16:43:46 2011.01.02 18:13 Agent86_5min EURUSD,M5: v1[245]= 0 if
2011.09.28 16:43:46 2011.01.02 18:13 Agent86_5min EURUSD,M5: v2[249]= 0 if


I don't know why it's resorting back to not printing the array again, because it's the same exact code as the indicator
Anyhow, I'll work on the indicator for now.

The values appear to be various from 4 digit fractional numbers to negative 4 digit fractional numbers

If I change the iMACD shift to i, then faster and slower = 0 all the time

 
Agent86:

I tried inserting if(faster > slower) into various areas of the code just to play with the idea. Normally these ideas would work in an EA but not in an indicator

IE if(v1 > 0 && faster > slower)

but this causes the indicator to disappear.

Try this change
//   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(i=Bars-1; i>=0; i--)
     {
   double   faster = iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,i), //MODE_MAIN
            slower = iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,i); //MODE_SIGNAL        
 
Agent86:


I don't know why it's resorting back to not printing the array again, because it's the same exact code as the indicator


You can't use Indicator Buffers in an EA . . this explains it : https://www.mql5.com/en/articles/1456

faster and slower are the same values all throughout the loop and the changing values of i, is that what you want and need ?

 
RaptorUK:

You can't use Indicator Buffers in an EA . . this explains it : https://www.mql5.com/en/articles/1456

faster and slower are the same values all throughout the loop and the changing values of i, is that what you want and need ?


Ok thanks for the link. I forgot about this. It's a lot of info for me to recall. Noobiness handicap LOL.

So anyhow, I was trying to make the high fractals only form when another condition occurs such as iMACD crosses, or EMA crosses or some other indicator crosses.
So that the fractals will only show on the indicator when all the conditions are met.
Then I would work on the low fractals with similar conditions as well.

I will likely try to add even more complex conditions too just to learn how to do it. I mean it may not be iFractals, but some other indicator with various conditions coupled with other indicators as well.

Design is a major problem for me because I'm not experienced so I have not seen many of the tactics or theories used in general code. So I can only learn by reading other peoples codes for now to see how they work and try to understand what they have done and learn from it.

Anyhow I'll keep working on it, thanks
 
WHRoeder:
Try this change
Hmmm interesting

So the variable has to be declared within the loop also.


Ok this should be fun to play around with now, thanks everyone

 

I prefer instantiating just once, all looping vrbs, out of the loop, first. If you declare them inside the loop, for every iteration, the compiler creates new variable. even though they look the same, actually they are not.

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(i=Bars-1; i>=0; i--)
     {
            faster = iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,i), //MODE_MAIN
            slower = iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,i); //MODE_SIGNAL 
 
diostar:
I prefer instantiating just once, all looping vrbs, out of the loop, first. If you declare them inside the loop, for every iteration, the compiler creates new variable. even though they look the same, actually they are not.
Exactly how did you come to that conclusion and what is the functional difference?