byOpenDaily_Levels

Author: Copyright � 2010, fx-system@mail.ru
Price Data Components
Series array that contains the highest prices of each barSeries array that contains the lowest prices of each barSeries array that contains open prices of each bar
Indicators Used
Indicator of the average true range
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
byOpenDaily_Levels
//+------------------------------------------------------------------+
//|                                          byOpenDaily_Levels.mq4  |
//|                                                fx-system@mail.ru |
//+------------------------------------------------------------------+
// Òîëüêî äëÿ ãðàôèêà 1 ÷àñ
#property copyright "Copyright © 2010, fx-system@mail.ru"
//----
#property indicator_chart_window
#property indicator_buffers 7
#property indicator_color1 Gold
#property indicator_width1 2
#property indicator_color2 Red
#property indicator_width2 2
#property indicator_color3 Lime
#property indicator_width3 2

#property indicator_color4 Red
#property indicator_width4 0
#property indicator_style4 STYLE_DASH
#property indicator_color5 DarkGreen
#property indicator_width5 0
#property indicator_style5 STYLE_DASH

#property indicator_color6 DarkGreen
#property indicator_color7 Red

//---- input parameters
extern int setFlatZone = 5; // äèàïàçîí ôëýòà â ïï, ÅÑËÈ < 10ïï ðàñ÷åò ïî ÷àñîâîìó ATR(SetFlatByATR)
                            // ðó÷íàÿ íàñòðîéêà äëÿ íàòÿãèâàíèÿ íà ÔëýòÀçèÿ è äëÿ êîíòðîëÿ íà èñòîðèè è äëÿ ...
                            // ëó÷øåå "ðó÷íîå" çíà÷åíèå = 19...21 (äëÿ åâðî)
extern int SetFlatByATR = 48;
extern bool sayLevels = true;    // âûâîä (ðèñîâàíèå) çíà÷åíèé óðîâíåé

//---- buffers
double DailyOpenBuffer[];
double LevelBUYBuffer[];
double LevelSELLBuffer[];
double TargetBUYBuffer[];
double TargetSELLBuffer[];
double UpSignal[]; // ñíà÷àëà õîòåëîñü ñòðåëêè, íî ïóñòü áóäåò öåëüÂÑÅÃÄÀ (200% êîðèäîðà)
double DnSignal[];

//---- variables

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   string short_name;
   IndicatorBuffers(7);
//---- indicator lines
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,DailyOpenBuffer);
   //SetIndexEmptyValue(0, 0.0);
   SetIndexLabel(0,"OpenÄíÿ"); 
        
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,LevelSELLBuffer);
   //SetIndexEmptyValue(1, 0.0);
   SetIndexLabel(1,"ÓðîâåíüSELLÏîñëåÏðîáîÿ");
   
   SetIndexStyle(2,DRAW_LINE);
   SetIndexBuffer(2,LevelBUYBuffer);
   //SetIndexEmptyValue(2, 0.0);
   SetIndexLabel(2,"ÓðîâåíüBUYÏîñëåÏðîáîÿ"); 
   
   SetIndexStyle(3,DRAW_LINE,STYLE_DASH);
   SetIndexBuffer(3,TargetBUYBuffer);
   //SetIndexEmptyValue(3, 0.0);
   SetIndexLabel(3,"ÓðîâåíüDN-Öåëü(300%)Buy?"); 
   
   SetIndexStyle(4,DRAW_LINE,STYLE_DASH);
   SetIndexBuffer(4,TargetSELLBuffer);
   SetIndexLabel(4,"ÓðîâåíüUP-Öåëü(300%)Sell?"); 
   
   SetIndexStyle(5,DRAW_LINE);
   SetIndexBuffer(5,UpSignal);
   //SetIndexEmptyValue(5, 0.0);
   SetIndexLabel(5,"ÓðîâåíüUP-Öåëü(200%)");
   
   SetIndexStyle(6,DRAW_LINE);
   SetIndexBuffer(6,DnSignal);
   SetIndexLabel(6,"ÓðîâåíüDN-Öåëü(200%)");
   
//---- name for DataWindow and indicator subwindow label

//   IndicatorShortName(short_name);

   return(0);
  }
