protorgovka 1

Miscellaneous
Implements a curve of type %1
2 Views
0 Downloads
0 Favorites
protorgovka 1
ÿþ#property copyright "Copyright © 2021, http://cmillion.ru"

#property link      "cmillion@narod.ru"

#property strict

#property description "=48:0B>@ >B>1@0605B ?0BB5@=K ?@>B>@3>2:8"



#property indicator_chart_window

#property indicator_buffers    2

#property indicator_color1     clrBlue

#property indicator_color2     clrRed

//--- input parameter

input int Percent=60;

input int candl=5;

//--- buffers

double UpBuffer[];

double DnBuffer[];

input color clrUP = clrLightGreen;

input color clrDn = clrPink;





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

int OnInit(void)

  {

   string short_name;



   IndicatorBuffers(2);

   SetIndexBuffer(0,UpBuffer);

   SetIndexBuffer(1,DnBuffer);



   SetIndexStyle(0,DRAW_ARROW,0,3);

   SetIndexArrow(0,217);

   SetIndexStyle(1,DRAW_ARROW,0,3);

   SetIndexArrow(1,218); 



   short_name="protorgovka("+IntegerToString(Percent)+"%)";

   IndicatorShortName(short_name);

   ObjectsDeleteAll(0,"protorgovka");

   return(INIT_SUCCEEDED);

  }



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

int OnCalculate(const int rates_total,

                const int prev_calculated,

                const datetime &time[],

                const double &open[],

                const double &high[],

                const double &low[],

                const double &close[],

                const long &tick_volume[],

                const long &volume[],

                const int &spread[])

  {



   int j,i; 

   color clr;

   for(i=rates_total-prev_calculated-1; i>=0; i--)

   {

      int n=0;

      j=i+1;

      double body,bodyKontr=MathAbs(open[i]-close[i])/100*Percent,upprice=0,dnprice=0;

      

      while(j<rates_total && !IsStopped())

      {

         body=high[j]-low[j];

         if (body>=bodyKontr) break;//@07<5@ A25G8 2 ?@>B>@3>2:5 <5=LH5 G5< :>=B@>;L=0O A25G0

         //if (high[j]>high[i] && low[j]<low[i])

         

         //=0E>68< <0:A8<C< 8 <8=8<C< :>@>1:8

         if (upprice<high[j]) upprice=high[j];

         if (dnprice==0 || dnprice>low[j]) dnprice=low[j];

         

         //@07<5@ :>@>1:8 ?@>B>@3>2:8 <5=LH5 G5< :>=B@>;L=0O A25G0

         if ((upprice-dnprice)>=bodyKontr) break;

         

         j++;

         n++;

      }

      //Comment(n," ",j);

      if (n<candl) continue;

      if (open[i]<close[i]) 

      {

         clr = clrUP;

         UpBuffer[i]=high[i];

      }

      else 

      {

         clr = clrDn;

         DnBuffer[i]=low[i];

      }

      

      string name=StringConcatenate("protorgovka ",TimeToString(time[i]));

      RectangleCreate(0,name,0,time[i],dnprice,time[j],upprice,clr,0,1);

      //name=StringConcatenate(name," diap");

      //TextCreate (0,name,0,Tstart,MaxPrice,IntegerToString(diap),"Arial",8,clrBlack);//480?>7>= 2 ?C=:B0E

      

   }



   return(rates_total);

  }

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

