How to draw lines between TWO LOWEST/HIGHEST candles among last 300 bars ?

To add comments, please log in or register
Piotr
1271
Piotr  

I would like to draw automatically on 30 MIN chart two lines (support and resistance) indicated by the last 300 bars. From the last 300 bars indicator should find two MAXIMUM BARS (ONLY 2 HIGHEST BARS AMONG THE LAST 300 BARS) and draw the RED LINE and from the other hand the same indicator should find two MINIMUM BARS (ONLY 2 LOWEST BARS AMONG THE LAST 300 BARS) and draw the GREEN LINE as on the picture.

Piotr
1271
Piotr  

Nobody knows ?

Avery Horton
542
Avery Horton  
puncher:

I would like to draw automatically on 30 MIN chart two lines (support and resistance) indicated by the last 300 bars. From the last 300 bars indicator should find two MAXIMUM BARS (ONLY 2 HIGHEST BARS AMONG THE LAST 300 BARS) and draw the RED LINE and from the other hand the same indicator should find two MINIMUM BARS (ONLY 2 LOWEST BARS AMONG THE LAST 300 BARS) and draw the GREEN LINE as on the picture.


I wrote an indicator that does EXACTLY what you asked for


//+------------------------------------------------------------------+ 
//|   TRO_TrendLine                                                  | 
//|                                                                  | 
//|   Copyright © 2009, Avery T. Horton, Jr. aka TheRumpledOne       |
//|                                                                  |
//|   PO BOX 43575, TUCSON, AZ 85733                                 |
//|                                                                  |
//|   GIFTS AND DONATIONS ACCEPTED                                   | 
//|   All my indicators should be considered donationware. That is   |
//|   you are free to use them for your personal use, and are        |
//|   under no obligation to pay for them. However, if you do find   |
//|   this or any of my other indicators help you with your trading  |
//|   then any Gift or Donation as a show of appreciation is         |
//|   gratefully accepted.                                           |
//|                                                                  |
//|   Gifts or Donations also keep me motivated in producing more    |
//|   great free indicators. :-)                                     |
//|                                                                  |
//|   PayPal - THERUMPLEDONE@GMAIL.COM                               |  
//+------------------------------------------------------------------+ 
//| Use http://therumpledone.mbtrading.com/fx/ as your forex broker  |  
//| ...tell them therumpledone sent you!                             |  
//+------------------------------------------------------------------+ 
#property  copyright "Copyright © 2009, Avery T. Horton, Jr. aka TRO" 
#property  link      "http://www.therumpledone.com/" 
  
#property indicator_chart_window
 
extern int myBars = 300;  
  
extern color ColorTrendUp    = Red ;
extern color ColorTrendDn    = Blue ;
 
int cnt,nCurBar=0;

double r1,r2,r3,r4,r5,r6;
int rt1,rt2,rt3,rt4,rt5,rt6;
double s1,s2,s3,s4,s5,s6;
int st1,st2,st3,st4,st5,st6;
   
//+------------------------------------------------------------------+
int init()
  {
   deinit() ;
   return(0);
  }
  
//+------------------------------------------------------------------+
int deinit()
  {
    
   ObjectDelete("Trend DN-0");
   ObjectDelete("Trend Up-0");   
    return(0);
  }
  
