Is it possible to draw parallels from Close, without using buffers?

 

Hello,
Is it possible to draw parallels from Close, without using buffers?
Thank you,

Pierre8r

Code with buffers :

//+------------------------------------------------------------------+
//|                                                  Parallel001.mq4 |
//|                                       Copyright © 2012, Pierre8r |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2012, Pierre8r"
#property link      "http://www.metaquotes.net"


#property indicator_chart_window
#property indicator_buffers 3

#property indicator_color1 Green
#property indicator_color2 Yellow
#property indicator_color3 Red
//---- indicator parameters
extern double pourcent=0.01;

bool FirstBar = true;

//---- indicator buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];

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

   string short_name;
//---- drawing settings
   SetIndexStyle(0,DRAW_LINE);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexStyle(2,DRAW_LINE);
   IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
//---- indicator short name
   short_name="LBH(";
   IndicatorShortName(short_name+")");
//---- indicator buffers mapping
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexBuffer(2,ExtMapBuffer3);

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
  
  //---- check for possible errors
     if(IndicatorCounted()<0) return(-1);
  //---- main loop

   int pos=Bars-IndicatorCounted()-1;
//---- main calculation loop
   while(pos>=0)
       {

         ExtMapBuffer1[pos] = Close[pos]+(Close[pos]*(pourcent));
         ExtMapBuffer2[pos] = Close[pos]+(Close[pos]*(2*pourcent));
         ExtMapBuffer3[pos] = Close[pos]+(Close[pos]*(3*pourcent));

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



 
You could use objects but that'll slow things down allot.
 
tintin92:


Is it possible to draw parallels from Close, without using buffers?


int pos=Bars-IndicatorCounted()-1;

//---- main calculation loop

while(pos>=0){

    ExtMapBuffer1[pos] = Close[pos]+(Close[pos]*(pourcent));
    ExtMapBuffer2[pos] = Close[pos]+(Close[pos]*(2*pourcent));
    ExtMapBuffer3[pos] = Close[pos]+(Close[pos]*(3*pourcent));

    pos--;

}


You do not seem to be drawing parallel straight lines from a particular Close value. You are joining close points together with an artbitrary curve. Realistically you cannot do this any other way than with buffers. Drawing 100,000 objects is not an option.

Why do you not want to do it with buffers?

 
tintin92:
Is it possible to draw parallels from Close, without using buffers?
  1. Something like Linear Regression Channel - MQL4 Code Base perhaps?
 

Hi,

Thank for all answers.

Specially to ubzen and dabbler.

Pierre8r

Reason: