Miscellaneous
0
Views
0
Downloads
0
Favorites
#^MTF_EMA_Prediction_2
//+------------------------------------------------------------------+
//| EMA_Prediction_2.mq4 |
//| Codersguru |
//| http://www.forex-tsd.com |
//+------------------------------------------------------------------+
#property copyright "Codersguru"
#property link "http://www.forex-tsd.com"
extern int TimeFrame=0;
extern int ShortEma=1;
extern int LongEma=2;
extern bool Draw_Lines = true;
extern bool Vertical_Lines = true;
extern bool Show_Thumbs = true;
#property indicator_buffers 4
#property indicator_chart_window
#property indicator_color1 Blue
#property indicator_color2 Red
#property indicator_color3 Blue
#property indicator_color4 Red
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
double Signal1=0,Signal2=0;
int Previous_Bar = 0;
int init()
{
IndicatorBuffers(4);
SetIndexStyle(0,DRAW_ARROW,STYLE_SOLID,2);
SetIndexStyle(1,DRAW_ARROW,STYLE_SOLID,2);
SetIndexArrow(0, 234);
SetIndexArrow(1, 233);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexStyle(2,DRAW_LINE);
SetIndexBuffer(2,ExtMapBuffer3);
SetIndexStyle(3,DRAW_LINE);
SetIndexBuffer(3,ExtMapBuffer4);
//---- name for DataWindow and indicator subwindow label
switch(TimeFrame)
{
case 1 : string TimeFrameStr="Period_M1"; break;
case 5 : TimeFrameStr="Period_M5"; break;
case 15 : TimeFrameStr="Period_M15"; break;
case 30 : TimeFrameStr="Period_M30"; break;
case 60 : TimeFrameStr="Period_H1"; break;
case 240 : TimeFrameStr="Period_H4"; break;
case 1440 : TimeFrameStr="Period_D1"; break;
case 10080 : TimeFrameStr="Period_W1"; break;
case 43200 : TimeFrameStr="Period_MN1"; break;
default : TimeFrameStr="Current Timeframe";
}
IndicatorShortName("MTF_EMA_Prediction_2 ("+TimeFrameStr+")");
return(0);
}
void DrawVertical( int bar , double value, color clr)
{
static int cnt = 0;
cnt++;
string dv = "Signal" + cnt;
ObjectCreate(dv, OBJ_VLINE, 0, Time[bar], 0);
ObjectSet(dv, OBJPROP_COLOR, clr);
ObjectsRedraw();
}
void DrawThumb( int bar , int thumb , double value, color clr)
{
static int cnt = 0;
cnt++;
string dv = "thumb" + cnt;
ObjectCreate(dv, OBJ_ARROW, 0, Time[bar], value);
if(thumb == 1)
{
ObjectSet(dv, OBJPROP_ARROWCODE, 67);
}
if(thumb == 2)
{
ObjectSet(dv, OBJPROP_ARROWCODE, 68);
}
ObjectSet(dv, OBJPROP_COLOR, clr);
ObjectSet(dv, OBJPROP_STYLE , STYLE_SOLID);
ObjectSet(dv, OBJPROP_WIDTH , 3);
ObjectsRedraw();
}
int deinit()
{
int I = WindowsTotal();
for (int count = 0; count < WindowsTotal(); count++)
{
int nObjects = ObjectsTotal();
for (int i=nObjects; i>=0; i--)
{
string objName = ObjectName(i);
if(StringFind(objName, "Signal", 0) >= 0)
ObjectDelete(objName);
if(StringFind(objName, "thumb", 0) >= 0)
ObjectDelete(objName);
}
}
return(0);
}
int start()
{
datetime TimeArray[];
int i,limit,y=0,counted_bars=IndicatorCounted();
// Plot defined time frame on to current time frame
ArrayCopySeries(TimeArray,MODE_TIME,Symbol(),TimeFrame);
limit=Bars-counted_bars;
for(i=0,y=0;i<limit;i++)
{
if (Time[i]<TimeArray[y]) y++;
//----
ExtMapBuffer1[1]=iCustom(NULL,TimeFrame,"EMA_Prediction_2", ShortEma,LongEma,Draw_Lines,Vertical_Lines,Show_Thumbs,Signal1,0,y);
ExtMapBuffer2[1]=iCustom(NULL,TimeFrame,"EMA_Prediction_2", ShortEma,LongEma,Draw_Lines,Vertical_Lines,Show_Thumbs,Signal2,1,y);
ExtMapBuffer3[1]=iCustom(NULL,TimeFrame,"EMA_Prediction_2", ShortEma,LongEma,Draw_Lines,Vertical_Lines,Show_Thumbs,2,y);
ExtMapBuffer4[1]=iCustom(NULL,TimeFrame,"EMA_Prediction_2", ShortEma,LongEma,Draw_Lines,Vertical_Lines,Show_Thumbs,3,y);
}
//
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
---