bool RectangleCreate(const long            chart_ID=0,        // ID 3@0D8:0 

                     const string          name="Rectangle",  // 8<O ?@O<>C3>;L=8:0 

                     const int             sub_window=0,      // =><5@ ?>4>:=0  

                     datetime              time1=0,           // 2@5<O ?5@2>9 B>G:8 

                     double                price1=0,          // F5=0 ?5@2>9 B>G:8 

                     datetime              time2=0,           // 2@5<O 2B>@>9 B>G:8 

                     double                price2=0,          // F5=0 2B>@>9 B>G:8 

                     const color           clr=clrRed,        // F25B ?@O<>C3>;L=8:0 

                     const ENUM_LINE_STYLE style=STYLE_SOLID, // AB8;L ;8=89 ?@O<>C3>;L=8:0 

                     const int             width=1,           // B>;I8=0 ;8=89 ?@O<>C3>;L=8:0 

                     const bool            fill=true,         // 70;82:0 ?@O<>C3>;L=8:0 F25B>< 

                     const bool            back=true,        // =0 704=5< ?;0=5 

                     const bool            selection=false,    // 2K45;8BL 4;O ?5@5<5I5=89 

                     const bool            hidden=true,       // A:@KB 2 A?8A:5 >1J5:B>2 

                     const long            z_order=0)         // ?@8>@8B5B =0 =060B85 <KHLN 

  { 

   if (ObjectFind(chart_ID,name)==-1)

   {

      if(!ObjectCreate(chart_ID,name,OBJ_RECTANGLE,sub_window,time1,price1,time2,price2)) 

      { 

         return(false); 

      } 

      ObjectSetInteger(chart_ID,name,OBJPROP_STYLE,style); 

      ObjectSetInteger(chart_ID,name,OBJPROP_WIDTH,width); 

      ObjectSetInteger(chart_ID,name,OBJPROP_FILL,fill); 

      ObjectSetInteger(chart_ID,name,OBJPROP_BACK,back); 

      ObjectSetInteger(chart_ID,name,OBJPROP_SELECTABLE,selection); 

      ObjectSetInteger(chart_ID,name,OBJPROP_SELECTED,selection); 

      ObjectSetInteger(chart_ID,name,OBJPROP_HIDDEN,hidden); 

      ObjectSetInteger(chart_ID,name,OBJPROP_ZORDER,z_order); 

   }

   ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr); 

   ObjectMove(chart_ID,name,0,time1,price1);

   ObjectMove(chart_ID,name,1,time2,price2);

   return(true); 

  } 

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

bool TextCreate(const long              chart_ID=0,               // ID 3@0D8:0 

                const string            name="Text",              // 8<O >1J5:B0 

                const int               sub_window=0,             // =><5@ ?>4>:=0 

                datetime                time=0,                   // 2@5<O B>G:8 ?@82O7:8 

                double                  price=0,                  // F5=0 B>G:8 ?@82O7:8 

                const string            text="Text",              // A0< B5:AB 

                const string            font="Arial",             // H@8DB 

                const int               font_size=10,             // @07<5@ H@8DB0 

                const color             clr=clrRed,               // F25B 

                const double            angle=0.0,                // =0:;>= B5:AB0 

                const ENUM_ANCHOR_POINT anchor=ANCHOR_LEFT_UPPER, // A?>A>1 ?@82O7:8 

                const bool              back=false,               // =0 704=5< ?;0=5 

                const bool              selection=false,          // 2K45;8BL 4;O ?5@5<5I5=89 

                const bool              hidden=true,              // A:@KB 2 A?8A:5 >1J5:B>2 

                const long              z_order=0)                // ?@8>@8B5B =0 =060B85 <KHLN 

  { 

   if(ObjectFind(chart_ID,name)!=-1) ObjectDelete(chart_ID,name);

   if(!ObjectCreate(chart_ID,name,OBJ_TEXT,sub_window,time,price)) 

     { 

      return(false); 

     } 

   ObjectSetString(chart_ID,name,OBJPROP_FONT,font); 

   ObjectSetInteger(chart_ID,name,OBJPROP_FONTSIZE,font_size); 

   ObjectSetDouble(chart_ID,name,OBJPROP_ANGLE,angle); 

   ObjectSetInteger(chart_ID,name,OBJPROP_ANCHOR,anchor); 

   ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr); 

   ObjectSetInteger(chart_ID,name,OBJPROP_BACK,back); 

   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTABLE,selection); 

   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTED,selection); 

   ObjectSetInteger(chart_ID,name,OBJPROP_HIDDEN,hidden); 

   ObjectSetInteger(chart_ID,name,OBJPROP_ZORDER,z_order); 

   ObjectSetString(chart_ID,name,OBJPROP_TEXT,text); 

   return(true); 

  } 

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

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