//+------------------------------------------------------------------+
//| BullBearMA.mq4 |
//| Copyright 2018, AM2 |
//| http://www.forexsyatems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2018, AM2"
#property link "http://www.forexsyatems.biz"
#property version "1.00"
#property strict
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Green
#property indicator_color2 Red
#property indicator_color3 Blue
input int MAPeriod=14;
//--- buffers
double bull[];
double bear[];
double ma[];
double bu[];
double be[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
SetIndexBuffer(0,bull);
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(1,bear);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(2,ma);
SetIndexStyle(2,DRAW_LINE);
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[])
{
//---
ArraySetAsSeries(bull,true);
ArraySetAsSeries(bear,true);
string s="";
for(int i=0;i<10;i++)
{
if(close[i]>open[i]) bu[i]=close[i];
if(close[i]<open[i]) be[i]=close[i];
bull[i]=iMAOnArray(bu,0,MAPeriod,0,0,i);
bear[i]=iMAOnArray(be,0,MAPeriod,0,0,i);
ma[i]=iMA(NULL,0,MAPeriod,0,0,0,i);
s=StringConcatenate(s,(string)bu[i]);
}
Comment("\n ARR: ",s);
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Baton.mq4 |
//| Copyright 2018, AM2 |
//| http://www.forexsyatems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2018, AM2"
#property link "http://www.forexsyatems.biz"
#property version "1.00"
#property strict
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
//--- включение сообщений о перемещении мыши по окну чарта
ChartSetInteger(0,CHART_EVENT_MOUSE_MOVE,1);
PutButton("B",55,55,"БАТОН");
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void PutButton(string name,int x,int y,string text)
{
ObjectCreate(0,name,OBJ_BUTTON,0,0,0);
//--- установим координаты кнопки
ObjectSetInteger(0,name,OBJPROP_XDISTANCE,x);
ObjectSetInteger(0,name,OBJPROP_YDISTANCE,y);
//--- установим размер кнопки
ObjectSetInteger(0,name,OBJPROP_XSIZE,80);
ObjectSetInteger(0,name,OBJPROP_YSIZE,30);
//--- установим угол графика, относительно которого будут определяться координаты точки
ObjectSetInteger(0,name,OBJPROP_CORNER,2);
//--- установим текст
ObjectSetString(0,name,OBJPROP_TEXT,text);
//--- установим шрифт текста
ObjectSetString(0,name,OBJPROP_FONT,"Arial");
//--- установим размер шрифта
ObjectSetInteger(0,name,OBJPROP_FONTSIZE,12);
//--- установим цвет текста
ObjectSetInteger(0,name,OBJPROP_COLOR,Red);
//--- установим цвет фона
ObjectSetInteger(0,name,OBJPROP_BGCOLOR,White);
//--- установим цвет границы
ObjectSetInteger(0,name,OBJPROP_BORDER_COLOR,Blue);
//--- включим (true) или отключим (false) режим перемещения кнопки мышью
ObjectSetInteger(0,name,OBJPROP_SELECTABLE,1);
ObjectSetInteger(0,name,OBJPROP_SELECTED,1);
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
}
//+------------------------------------------------------------------+
void OnChartEvent(const int id,const long &lparam,const double &dparam,const string &sparam)
{
//--- нажатие мышкой на графике
if(id==CHARTEVENT_MOUSE_MOVE)
{
if(sparam=="1") Comment("Нажатие левой кнопки мышки на графике!"+"\n Координаты мышки на графике: x = ",lparam," y = ",dparam);
if(sparam=="2") Comment("Нажатие правой кнопки мышки на графике!"+"\n Координаты мышки на графике: x = ",lparam," y = ",dparam);
}
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| ATRSig.mq4 |
//| Copyright 2018, AM2 |
//| http://www.forexsyatems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2018, AM2"
#property link "http://www.forexsyatems.biz"
#property version "1.00"
#property strict
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
input int period=14;
input int count=1000;
input int upcode=233;
input int dncode=234;
input double lev1=0.007;
input double lev2=0.01;
double up[],dn[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
SetIndexStyle(0,DRAW_ARROW);
SetIndexBuffer(0,up);
SetIndexArrow(0,upcode);
SetIndexStyle(1,DRAW_ARROW);
SetIndexBuffer(1,dn);
SetIndexArrow(1,dncode);
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[])
{
//---
for(int i=0;i<count;i++)
{
double atr1=iATR(NULL,0,period,i);
double atr2=iATR(NULL,0,period,i+1);
if((atr1<lev1 && atr2>lev1)||(atr1<lev2 && atr2>lev2)) up[i]=high[i];
if((atr1>lev1 && atr2<lev1)||(atr1>lev2 && atr2<lev2)) dn[i]=high[i];
}
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+
AM2