Author: Inkov Evgeni ew123@mail.ru
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
Spread_v2
//+------------------------------------------------------------------+
//|                                                       Spread.mq4 |
//+------------------------------------------------------------------+
#property copyright "Inkov Evgeni ew123@mail.ru"
#property link      "+7-988-140-68-11"
//+------------------------------------------------------------------+
// ñðåäíèå - TL
// Volum - îòäåëüíî
//    VSA
// óðîâíè ñïðåäà: (1-àÿ ëèíèÿ - íèæå (A), 2-ÿ - âûøå(B))
// 1 - íèæå À
// 2 - ìåæäó À è Â
// 3 - âûøå Â
// óðîâíè îáú¸ìà  (1-àÿ ëèíèÿ - íèæå (A), 2-ÿ - âûøå(B), 3-ÿ ëèíèÿ - åù¸ âûøå (Ñ))
// 1 - íèæå À
// 2 - ìåæäó À è Â
// 3 - ìåæäó Â è Ñ
// 4 - âûøå Ñ
//+------------------------------------------------------------------+
#property  indicator_separate_window
#property  indicator_buffers 3
#property  indicator_color1  Lime       // Spread Up-Bar, Dw-Bar
#property  indicator_color2  Red        // Spread 0-Bar
#property  indicator_color3  Blue       // Close
#property  indicator_width1  2
#property  indicator_width2  2
#property  indicator_width3  1
//----------------------------
double     ExtBuffer0[]; // Spread Up-Bar, Dw-Bar
double     ExtBuffer1[]; // Spread 0-Bar
double     ExtBuffer2[]; // Close
//----------------------------
int init()
{
   IndicatorBuffers(3);

   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexStyle(1,DRAW_HISTOGRAM);
   SetIndexStyle(2,DRAW_LINE);
   
   SetIndexBuffer(0,ExtBuffer0);
   SetIndexBuffer(1,ExtBuffer1);
   SetIndexBuffer(2,ExtBuffer2);
   
   ArrayInitialize(ExtBuffer0,0);
   ArrayInitialize(ExtBuffer1,0);
   ArrayInitialize(ExtBuffer2,0);

   SetIndexEmptyValue(3,0);
   
   IndicatorShortName("Spread");
   IndicatorDigits(2);
   
   return(0);
}
//----------------------------
int deinit()
{
   ArrayInitialize(ExtBuffer0,0);
   ArrayInitialize(ExtBuffer1,0);
   ArrayInitialize(ExtBuffer2,0);
   return(0);
}
//-------------------------
int start()
{
   int    limit,i,j;
   int    counted_bars=IndicatorCounted();
   double prev,current;

   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
   for(i=limit; i>=0; i--)
   {
         // ãèñòîãðàììà ñïðåäîâ
      if (Close[i]>Close[i+1]) // Up - bar
      {
         ExtBuffer0[i]=(High[i]-Low[i])/Point;
         ExtBuffer1[i]=0;
         ExtBuffer2[i]=(Close[i]-Low[i])/Point;

      }
      else 
         if (Close[i]<Close[i+1]) // Down - bar
         {
            ExtBuffer0[i]=-(High[i]-Low[i])/Point;
            ExtBuffer1[i]=0;
            ExtBuffer2[i]=-(High[i]- Close[i])/Point;
         }
         else     // 0 - bar
            if (ExtBuffer0[i+1]+ExtBuffer2[i+1]>0)
            {
               ExtBuffer0[i]=0;
               ExtBuffer1[i]=(High[i]-Low[i])/Point;
               ExtBuffer2[i]=(Close[i]-Low[i])/Point;
            }
            else
            {
               ExtBuffer0[i]=0;
               ExtBuffer1[i]=-(High[i]-Low[i])/Point;
               ExtBuffer2[i]=-(High[i]- Close[i])/Point;
            }
   }
   
   return(0);
}
//----------------------------------------------

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