why isn't it plotting the formula?

 
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Red
//---- input parameters
 
//---- buffers
double ExtMapBuffer1[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicator drawing
   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,3,Green);
   SetIndexBuffer(0,ExtMapBuffer1);
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int counted_bars = IndicatorCounted();
   int pos = Bars - counted_bars; 
     
 //----
   
   
   if (counted_bars<0) return(-1);
     
   if (counted_bars>0) counted_bars--;
   
   while(pos>=0)
    {
           
       
                
         double MACD = iMACD(NULL,0,12,26,9,PRICE_CLOSE,0,pos);
         double Momentum = iMomentum(NULL,0,9,PRICE_CLOSE,pos);
         double Volu = iVolume(NULL,0,pos);
         
         //Main Forumla
         double preFormula = MathPow((MACD)/Momentum,Volu);
         double Formula = iMA(NULL,0,2,pos,MODE_SMA,preFormula,pos);
                       
         ExtMapBuffer1[pos] = Formula;
          
         Alert(preFormula);
        
         
         pos--;
     }
it will do nothing. just spits out an empty indicator. its supposed to calculate that preFormula for each pos. then use preFormula's value for drawing an SMA that will be plotted.

please help, and if all goes well, i can share you the rest of the goods :)

 
could you place the all of the code?
 
old_man:
could you place the all of the code?

nothing much besides windows.
 
it draws the line at right most of the window , I think you need to refine your formula
 
old_man:
it draws the line at right most of the window , I think you need to refine your formula

okay i made some adjustments. i created two buffers placed formula in extmapbuffer1, and the moving average on to extmapbuffer2. i see where the problem lies. its when i divide by the momentum, it results in a flat line. although this is very weird. since macd devided momentum shouldnt yield zero. im seeing if i have to use iMomentumOnArray method or not.....
 

         double Formula = iMA(NULL,0,2,pos,MODE_SMA,preFormula,pos);
                       
. 

I Think you can not use the value of the (bold face) parameter here

this is the mistake

 
i fixd that by replacing boldface with pos. also storing iMA in a second buffer. i was able to graph a portion of the formula. however, in the formula, when i divide by momentum, the graph wont even bother working. i dont see why, even tho the result is a huge number, mt4 should be able to graph it. it seems like when i divide MACD  by ANYTHING at all, it will not bother calculating. .
 

double Formula = iMA(NULL,0,2,pos,MODE_SMA,preFormula,pos);
should be:

double Formula = iMA(NULL,0,2,0,MODE_SMA,preFormula,pos);

 
DxdCn:

double Formula = iMA(NULL,0,2,pos,MODE_SMA,preFormula,pos);
should be:

double Formula = iMA(NULL,0,2,0,MODE_SMA,preFormula,pos);


okay. that wasn't the problem. but i think something wrong with Volume or Momentum.

this Custom indicator supposed to be producing oscillating sine graphs, but i think the author which i found this from the book is scammer, since its not possible to be producing such graphs with high numbers such as Volume.

 

please refer to this link for full information.

http://www.forexfactory.com/showthread.php?p=1550118#post1550118

 
yari:


         double preFormula = MathPow((MACD)/Momentum,Volu);

MathPow() is likely to return either 0 or infinity if Volu is noticably larger than 1.