Download MetaTrader 5

How to Draw a Reference Lines Every 10 Pips - page 4

To add comments, please log in or register
We have launched Spanish and Portuguese versions of the website. Try them!
deansi
12
deansi 2012.12.27 02:28  

Its ok,

I got it to work ..!!  8)

 Thanks to those who contributed the ideas for this.

deansi
12
deansi 2012.12.27 23:01  

The result.... at 10pips per bar. 

for me its much easier on the eyes than the default grid, and takes half a second to see how many pips movement youre looking at. 

 new bars .mq4

paul.seldon
415
paul.seldon 2014.12.29 14:17  
//+------------------------------------------------------------------+
//|                                                       bgColorChanges10_20_30_40_50.mq4 |
//|                      Copyright ?2009, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright ?2009, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#property indicator_chart_window
#define ONDA_BEGINS   0
#define ONDA_CONTAINS 1


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
    for (int ix = 0; ix < nLines; ix++) // delete my horizontal lines
      {
      ObjectDelete("tensLines"+ix);
      }

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
    int nLines = 40;                                   // Number of total line to draw
   double lineInterval = 0.0010;                      // Interval between lines
   double normPrice = NormalizeDouble(Close[1],3);    // Current price is rounded to nearest "10"

   for (int ix = 0; ix < nLines; ix++)                // Loop span number of times
      {
      if(ObjectFind("tensLines"+ix) < 0) 
         ObjectCreate("tensLines"+ix, OBJ_HLINE, 0, 0, normPrice+((ix-(nLines/2))*lineInterval));    // Place half above and half below the current price

      else ObjectSet("tensLines"+ix, OBJPROP_PRICE1, normPrice+((ix-(nLines/2))*lineInterval));
      ObjectSet("tensLines"+ix,OBJPROP_COLOR,DarkSlateGray);      // Make the lines look better
      }
 
//----
   return(0);
  }
//+------------------------------------------------------------------+

void ObjectNameDeleteAll(string name, int where=ONDA_BEGINS, int type=EMPTY)
{
    for(int iObj=ObjectsTotal()-1; iObj >= 0; iObj--)
    {
        string on   = ObjectName(iObj);
        int    iPos = StringFind(on, name);
        if (iPos < 0)                         continue;
        if (iPos > 0 && where == ONDA_BEGINS) continue;
        if      (type == EMPTY))         ObjectDelete(on);
        else if (type == ObjectType(on)) ObjectDelete(on);
    }
}



//---

It doesn't work.  Many errors.  What needs to be fixed?

Also, when it goes higher timeframe, I want it to be changed,

     ===> 1Min ~ 30 Min ==> every 10 pips  

     ===> 1 Hour  ======>  every 50 pips 

     ===>  4 Hour, Daily ======> every 100 pips

     ===> Weekly, Monthly ===> every 1000 pips

  

Any help? Rectangles are desired instead of lines which can cause confusion with Resistance and Support Lines.

Please help, thanks in advance ~  

     

1234
To add comments, please log in or register