Indicators Used
Miscellaneous
0
Views
0
Downloads
0
Favorites
FX Sniper's MA_001
//+------------------------------------------------------------------+
//| FX Sniper's MA |
//| Copyright © 2006, FX Sniper |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, FX Sniper "
#property link "http://www.metaquotes.net/"
//---- indicator settings
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 DarkViolet
#property indicator_color2 Olive
#property indicator_width1 1
#property indicator_width2 1
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[],ma[];
string objectma1;
string IntToStr(int X)
{
return (DoubleToStr(X, 0));
}
extern string note1 = "Moving Average Type";
extern string note2 = "0=Simple,1=Exponential";
extern string note3 = "2=Smooth,3=Linear Weighted";
extern int MAType = 3;
extern string note4 = "Moving Average Period";
extern int MAPeriod = 3;
extern int MAShift = 0;
extern int PriceType=0;
extern string note5 = "What color?";
extern color MAcolor1 = DarkViolet;
extern string note6 = "Display the info in what corner?";
extern string note7 = "Upper left=0; Upper right=1";
extern string note8 = "Lower left=2; Lower right=3";
extern int WhatCorner=1;
extern string note9 = "Y distance; add 10 to each MA";
extern int ydistance1=10;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
int ydistance2;
string short_name;
//---- 2 additional buffers are used for counting.
IndicatorBuffers(5);
//---- drawing settings
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexBuffer(2,ma);
SetIndexStyle(0,DRAW_LINE);
SetIndexStyle(1,DRAW_LINE);
switch(MAType)
{
case 1 : short_name="EMA"; break;
case 2 : short_name="SMMA"; break;
case 3 : short_name="LWMA"; break;
default :
MAType=0;
short_name="SMA";
}
if ((WhatCorner == 2) || (WhatCorner == 3))
{
ydistance2 = 50+ydistance1;
}
else
{
ydistance1 = 20+ydistance1;
}
objectma1 = "FXSniperMA"+IntToStr(MAPeriod);
ObjectCreate(objectma1, OBJ_LABEL, 0, 0, 0);
ObjectSetText(objectma1, short_name+"("+MAPeriod+")", 8, "Arial", MAcolor1);
ObjectSet(objectma1, OBJPROP_CORNER, WhatCorner);
ObjectSet(objectma1, OBJPROP_XDISTANCE, 2);
ObjectSet(objectma1, OBJPROP_YDISTANCE, ydistance1);
//---- initialization done
return(0);
}
//+------------------------------------------------------------------+
int deinit()
{
ObjectDelete(objectma1);
return(0);
}
//+------------------------------------------------------------------+
int start()
{
for(int i = Bars-10; i >= 0; i--)
{
ma[i]=iMA(NULL,0,MAPeriod,MAShift,MAType,PriceType,i);
}
for(int shift = Bars-10; shift >= 0; shift--)
{
ExtMapBuffer1[shift] = ma[shift];
ExtMapBuffer2[shift] = ma[shift];
//Print (ma[shift]);
if (ma[shift] > ma[shift+1])
{
ExtMapBuffer1[shift] = EMPTY_VALUE;
ExtMapBuffer2[shift+1] = ma[shift+1];
}
else if (ma[shift] < ma[shift+1])
{
ExtMapBuffer2[shift] = EMPTY_VALUE;
ExtMapBuffer1[shift+1] = ma[shift+1];
}
}
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
---