Indicators Used
Miscellaneous
0
Views
0
Downloads
0
Favorites
LeManStop
//+------------------------------------------------------------------+
//| LeManStop.mq4 |
//| Copyright © 2009, LeMan. |
//| b-market@mail.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2009, LeMan."
#property link "b-market@mail.ru"
//----
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Red
#property indicator_width1 1
#property indicator_style1 2
//----
extern int per = 24;
extern int coef = 4;
extern int fastEMA = 9;
extern int slowEMA = 18;
//----
double ExtBuffer[];
//+------------------------------------------------------------------+
int init() {
//----
SetIndexBuffer(0,ExtBuffer);
SetIndexStyle(0,DRAW_LINE);
//----
return(0);
}
//+------------------------------------------------------------------+
int start() {
//----
double Stop = 0;
int counted_bars = IndicatorCounted();
int limit = Bars-per-3;
//----
for (int shift = limit; shift >= 0; shift--) {
double EMA0 = iMA(Symbol(),0,fastEMA,0,MODE_EMA,0,shift)-iMA(Symbol(),0,slowEMA,0,MODE_EMA,0,shift);
double EMA1 = iMA(Symbol(),0,fastEMA,0,MODE_EMA,0,shift+1)-iMA(Symbol(),0,slowEMA,0,MODE_EMA,0,shift+1);
double PreStop = ExtBuffer[shift+1];
double x = 0;
double Counter = 0;
if (EMA0 > 0) {
for (int value1 = 0; value1 <= per; value1++) {
x = Open[shift+value1]-Low[shift+value1]+x;
Counter++;
}
if (Counter != 0) {
Stop = Open[shift]-(coef*(x/Counter));
} else {
Stop = Open[shift]-(coef*x);
}
if ((Stop < PreStop) && (EMA1 > 0)) {
Stop = PreStop;
}
}
if (EMA0 < 0) {
for (value1 = 0; value1 <= per; value1++) {
x = High[shift+value1]-Open[shift+value1]+x;
Counter++;
}
if (Counter != 0) {
Stop = Open[shift+1]+(coef*(x/Counter));
} else {
Stop = Open[shift+1]+(coef*x);
}
if ((Stop > PreStop) && (EMA1 < 0)) {
Stop = PreStop;
}
}
PreStop = Stop;
ExtBuffer[shift] = Stop;
}
//----
return(0);
}
//+------------------------------------------------------------------+
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
---