Miscellaneous
0
Views
0
Downloads
0
Favorites
SvmPower
//+------------------------------------------------------------------+
//| SvmPower.mq4 |
//| Copyright © 2008, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
#property indicator_separate_window
#property indicator_buffers 5
#property indicator_color1 Aqua
#property indicator_color2 Red
#property indicator_color3 Blue
#property indicator_color4 Magenta
#property indicator_color5 Silver
#property indicator_style2 2
#property indicator_style3 2
#property indicator_width1 1
#property indicator_width2 1
#property indicator_width3 1
#property indicator_width4 1
#property indicator_width5 1
#property indicator_level1 0
#property indicator_level2 30
#property indicator_level3 -30
#property indicator_level4 60
#property indicator_level5 -60
#property indicator_level6 90
#property indicator_level7 -90
extern int MaxDrawTicks=1500;
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
double ExtMapBuffer5[];
int tickCounter;
string shortname;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
shortname=WindowExpertName();
IndicatorShortName(shortname);
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0, ExtMapBuffer1);
SetIndexEmptyValue(0,EMPTY_VALUE);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1, ExtMapBuffer2);
SetIndexEmptyValue(1,EMPTY_VALUE);
SetIndexStyle(2,DRAW_LINE);
SetIndexBuffer(2, ExtMapBuffer3);
SetIndexEmptyValue(2,EMPTY_VALUE);
SetIndexStyle(3,DRAW_LINE);
SetIndexBuffer(3, ExtMapBuffer4);
SetIndexEmptyValue(3,EMPTY_VALUE);
SetIndexStyle(4,DRAW_LINE);
SetIndexBuffer(4, ExtMapBuffer5);
SetIndexEmptyValue(4,EMPTY_VALUE);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
//----
double p1=GlobalVariableGet("SignalPower1");
double p2=GlobalVariableGet("SignalPower2");
double p3=GlobalVariableGet("SignalPower3");
if(isNewBarM5())
{
SetDelimeter();
if(p1 != EMPTY_VALUE)
{
ExtMapBuffer1[0]=p1;
ExtMapBuffer2[0]=-30;
ExtMapBuffer3[0]=30;
ExtMapBuffer4[0]=-p2;
//ExtMapBuffer5[0]=p3;
}
/*
if(p1>0)
{
ExtMapBuffer1[0]=p1;
ExtMapBuffer2[0]=0;
}
else if(p1<0)
{
ExtMapBuffer2[0]=p1;
ExtMapBuffer1[0]=0;
}
*/
//ExtMapBuffer1[0]=Bid;
//ExtMapBuffer2[0]=Ask;
//ExtMapBuffer3[0]=Open[0];
}
else
{tickCounter++;
ShiftArray();
if(p1 != EMPTY_VALUE)
{
ExtMapBuffer1[0]=p1;
ExtMapBuffer2[0]=-30;
ExtMapBuffer3[0]=30;
ExtMapBuffer4[0]=-p2;
// ExtMapBuffer5[0]=p3;
}
/*
if(p1>0)
{
ExtMapBuffer1[0]=p1;
ExtMapBuffer2[0]=0;
}
else if(p1<0)
{
ExtMapBuffer2[0]=p1;
ExtMapBuffer1[0]=0;
}
*/
//ExtMapBuffer1[0]=Bid;
//ExtMapBuffer2[0]=Ask;
//ExtMapBuffer3[0]=Open[0];
}
//----
Obj1(DoubleToStr(p1,0),DoubleToStr(-p2,0),DoubleToStr(p3,0));
return(0);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//|
//+------------------------------------------------------------------+
bool isNewBarM1()
{
static datetime BarTimeM1;
bool res=false;
if (BarTimeM1!=iTime(NULL,PERIOD_M1,0))
{
BarTimeM1=iTime(NULL,PERIOD_M1,0);
res=true;
}
return(res);
}
//+------------------------------------------------------------------+
//|
//+------------------------------------------------------------------+
bool isNewBarM5()
{
static datetime BarTimeM5;
bool res=false;
if (BarTimeM5!=iTime(NULL,PERIOD_M5,0))
{
BarTimeM5=iTime(NULL,PERIOD_M5,0);
res=true;
}
return(res);
}
void SetDelimeter()
{
//----
string delimeterDate=TimeToStr(Time[0]);
//Print("Ñòàâèì ðàçäåëèòåëü");
int handle=WindowFind("SvmPower");
if(!ObjectCreate(delimeterDate,OBJ_VLINE,handle,Time[0],0))
{
//Alert("Íåäà÷íàÿ ïîïûòêà ñîçäàíèÿ ðàçäåëèòåëÿ â îêíå ",
//handle," ïî âðåìåíè ",TimeToStr(CurTime()));
//Print("Îøèáêà ¹",GetLastError(),", èìÿ ðàçäåëèòåëÿ ",delimeterDate);
}
else
{
ObjectSet(delimeterDate,OBJPROP_COLOR,Yellow);
ObjectSet(delimeterDate,OBJPROP_STYLE,STYLE_DASHDOT);
ObjectsRedraw();
}
WindowScreenShot("shots\\tester"+Symbol()+TimeCurrent()+".gif",640,480);
//----
return(0);
}
void ShiftArray()
{
//----
int V_lines,i1;
string delimeterName;
datetime firstTime;
int BarFirstTime;
if (tickCounter>2*MaxDrawTicks)
{
for (i1=tickCounter;i1>=MaxDrawTicks;i1--) ExtMapBuffer1[i1]=0.0;
for (i1=tickCounter;i1>=MaxDrawTicks;i1--) ExtMapBuffer2[i1]=0.0;
for (i1=tickCounter;i1>=MaxDrawTicks;i1--) ExtMapBuffer3[i1]=0.0;
for (i1=tickCounter;i1>=MaxDrawTicks;i1--) ExtMapBuffer4[i1]=0.0;
// for (i1=tickCounter;i1>=MaxDrawTicks;i1--) ExtMapBuffer5[i1]=0.0;
tickCounter=MaxDrawTicks;
}
for(int cnt=tickCounter;cnt>0;cnt--)
{
ExtMapBuffer1[cnt]=ExtMapBuffer1[cnt-1];
ExtMapBuffer2[cnt]=ExtMapBuffer2[cnt-1];
ExtMapBuffer3[cnt]=ExtMapBuffer3[cnt-1];
ExtMapBuffer4[cnt]=ExtMapBuffer4[cnt-1];
// ExtMapBuffer5[cnt]=ExtMapBuffer5[cnt-1];
}
V_lines=ObjectsTotal();
for (int z=0;z<V_lines;z++)
{
delimeterName=ObjectName(z);
if (ObjectFind(delimeterName)!=-1)
{
if (ObjectType(delimeterName)==OBJ_VLINE)
{
firstTime=ObjectGet(delimeterName,OBJPROP_TIME1);
BarFirstTime=iBarShift(NULL,0,firstTime);
firstTime=Time[BarFirstTime+1];
ObjectSet(delimeterName,OBJPROP_TIME1,firstTime);
}
}
}
//----
return(0);
}
//---------------------------------------------------------------------+
void Obj1(string s1, string s2, string s3)
{
int FontSize=8;
color FontColor1=Aqua;
color FontColor2=Magenta;
color FontColor3=Silver;
int offset1=0;
string objname1=shortname+1;
string objname2=shortname+2;
string objname3=shortname+3;
//string objname4=shortname+4;
if(ObjectFind(objname1)<0)
ObjectCreate(objname1,OBJ_TEXT,WindowFind(shortname),Time[0+offset1]+Period()*60,ExtMapBuffer1[0+offset1]);
else
ObjectMove(objname1,0,Time[0+offset1]+Period()*60,ExtMapBuffer1[0+offset1]);
if(ObjectFind(objname2)<0)
ObjectCreate(objname2,OBJ_TEXT,WindowFind(shortname),Time[0+offset1]+Period()*60,ExtMapBuffer4[0+offset1]);
else
ObjectMove(objname2,0,Time[0+offset1]+Period()*60,ExtMapBuffer4[0+offset1]);
/*
if(ObjectFind(objname3)<0)
ObjectCreate(objname3,OBJ_TEXT,WindowFind(shortname),Time[0+offset1]+Period()*60,ExtMapBuffer5[0+offset1]);
else
ObjectMove(objname3,0,Time[0+offset1]+Period()*60,ExtMapBuffer5[0+offset1]);
*/
/*
if(ObjectFind(objname4)<0)
ObjectCreate(objname4,OBJ_TEXT,WindowFind(shortname),Time[0+offset1]+Period()*60,Buffer5[0+offset1]);
else
ObjectMove(objname4,0,Time[0+offset1]+Period()*60,Buffer5[0+offset1]);
*/
ObjectSetText(objname1,""+s1+"",FontSize,"Courier",FontColor1);
ObjectSetText(objname2,""+s2+"",FontSize,"Courier",FontColor2);
// ObjectSetText(objname3,""+s3+"",FontSize,"Courier",FontColor3);
/*
ObjectSetText(objname4,"4-"+Symbol4Long+"",FontSize,"Courier",FontColor);
*/
}
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
---