Он держит ситуацию под контролем, постоянно сравнивая текущее значение цены со значением цены OPEN
цену оупен какой свечи запоминаем?
Он держит ситуацию под контролем, постоянно сравнивая текущее значение цены со значением цены OPEN
//+------------------------------------------------------------------+
//| HighLow.mq4 |
//| Copyright 2018, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2018, AM2"
#property link "http://www.forexsystems.biz"
#property version "1.00"
#property strict
#property indicator_chart_window
input int days=5;
input int width=1;
input int style=1;
input int delta=100;
input int count=5;
input bool push=1;
input bool alert=1;
input color upcolor=Red;
input color dncolor=Blue;
input color txtcolor=Lime;
int num=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void PutTrendLine(string name,datetime time1,double price1,datetime time2,double price2,color clr)
{
ObjectDelete(0,name);
ObjectCreate(0,name,OBJ_TREND,0,time1,price1,time2,price2);
//--- установим цвет линии
ObjectSetInteger(0,name,OBJPROP_COLOR,clr);
//--- установим стиль отображения линии
ObjectSetInteger(0,name,OBJPROP_STYLE,style);
//--- установим толщину линии
ObjectSetInteger(0,name,OBJPROP_WIDTH,width);
//--- включим (true) или отключим (false) режим продолжения отображения линии вправо
ObjectSetInteger(0,name,OBJPROP_RAY_RIGHT,0);
}
//+------------------------------------------------------------------+
//| Put Text Function |
//+------------------------------------------------------------------+
void Text(string name,const string text,double price,datetime time,const color clr)
{
ObjectDelete(0,name);
//--- create a "Text" object
ObjectCreate(0,name,OBJ_TEXT,0,time,price);
//--- set the text
ObjectSetString(0,name,OBJPROP_TEXT,text);
//--- set the font of the text
ObjectSetString(0,name,OBJPROP_FONT,"Arial");
//--- set the font size
ObjectSetInteger(0,name,OBJPROP_FONTSIZE,9);
//--- set the method binding
ObjectSetInteger(0,name,OBJPROP_ANCHOR,4);
//--- set the color
ObjectSetInteger(0,name,OBJPROP_COLOR,clr);
}
//+------------------------------------------------------------------+
//| 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[])
{
//---
double hi1=iHigh(NULL,PERIOD_D1,1);
double lo1=iLow (NULL,PERIOD_D1,1);
for(int i=1;i<days;i++)
{
double hi=iHigh(NULL,PERIOD_D1,i);
double lo=iLow (NULL,PERIOD_D1,i);
datetime tm1=iTime(NULL,PERIOD_D1,i-1);
datetime tm2=iTime(NULL,PERIOD_D1,i);
datetime tm=(tm1+tm2)/2;
int range=(int)((hi-lo)/_Point/10);
PutTrendLine("Hi"+(string)i,tm1,hi,tm2,hi,upcolor);
PutTrendLine("Lo"+(string)i,tm1,lo,tm2,lo,dncolor);
Text("Text"+(string)i,(string)range,hi,tm,txtcolor);
}
if(num<count)
{
if(alert)
{
if(Bid<hi1+delta*_Point && Bid>hi1-delta*_Point) Alert(_Symbol+" Цена около уровня: ",hi1);
if(Bid<lo1+delta*_Point && Bid>lo1-delta*_Point) Alert(_Symbol+" Цена около уровня: ",lo1);
}
if(push)
{
if(Bid<hi1+delta*_Point && Bid>hi1-delta*_Point) SendNotification(_Symbol+" Цена около уровня: "+(string)hi1);
if(Bid<lo1+delta*_Point && Bid>lo1-delta*_Point) SendNotification(_Symbol+" Цена около уровня: "+(string)lo1);
}
num++;
}
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+
Второе, что сложнее, буду думать, как контролировать руками.
Проверяем общий плюс по всем сделкам. Если плюс достиг показателя переменной, то все ордера закрываем. Если нет, то ждем.
Смотрим на предыдущий квадратик, если он красный, ищем открытые ордера, которые в buy, в плюсе, закрываем их, остальные ордера в buy которые в минусе удерживаем. Открываем sell.
Смотрим на предыдущий квадратик, если он синий, ищем открытые ордера, которые в sell, в плюсе, закрываем их, остальные ордера в sell которые в минусе удерживаем. Открываем buy.
//+------------------------------------------------------------------+
//| HighLow.mq4 |
//| Copyright 2018, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2018, AM2"
#property link "http://www.forexsystems.biz"
#property version "1.00"
#property strict
#property indicator_chart_window
input int days=5;
input int width=1;
input int style=1;
input int delta=100;
input int count=5;
input bool mail=1;
input bool alert=1;
input color upcolor=Red;
input color dncolor=Blue;
input color txtcolor=Lime;
int num=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void PutTrendLine(string name,datetime time1,double price1,datetime time2,double price2,color clr)
{
ObjectDelete(0,name);
ObjectCreate(0,name,OBJ_TREND,0,time1,price1,time2,price2);
//--- установим цвет линии
ObjectSetInteger(0,name,OBJPROP_COLOR,clr);
//--- установим стиль отображения линии
ObjectSetInteger(0,name,OBJPROP_STYLE,style);
//--- установим толщину линии
ObjectSetInteger(0,name,OBJPROP_WIDTH,width);
//--- включим (true) или отключим (false) режим продолжения отображения линии вправо
ObjectSetInteger(0,name,OBJPROP_RAY_RIGHT,0);
}
//+------------------------------------------------------------------+
//| Put Text Function |
//+------------------------------------------------------------------+
void Text(string name,const string text,double price,datetime time,const color clr)
{
ObjectDelete(0,name);
//--- create a "Text" object
ObjectCreate(0,name,OBJ_TEXT,0,time,price);
//--- set the text
ObjectSetString(0,name,OBJPROP_TEXT,text);
//--- set the font of the text
ObjectSetString(0,name,OBJPROP_FONT,"Arial");
//--- set the font size
ObjectSetInteger(0,name,OBJPROP_FONTSIZE,9);
//--- set the method binding
ObjectSetInteger(0,name,OBJPROP_ANCHOR,4);
//--- set the color
ObjectSetInteger(0,name,OBJPROP_COLOR,clr);
}
//+------------------------------------------------------------------+
//| 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[])
{
//---
double hi1=iHigh(NULL,PERIOD_D1,1);
double lo1=iLow (NULL,PERIOD_D1,1);
for(int i=1;i<days;i++)
{
double hi=iHigh(NULL,PERIOD_D1,i);
double lo=iLow (NULL,PERIOD_D1,i);
datetime tm1=iTime(NULL,PERIOD_D1,i-1);
datetime tm2=iTime(NULL,PERIOD_D1,i);
datetime tm=(tm1+tm2)/2;
int range=(int)((hi-lo)/_Point/10);
PutTrendLine("Hi"+(string)i,tm1,hi,tm2,hi,upcolor);
PutTrendLine("Lo"+(string)i,tm1,lo,tm2,lo,dncolor);
Text("Text"+(string)i,(string)range,hi,tm,txtcolor);
}
if(num<count)
{
if(alert)
{
if(Bid<hi1+delta*_Point && Bid>hi1-delta*_Point) Alert(_Symbol+" Цена около уровня: ",hi1);
if(Bid<lo1+delta*_Point && Bid>lo1-delta*_Point) Alert(_Symbol+" Цена около уровня: ",lo1);
}
if(mail)
{
if(Bid<hi1+delta*_Point && Bid>hi1-delta*_Point) SendMail("Signal",_Symbol+" Цена около уровня: "+(string)hi1);
if(Bid<lo1+delta*_Point && Bid>lo1-delta*_Point) SendMail("Signal",_Symbol+" Цена около уровня: "+(string)lo1);
}
num++;
}
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Reno.mq5 |
//| Copyright 2019, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2019, AM2"
#property link "http://www.forexsystems.biz"
#property version "1.00"
#include <Trade\Trade.mqh>
CTrade trade;
input int mag=123;
input int slip=33;
input double lot=0.1;
input string IndName="RenkoChart";
int rn=0;
double last=0;
double op[1],cl[1];
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
rn=iCustom(NULL,0,IndName);
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
CopyBuffer(rn,0,1,1,op);
CopyBuffer(rn,3,1,1,cl);
double bid=SymbolInfoDouble(Symbol(),SYMBOL_BID);
double ask=SymbolInfoDouble(Symbol(),SYMBOL_ASK);
if(last!=op[0])
{
if(cl[0]>op[0]) trade.Buy(lot,_Symbol,ask);
if(cl[0]<op[0]) trade.Sell(lot,_Symbol,bid);
last=op[0];
}
Comment("\n Open: ",op[0],
"\n Close: ",cl[0]);
}
//+------------------------------------------------------------------+
AM2