

Для начала пока надо переделать индикатор сделать машку чтобы она отображалась так как и на индикаторе
с возможностью переключения 0-точки/1-линия
//+------------------------------------------------------------------+
//| Kashtan.mq4 |
//| Copyright 2016, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016, AM2"
#property link "http://www.forexsystems.biz"
#property version "1.00"
#property strict
//--- Inputs
extern double Lots = 0.1; // лот
extern double Koeff = 3; // коэффициент расширения диапазона
extern int StopLoss = 2000; // лось
extern int TakeProfit = 3000; // язь
extern int BarsCount = 20; // баров для расчета
extern int MaxDelta = 1000; // максимальное расстояние от хая до лоу
extern int MinDelta = 100; // минимальное расстояние от хая до лоу
extern int Slip = 30; // реквот
extern int Magic = 123456; // магик
datetime t=0;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
Comment("");
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
Comment("");
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void PutOrder(int type,double price)
{
int r=0;
color clr=Green;
double sl=0,tp=0;
if(type==1 || type==3 || type==5)
{
clr=Red;
if(StopLoss>0) sl=NormalizeDouble(price+StopLoss*Point,Digits);
if(TakeProfit>0) tp=NormalizeDouble(price-TakeProfit*Point,Digits);
}
if(type==0 || type==2 || type==4)
{
clr=Blue;
if(StopLoss>0) sl=NormalizeDouble(price-StopLoss*Point,Digits);
if(TakeProfit>0) tp=NormalizeDouble(price+TakeProfit*Point,Digits);
}
r=OrderSend(NULL,type,Lots,NormalizeDouble(price,Digits),Slip,sl,tp,"",Magic,0,clr);
return;
}
//+------------------------------------------------------------------+
//| Подсчет ордеров по типу |
//+------------------------------------------------------------------+
int CountOrders(int type)
{
int count=0;
for(int i=OrdersTotal()-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
{
if(OrderType()==type) count++;
}
}
}
return(count);
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
double h = High[iHighest(NULL,0,MODE_HIGH,BarsCount,0)];
double l = Low[iLowest(NULL,0,MODE_LOW,BarsCount,0)];
if(t!=Time[0])
{
if((h-l)>MinDelta*Point && (h-l)<MaxDelta*Point)
{
if(Bid>(l+(h-l)/Koeff) && Bid<(h-(h-l)/Koeff))
{
while(CountOrders(0)<1) PutOrder(0,Ask);
while(CountOrders(1)<1) PutOrder(1,Bid);
t=Time[0];
}
}
}
Comment("\n Delta: ",(h-l)/Point,
"\n High: ",h,
"\n Low: ",l,
"\n h-(h-l)/3: ",h-(h-l)/3,
"\n l+(h-l)/3: ",l+(h-l)/3);
}
//+------------------------------------------------------------------+
if((h-l)>MinDelta*Point && (h-l)<MaxDelta*Point)
if(Bid>(l+(h-l)/Diapazon) && Bid<(h-(h-l)/Diapazon))
extern double Diapazon = 3; // диапазон
//+------------------------------------------------------------------+
//| Diapazon.mq4 |
//| Copyright 2016, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016, AM2"
#property link "http://www.forexsystems.biz"
#property version "1.00"
#property strict
//--- Inputs
extern double Lots = 0.1; // лот
extern double Diapazon = 3; // диапазон
extern int StopLoss = 2000; // лось
extern int TakeProfit = 3000; // язь
extern int BarsCount = 20; // баров для расчета
extern int MaxDelta = 1000; // максимальное расстояние от хая до лоу
extern int MinDelta = 100; // минимальное расстояние от хая до лоу
extern int Slip = 30; // реквот
extern int Magic = 123; // магик
datetime t=0;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
Comment("");
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
Comment("");
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void PutOrder(int type,double price)
{
int r=0;
color clr=Green;
double sl=0,tp=0;
if(type==1 || type==3 || type==5)
{
clr=Red;
if(StopLoss>0) sl=NormalizeDouble(price+StopLoss*Point,Digits);
if(TakeProfit>0) tp=NormalizeDouble(price-TakeProfit*Point,Digits);
}
if(type==0 || type==2 || type==4)
{
clr=Blue;
if(StopLoss>0) sl=NormalizeDouble(price-StopLoss*Point,Digits);
if(TakeProfit>0) tp=NormalizeDouble(price+TakeProfit*Point,Digits);
}
r=OrderSend(NULL,type,Lots,NormalizeDouble(price,Digits),Slip,sl,tp,"",Magic,0,clr);
return;
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int CountTrades()
{
int count=0;
for(int i=OrdersTotal()-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
{
if(OrderType()<2) count++;
}
}
}
return(count);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void CloseAll()
{
bool cl;
for(int i=OrdersTotal()-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
{
if(OrderType()==OP_BUY)
{
RefreshRates();
cl=OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(Bid,Digits),Slip,White);
}
if(OrderType()==OP_SELL)
{
RefreshRates();
cl=OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(Ask,Digits),Slip,White);
}
}
}
}
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
double h = High[iHighest(NULL,0,MODE_HIGH,BarsCount,0)];
double l = Low[iLowest(NULL,0,MODE_LOW,BarsCount,0)];
if(CountTrades()<1 && t!=Time[0])
{
if((h-l)>MinDelta*Point && (h-l)<MaxDelta*Point)
{
if(Bid>(l+(h-l)/Diapazon) && Bid<(h-(h-l)/Diapazon))
{
PutOrder(0,Ask);
PutOrder(1,Bid);
t=Time[0];
}
}
}
Comment("\n Delta: ",(h-l)/Point,
"\n High: ",h,
"\n Low: ",l,
"\n h-(h-l)/3: ",h-(h-l)/3,
"\n l+(h-l)/3: ",l+(h-l)/3);
}
//+------------------------------------------------------------------+
AM2