Miscellaneous
0
Views
0
Downloads
0
Favorites
lsma_v3
//+------------------------------------------------------------------+
//| |
//| Copyright © 2000-2007, MetaQuotes Software Corp. |
//| http://www.metaquotes.ru |
//+------------------------------------------------------------------+
// LSMA.mq4
// Least Squares Moving Average
#property link "mandorr@gmail.com"
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Red
extern int period=50;
extern int CountBars=10000; // Êîëè÷åñòâî îòîáðàæàåìûõ áàðîâ
double buffer[];
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void init()
{
SetIndexStyle(0,DRAW_LINE,0,2);
SetIndexBuffer(0,buffer);
SetIndexLabel(0,"Value");
SetIndexDrawBegin(0,0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void start()
{
for(int i=0; i<=CountBars-1; i++)
{
buffer[i]=LSMA(period,i);
}
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
double LSMA(int ma_period,int shift)
{
double lengthvar;
double tmp;
double sum=0;
for(int i=ma_period; i>=1; i--)
{
lengthvar=(ma_period+1)/3;
tmp=(i-lengthvar)*Close[ma_period-i+shift];
sum+=tmp;
}
double value=sum*6/(ma_period*(ma_period+1));
return(value);
}
//+------------------------------------------------------------------+
Comments
Markdown Formatting Guide
# H1
## H2
### H3
**bold text**
*italicized text*
[title](https://www.example.com)

`code`
```
code block
```
> blockquote
- Item 1
- Item 2
1. First item
2. Second item
---