DSRS
Price Data Components
Series array that contains close prices for each barSeries array that contains open prices of each barSeries array that contains the highest prices of each barSeries array that contains the lowest prices of each bar
2 Views
0 Downloads
0 Favorites
DSRS
//+------------------------------------------------------------------+
//|                  Daily Support and Resistance Special            |
//|                                                         DSRS.mq4 |
//|                                              Developed by mqldev |
//|                                            http://www.mqldev.com |
//+------------------------------------------------------------------+

#property link      "http://www.mqldev.com"


#property indicator_chart_window

extern color   ResistanceColor = Red;
extern color   SupportColor    = Blue;

int init()
{
   DelObjs();
   return(0);
}
int deinit()
{
   DelObjs();
   return(0);
}

void start()
{
   double c = iClose(NULL,PERIOD_D1,1);
   double o = iOpen(NULL,PERIOD_D1,1);
   double h = iHigh(NULL,PERIOD_D1,1);
   double l = iLow(NULL,PERIOD_D1,1);
   
   
   Print("close:",c," open:",o," high:",h," low:",l);
   
   if (c>=o)
   {
      DrawLine(h,"Resistance",ResistanceColor);
      DrawLine(o,"Support",SupportColor);
   }
   else
   {
      DrawLine(o,"Resistance",ResistanceColor);
      DrawLine(l,"Support",SupportColor);
   }

   return(0);
}

int DrawLine(double price  , string Obj , color clr)
{

   int objs = ObjectsTotal();
   string name;
   for(int cnt=ObjectsTotal()-1;cnt>=0;cnt--)
   {
      name=ObjectName(cnt);
      if (StringFind(name,Obj,0)>-1) 
      {
         ObjectMove(Obj,0,Time[0],price);
         ObjectsRedraw();
         return(1);
      }
   }
   ObjectCreate(Obj,OBJ_HLINE,0,0,price);
   ObjectSet(Obj,OBJPROP_COLOR,clr);
   WindowRedraw();
   return(0);
}

void DelObjs()
{
   int objs = ObjectsTotal();
   string name;
   for(int cnt=ObjectsTotal()-1;cnt>=0;cnt--)
   {
      name=ObjectName(cnt);
      if (StringFind(name,"L",0)>-1) ObjectDelete(name);
      WindowRedraw();
   }
}


Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---