//+------------------------------------------------------------------+
int start()
{
  
DoPlot() ;  

for(nCurBar=0; nCurBar<myBars-1; nCurBar++)
{
   if(Low[nCurBar] < Low[st1])
      {
      s6=s5; s5=s4; s4=s3; s3=s2; s2=s1; s1=Low[nCurBar];
      st6=st5; st5=st4; st4=st3; st3=st2; st2=st1; st1=nCurBar;
      }
   if(High[nCurBar] > High[rt1])
      {
      r6=r5; r5=r4; r4=r3; r3=r2; r2=r1; r1=High[nCurBar];
      rt6=rt5; rt5=rt4; rt4=rt3; rt3=rt2; rt2=rt1; rt1=nCurBar;
      }
}
 
ObjectMove("Trend DN-0",0,Time[st1],s1);
ObjectMove("Trend DN-0",1,Time[st2],s2);
ObjectMove("Trend UP-0",0,Time[rt1],r1);
ObjectMove("Trend UP-0",1,Time[rt2],r2);
  
WindowRedraw();   

Comment(

"s1 " , DoubleToStr(s1,Digits) , "\n" ,  
"st1 " , DoubleToStr(st1,Digits) , "\n" ,  
"s2 " , DoubleToStr(s2,Digits) , "\n" , 
"st2 " , DoubleToStr(st2,Digits) , "\n" ,  
"s3 " , DoubleToStr(s3,Digits) , "\n" ,  
"st3 " , DoubleToStr(st3,Digits) , "\n" ,  
"s4 " , DoubleToStr(s4,Digits) , "\n" , 
"st4 " , DoubleToStr(st4,Digits) , "\n" ,  

"r1 " , DoubleToStr(r1,Digits) , "\n" ,
"rt1 " , DoubleToStr(rt1,Digits) , "\n" ,    
"r2 " , DoubleToStr(r2,Digits) , "\n" ,  
"rt2 " , DoubleToStr(rt2,Digits) , "\n" ,        
"r3 " , DoubleToStr(r3,Digits) , "\n" ,
"rt3 " , DoubleToStr(rt3,Digits) , "\n" ,    
"r4 " , DoubleToStr(r4,Digits) , "\n" ,  
"rt4 " , DoubleToStr(rt4,Digits) , "\n" ,        

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

void DoPlot()
{
     
   if(cnt<2)
   {
      if (ObjectFind("Trend DN-"+cnt) != 0)
      {       
      ObjectCreate("Trend DN-"+cnt,OBJ_TREND,0,0,0,0,0);
      ObjectSet("Trend DN-"+cnt,OBJPROP_COLOR,ColorTrendDn);
      }
      
      if (ObjectFind("Trend UP-"+cnt) != 0)
      {        
      ObjectCreate("Trend UP-"+cnt,OBJ_TREND,0,0,0,0,0);
      ObjectSet("Trend Up-"+cnt,OBJPROP_COLOR,ColorTrendUp);
      }
   }   
      
    ObjectSet("Trend DN-0",OBJPROP_COLOR,ColorTrendDn);
    ObjectSet("Trend Up-0",OBJPROP_COLOR,ColorTrendUp);
    
}

//+------------------------------------------------------------------+


But it doesn't do exactly what you want...





From the last 300 bars indicator should find two MAXIMUM BARS (ONLY 2 HIGHEST BARS AMONG THE LAST 300 BARS) and draw the RED LINE and from the other hand the same indicator should find two MINIMUM BARS (ONLY 2 LOWEST BARS AMONG THE LAST 300 BARS) and draw the GREEN LINE as on the picture.


Look at the lines in the chart... They are plotted at the 2 Max and 2 Min bars for the period.

Piotr
1271
Piotr  

Everything will be OK, but ther is ONE PROBLEM.. I NEED draw trend lines AS:


SUPPORT LINE always UNDER prices (LOW) - current and historical

RESISTANCE LINE always ABOVE prices (HIGH) - current and historical


???

prg_mt4
27
prg_mt4  

Hello 

Can I create a line between 2 candles like Red Line in mql4?

line

Keith Watford
Moderator
17943
Keith Watford  
prg_mt4:

Hello 

Can I create a line between 2 candles like Red Line in mql4?


Be more specific

Alain Verleyen
38884
Alain Verleyen  
prg_mt4:

Hello 

Can I create a line between 2 candles like Red Line in mql4?


I don't think it's possible.
prg_mt4
27
prg_mt4  
Alain Verleyen:
I don't think it's possible.
thanks
To add comments, please log in or register