//+------------------------------------------------------------------+
//| OpenDaily_Levels                                                 |
//+------------------------------------------------------------------+
int start()
  {
   if (Period() != 60)
    {
     Comment("ÒÎËÜÊÎ ÄËß ÃÐÀÔÈÊÀ 1 ×ÀÑ!!! ÏÅÐÅÊËÞ×ÈÒÜ ÍÀ Í1!!!");
     return (0);
    }
   int i,counted_bars = IndicatorCounted();
   double atrH1, highDaily, lowDaily, flat, flatWidth, Low161, High161;
   double LastHigh, LastLow;
   double open = iOpen(0,PERIOD_D1,0), low = iLow(0,PERIOD_D1,0), high = iHigh(0,PERIOD_D1,0);
   double atr = iATR(0,PERIOD_D1,5,0), Ma3, Ma5;
   double levelSELL = iLow(0,PERIOD_D1,1), levelBUY = iHigh(0,PERIOD_D1,1);
   string strTemp;
   int iX;
//----
   atrH1 = iATR(0,PERIOD_H1,SetFlatByATR,0);
   flat = setFlatZone*Point;
   flatWidth = 2*setFlatZone*Point;

   i = Bars - counted_bars - 1;
   // öèêë èíäèêàòîðà
   while(i >= 0)
     {
      if (TimeHour(Time[i]) == 0) 
      {
       open = Open[i]; // TimeHour
       low = Low[i];
       high = High[i];
      }
      DailyOpenBuffer[i] = open;
      LevelSELLBuffer[i] = open - flat;
      LevelBUYBuffer[i] = open + flat;
      if (setFlatZone < 10)
        {
         LevelSELLBuffer[i] = open - atrH1;
         LevelBUYBuffer[i] = open + atrH1;
         flatWidth = 2*atrH1;
        }
      // Öåëü Âñåãäà (2-êðàòíûé êîðèäîð)
      UpSignal[i]=LevelBUYBuffer[i] + flatWidth;
      DnSignal[i]=LevelSELLBuffer[i] - flatWidth;
      // Öåëü ÊàêÏðàâèëî (3-êðàòíûé êîðèäîð)
      TargetSELLBuffer[i] = LevelBUYBuffer[i] + 2*flatWidth;
      TargetBUYBuffer[i] = LevelSELLBuffer[i] - 2*flatWidth;
      i--;

     } // êîíåö öèêëà èíäèêàòîðà
   // Äîïîëíèòåëüíàÿ öåëü 161%
   Low161 = LevelSELLBuffer[1] - 0.5*flatWidth + 7*Point;
   DrawTrend ("ÓðîâåíüDN-Öåëü(150%)", 55, Low161, 0, Low161, Red, 0, 1, false, true);
   High161 = LevelBUYBuffer[1] + 0.5*flatWidth - 7*Point;
   DrawTrend ("ÓðîâåíüUP-Öåëü(150%)", 55, High161, 0, High161, Green, 0, 1, false, true);
   
   // Say Levels
      if (sayLevels)
       {
         DrawTxt("OpenÄíÿ", 0, DailyOpenBuffer[1], "                     " + DoubleToStr(DailyOpenBuffer[1], 4), Black, 9);
         DrawTxt("HighÔëýò", 0, LevelBUYBuffer[1], "                     " + DoubleToStr(LevelBUYBuffer[1], 4), Green, 9); 
         DrawTxt("LowÔëýò", 0, LevelSELLBuffer[1], "                     " + DoubleToStr(LevelSELLBuffer[1], 4), Red, 9); 
         DrawTxt("High200%", 0, UpSignal[1], "                     " + DoubleToStr(UpSignal[1], 4), Green, 9);
         DrawTxt("Low200%", 0, DnSignal[1], "                     " + DoubleToStr(DnSignal[1], 4), Red, 9);
         DrawTxt("High300%", 0, TargetBUYBuffer[1], "                     " + DoubleToStr(TargetBUYBuffer[1], 4), Green, 9); 
         DrawTxt("Low300%", 0, TargetSELLBuffer[1], "                     " + DoubleToStr(TargetSELLBuffer[1], 4), Red, 9);  
         DrawTxt("High150%", 0, High161, "                        " + DoubleToStr(High161, 4), Green, 8); 
         DrawTxt("Low150%", 0, Low161, "                        " + DoubleToStr(Low161, 4), Red, 8);  
       }
       else
        {
         ObjectDelete("OpenÄíÿ");
         ObjectDelete("HighÔëýò");
         ObjectDelete("LowÔëýò");
         ObjectDelete("High200%");
         ObjectDelete("Low200%");
         ObjectDelete("High300%");
         ObjectDelete("Low300%");
         ObjectDelete("High150%");
         ObjectDelete("Low150%");
        }
//++++++++++++++++++++++++++++++++++++++++++++++++++
//---------------- Close-LowÂ÷åðà, Close-High÷åðà (íà 1 ÷àñ)
     iX = iHighest(NULL,0,MODE_CLOSE,23,Hour() + 1);
     LastHigh = Close[iX];
     DrawTrend ("HighCloseÂ÷åðà(íèæå-ÎòìåíàUP)", Hour()+18, LastHigh, 0, LastHigh, DarkGreen, 5, 0, false, true);
     DrawTxt("txtHighCloseÂ÷åðà", Hour()+15, LastHigh+10*Point, DoubleToStr(LastHigh, 4), DarkGreen, 11);
     
     iX = iLowest(NULL,0,MODE_CLOSE,23,Hour() + 1);
     LastLow = Close[iX];
     DrawTrend ("LowCloseÂ÷åðà(âûøå-ÎòìåíàDN)", Hour()+18, LastLow, 0, LastLow, OrangeRed, 5, 0, false, true);
     DrawTxt("txtLowCloseÂ÷åðà", Hour()+15, LastLow-3*Point, DoubleToStr(LastLow, 4), OrangeRed, 11);
     
   return(0);
  }
  
  
