Forex
Google
New signals service!

Go Back   Forex Trading > Discussion Areas > Metatrader 4


Register in Forex TSD!
Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time).
Click here to register and get more information

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-11-2006, 06:54 PM
Junior Member
 
Join Date: Sep 2006
Posts: 9
Q0paz is on a distinguished road
Problem coding indicator

Guys,

I am trying to code an indicator which allows me to plot a horizontal grid spaced a specific number of points apart, anchored to a specific price high or low. Eg if the market makes a low at 1.1266 (USDCAD on 20061110) then I want to be able to plot horizontal lines a configurable distance apart up or down as the price moves up or down from that low.

Here is the code I have

Code:
//+------------------------------------------------------------------+
//|                                                  Market_Grid.mq4 |
//|                      Copyright © 2006, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, Market Analytics & Automated Trading Ltd" 
#property link      "http://www.blackboxfutures.com"

#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Gainsboro

//---- input parameters
extern double    base=1.1266;
extern double    incr=0.0050;
extern bool      Debug = true;


int i;

double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         | 
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   IndicatorBuffers(4);
   
   SetIndexStyle(0,DRAW_LINE, STYLE_DOT,1,indicator_color1);
   SetIndexBuffer(0, ExtMapBuffer1); 
   SetIndexStyle(1,DRAW_LINE, STYLE_DOT,1,indicator_color1);
   SetIndexBuffer(1, ExtMapBuffer2);
   SetIndexStyle(2,DRAW_LINE, STYLE_DOT,1,indicator_color1);
   SetIndexBuffer(2, ExtMapBuffer3);
   SetIndexStyle(3,DRAW_LINE, STYLE_DOT,1,indicator_color1); 
   SetIndexBuffer(3, ExtMapBuffer4);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       | 
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+ 
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   double _level0=0.0;
   double _level1=0.0 ;
   double _level2=0.0;
   double _level3=0.0;
   
   int    counted_bars=IndicatorCounted();
//----
      i=Bars-counted_bars-1;
      while(i>=0)
      {
         _level0 = URLevel(base, incr, i); 
         _level1 = _level0+incr;
         _level2 = _level0+(incr*2);
         _level3 = _level0-incr;
         if(Debug)
         {
            Print("_level0   :"  + _level0);
            Print("_level1   :"  + _level1); 
            Print("_level2   :"  + _level2);
            Print("_level3   :"  + _level3);
            Print("incr     : " + incr);
         }
         ExtMapBuffer1[i]= _level0; 
         ExtMapBuffer2[i]= _level1;
         ExtMapBuffer3[i]= _level2;
         ExtMapBuffer4[i]= _level3; 
         i--;
      }   
//----
   return(0);
  }
//+------------------------------------------------------------------+ 
double URLevel(double base, double incr, int idx)
{
   double offset = 0;
   double _urlevel = 0;
   
   offset = base - (MathFloor(base/incr) * incr);
   _urlevel = (MathFloor(Close[idx]/incr) * incr) + offset; 
   
   if(Debug)
   {
      Print("MathFloor(base/incr))   : " + MathFloor(base/incr));
      Print("Offset       : " + offset); 
      Print("URLevel   : " + _urlevel);
   }
   
   return(_urlevel);
  

}
Currently this plots continuous lines. When I open the indicator in the indicators list dialogbox, plots 2 to 4 (i.e. ExtMapBuffer1 2 and 3) are black... i.e. for some reason the indicator is not picking up that I have specified the plots to be in the color defined in the indicator_color1 property. Also all other propereties are not set. And despite specifiying STYLE_DOT in the SetIndexStyle method call it is plotting a dotted line. I have tried using DRAW_LINE and DRAW_SECTION. The effect I am trying to achieve is shown in the attached Market_Grid.gif . The effect I am getting is shown in USDCAD_Grid.gif.

Can anyone tell me how to get the plots as dots rather than dotted lines and point out how to get the Indicator to pick up the values I am specifying.

Thanks

Paz
Attached Images
File Type: gif Market_Grid.gif (4.3 KB, 36 views)
File Type: gif USDCAD_Grid.gif (19.5 KB, 31 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 11-13-2006, 10:30 AM
Junior Member
 
Join Date: Sep 2006
Posts: 9
Q0paz is on a distinguished road
problems solved :

Plotting dots

and

Reciprocal
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Coding Problem leeb Expert Advisors - Metatrader 4 3 01-29-2007 04:48 PM
High % Formation Need Help Coding Indicator doragio Metatrader 4 1 09-22-2006 01:10 AM
Coding help..How do I get indicator to filter instead of alert? Aaragorn Indicators - Metatrader 4 92 07-10-2006 05:29 PM
Help coding a cam indicator needed. DanielTyrkiel Suggestions for Trading Systems 5 11-29-2005 12:48 PM


All times are GMT. The time now is 12:16 AM.



Search Engine Friendly URLs by vBSEO 3.2.0 ©2008, Crawlability, Inc.