Пожалуйста сделайте чтобы в реале работал, иначе нету смысла от него
не знаю чем 5 индикаторов отличаютя----я ставил номер 1 и шаблон и вся картина сразу нарисовалась… на следующую пару ставил индикатор 2 и шаблон и тоже все ок и т.д.
//+------------------------------------------------------------------+
//| Grider21.mq4 |
//| Copyright 2020, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2020, AM2"
#property link "http://www.forexsystems.biz"
#property version "1.00"
#property strict
//--- Inputs
extern double Lots = 1; // объем первого ордера
extern int StopLoss = 15; // стоплосс
extern int TakeProfit = 30; // тейкпрофит
extern int Step = 20; // шаг ордеров
extern int Count = 25; // количество ордеров
extern int Type = 1; // 1-Stop 2-Limit
extern int Slip = 3; // проскальзывание
extern int Exp = 23; // истечение
extern int Magic = 123; // магик
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
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,TimeCurrent()+Exp*3600,clr);
}
//+------------------------------------------------------------------+
//| Подсчет ордеров по типу |
//+------------------------------------------------------------------+
int CountOrders(int type=-1)
{
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 || (OrderType()>=0 && type==-1))
count++;
}
}
}
return(count);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int CountTrades(int type=-1)
{
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 || type==-1)
count++;
}
}
}
return(count);
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
if(CountOrders()<1)
{
if(Type==1)
{
if(CountOrders(4)<1)
for(int i=1; i<=Count; i++)
PutOrder(4,Bid+Step*_Point*i);//buystop
if(CountOrders(5)<1)
for(int i=1; i<=Count; i++)
PutOrder(5,Bid-Step*_Point*i);//sellstop
}
if(Type==2)
{
if(CountOrders(3)<1)
for(int i=1; i<=Count; i++)
PutOrder(3,Bid+Step*_Point*i);//selllimit
if(CountOrders(2)<1)
for(int i=1; i<=Count; i++)
PutOrder(2,Bid-Step*_Point*i);//buylimit
}
}
}
//+------------------------------------------------------------------+
у вас лот ноль выдает.
переписал функцию лота, добавил магик и контроль по позициям на данном символе:
www.opentraders.ru/downloads/2591/
AM2