int deinit()
  {
   ObjectDelete("HighCloseÂ÷åðà(íèæå-ÎòìåíàUP)");
   ObjectDelete("LowCloseÂ÷åðà(âûøå-ÎòìåíàDN)");
         ObjectDelete("OpenÄíÿ");
         ObjectDelete("HighÔëýò");
         ObjectDelete("LowÔëýò");
         ObjectDelete("High200%");
         ObjectDelete("Low200%");
         ObjectDelete("High300%");
         ObjectDelete("Low300%");
         ObjectDelete("High150%");
         ObjectDelete("Low150%");
         ObjectDelete("txtHighCloseÂ÷åðà");
         ObjectDelete("txtLowCloseÂ÷åðà");
   return(0);
  }
//+------------------------------------------------------------------+
//+++++++ Ãðàôèêà ++++++++++++++++++++++++++++++++++++++++++
//----------DrawTrend - ðèñóåò Òðåíä ïî 2-ì òî÷êàì
void DrawTrend (string TrendName, int iX1, double Y1, int iX2, double Y2, color iTrendColor, int iTrendWidth, int iTrendStyle, bool Ray, bool Back)
   {
   if (ObjectFind(TrendName) > -1) ObjectDelete(TrendName);
   ObjectCreate(TrendName, OBJ_TREND, 0, Time[iX1], Y1, Time[iX2], Y2);
   ObjectSet(TrendName, OBJPROP_COLOR, iTrendColor); // DarkBlue
   ObjectSet(TrendName, OBJPROP_WIDTH, iTrendWidth);
   ObjectSet(TrendName, OBJPROP_STYLE, iTrendStyle);
   ObjectSet(TrendName, OBJPROP_RAY, Ray);
   ObjectSet(TrendName, OBJPROP_BACK, Back);
   }

//----------DrawTxt - ðèñóåò Òåêñò
//         ObjectCreate("OpenÄíÿ", OBJ_TEXT, 0, Time[0], DailyOpenBuffer[1]);
//         ObjectSetText("OpenÄíÿ", "                     " + DoubleToStr(DailyOpenBuffer[1], 4) ,9,"Tahoma",Black); //

void DrawTxt (string TxtName, int iX1, double Y1, string Txt, color iTxtColor, int iTxtWidth)
   {
    if (ObjectFind(TxtName) > -1) ObjectDelete(TxtName);
    ObjectCreate(TxtName, OBJ_TEXT, 0, Time[iX1], Y1);
    ObjectSetText(TxtName, Txt, iTxtWidth, "Tahoma", iTxtColor);
   }

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

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

//+------------------------------------------------------------------+
//----------DrowMarker - ðèñóåò öåíîâóþ ìåòêó, ïðåäóïðåæäàþùèé çíà÷îê


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 ---