Indicators Used
Miscellaneous
0
Views
0
Downloads
0
Favorites
Momentum-Multi.mod
//+------------------------------------------------------------------+
//| Momentum-Multi.mq4 v1.0 |
//| Copyright ?2004, MetaQuotes Software Corp. |
//| http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright ?2004, MetaQuotes Software Corp."
#property link "http: //www.metaquotes.net/"
#property indicator_separate_window
#property indicator_buffers 8
#property indicator_color1 Red
#property indicator_color2 Orange
#property indicator_color3 Gold
#property indicator_color4 Lime
#property indicator_color5 Aqua
#property indicator_color6 DodgerBlue
#property indicator_color7 MediumPurple
#property indicator_color8 Silver
#property indicator_level1 0
#property indicator_levelcolor LightSlateGray
#define INDICATOR_VERSION "v1.0.mod"
//---- input parameters
extern int MomPeriod1 = 5;
extern int MomPeriod2 = 7;
extern int MomPeriod3 = 9;
extern int MomPeriod4 = 11;
extern int MomPeriod5 = 14;
extern int MomPeriod6 = 17;
extern int MomPeriod7 = 20;
extern int MomPeriod8 = 23;
//---- buffers
double MomBuffer1[];
double MomBuffer2[];
double MomBuffer3[];
double MomBuffer4[];
double MomBuffer5[];
double MomBuffer6[];
double MomBuffer7[];
double MomBuffer8[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init() {
string short_name;
//---- indicator line
SetIndexStyle( 0, DRAW_LINE );
SetIndexStyle( 1, DRAW_LINE );
SetIndexStyle( 2, DRAW_LINE );
SetIndexStyle( 3, DRAW_LINE );
SetIndexStyle( 4, DRAW_LINE );
SetIndexStyle( 5, DRAW_LINE );
SetIndexStyle( 6, DRAW_LINE );
SetIndexStyle( 7, DRAW_LINE );
SetIndexBuffer( 0, MomBuffer1 );
SetIndexBuffer( 1, MomBuffer2 );
SetIndexBuffer( 2, MomBuffer3 );
SetIndexBuffer( 3, MomBuffer4 );
SetIndexBuffer( 4, MomBuffer5 );
SetIndexBuffer( 5, MomBuffer6 );
SetIndexBuffer( 6, MomBuffer7 );
SetIndexBuffer( 7, MomBuffer8 );
//---- name for DataWindow and indicator subwindow label
short_name = "Momentum-Multi " + INDICATOR_VERSION + "(" + MomPeriod1 + "," + MomPeriod2 + "," + MomPeriod3 + "," + MomPeriod4 + "," + MomPeriod5 + "," + MomPeriod6 + "," + MomPeriod7 + "," + MomPeriod8 + ")";
IndicatorShortName( short_name );
SetIndexLabel( 0, "Momentum-Multi(" + MomPeriod1 + ")" );
SetIndexLabel( 1, "Momentum-Multi(" + MomPeriod2 + ")" );
SetIndexLabel( 2, "Momentum-Multi(" + MomPeriod3 + ")" );
SetIndexLabel( 3, "Momentum-Multi(" + MomPeriod4 + ")" );
SetIndexLabel( 4, "Momentum-Multi(" + MomPeriod5 + ")" );
SetIndexLabel( 5, "Momentum-Multi(" + MomPeriod6 + ")" );
SetIndexLabel( 6, "Momentum-Multi(" + MomPeriod7 + ")" );
SetIndexLabel( 7, "Momentum-Multi(" + MomPeriod8 + ")" );
//----
SetIndexDrawBegin( 0, MomPeriod1 );
SetIndexDrawBegin( 1, MomPeriod2 );
SetIndexDrawBegin( 2, MomPeriod3 );
SetIndexDrawBegin( 3, MomPeriod4 );
SetIndexDrawBegin( 4, MomPeriod5 );
SetIndexDrawBegin( 5, MomPeriod6 );
SetIndexDrawBegin( 6, MomPeriod7 );
SetIndexDrawBegin( 7, MomPeriod8 );
//----
return( 0 );
}
//+------------------------------------------------------------------+
//| Momentum |
//+------------------------------------------------------------------+
int start() {
int counted_bars = IndicatorCounted();
// Check for errors
if ( counted_bars < 0 ) {
return( -1 );
}
// Last bar will be recounted
if ( counted_bars > 0 ) {
counted_bars--;
}
// Get the upper limit
int limit = Bars - counted_bars;
for ( int ictr = 0; ictr < limit; ictr++ ) {
MomBuffer1[ictr] = iMomentum( NULL, 0, MomPeriod1, PRICE_CLOSE, ictr ) - 100.0;
MomBuffer2[ictr] = iMomentum( NULL, 0, MomPeriod2, PRICE_CLOSE, ictr ) - 100.0;
MomBuffer3[ictr] = iMomentum( NULL, 0, MomPeriod3, PRICE_CLOSE, ictr ) - 100.0;
MomBuffer4[ictr] = iMomentum( NULL, 0, MomPeriod4, PRICE_CLOSE, ictr ) - 100.0;
MomBuffer5[ictr] = iMomentum( NULL, 0, MomPeriod5, PRICE_CLOSE, ictr ) - 100.0;
MomBuffer6[ictr] = iMomentum( NULL, 0, MomPeriod6, PRICE_CLOSE, ictr ) - 100.0;
MomBuffer7[ictr] = iMomentum( NULL, 0, MomPeriod7, PRICE_CLOSE, ictr ) - 100.0;
MomBuffer8[ictr] = iMomentum( NULL, 0, MomPeriod8, PRICE_CLOSE, ictr ) - 100.0;
}
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
---