HorizontalTrendLines_v1

Author: Scriptong
Price Data Components
0 Views
0 Downloads
0 Favorites
HorizontalTrendLines_v1
ÿþ#property copyright "Scriptong"

#property link      "scriptong@gmail.com"

#property strict



#property indicator_chart_window



input color             i_clrForColor  = clrNONE;                                                  // Lines color for correction

input ENUM_LINE_STYLE   i_eForStyle    = STYLE_SOLID;                                              // Lines type for correction





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[])



{

   return(rates_total);

}



void OnChartEvent(const int id, const long& lparam, const double& dparam, const string& sparam)

{

   if (id != CHARTEVENT_OBJECT_CHANGE && id != CHARTEVENT_OBJECT_DRAG)   

      return;

      

   if (ObjectGetInteger(0, sparam, OBJPROP_TYPE) != OBJ_TREND)

      return;

      

   if (bool(ObjectGetInteger(0, sparam, OBJPROP_HIDDEN)))

      return;



   if (i_clrForColor != clrNONE && color(ObjectGetInteger(0, sparam, OBJPROP_COLOR)) != i_clrForColor)

      return;



   if (ENUM_LINE_STYLE(ObjectGetInteger(0, sparam, OBJPROP_STYLE)) != i_eForStyle)

      return;



   double fLeftPrice = ObjectGetDouble(0, sparam, OBJPROP_PRICE, 0);

   double fRightPrice = ObjectGetDouble(0, sparam, OBJPROP_PRICE, 1);

   

   if (fabs(fLeftPrice - fRightPrice) < Point() / 10)

      return;

      

   ObjectSetDouble(0, sparam, OBJPROP_PRICE, 1, fLeftPrice);

   ChartRedraw();

}



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