extern bool BuyLimit = false; // BuyLimit
extern bool SellLimit = false; // SellLimit
extern bool BuyStop = false; // BuyStop
extern bool SellStop = false; // SellStop
//+------------------------------------------------------------------+
//| Unlimited.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
#property show_inputs
//--- Inputs
extern double Lot = 0.1; // Trade volume
extern int StopLoss = 0; // Order sroploss
extern int TakeProfit = 0; // Order takeprofit
extern int Expiration = 60; // The expiry of the order in minutes
extern int Delta = 100; // Distance from the price
extern int DeltaPrice = 50; // Distance for the price
extern int ChannelWidth = 100; // Channel Width
extern int Start = 1; // Start Bar
extern int Count = 8; // Bars count
extern int Slip = 3; // Slippage
extern int Magic = 123; // Magic number
extern bool BuyLimit = false; // BuyLimit
extern bool SellLimit = false; // SellLimit
extern bool BuyStop = false; // BuyStop
extern bool SellStop = false; // SellStop
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void PutHLine(string name,double p,color clr)
{
ObjectDelete(0,name);
ObjectCreate(0,name,OBJ_HLINE,0,0,p);
//--- установим цвет линии
ObjectSetInteger(0,name,OBJPROP_COLOR,clr);
//--- установим толщину линии
ObjectSetInteger(0,name,OBJPROP_WIDTH,1);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void PutOrder(int type,double price)
{
int r=0,err=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,Lot,NormalizeDouble(price,Digits),Slip,sl,tp,"",Magic,TimeCurrent()+Expiration*60,clr);
return;
}
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
double h=NormalizeDouble(High[iHighest(NULL,0,MODE_HIGH,Count,Start)],Digits);
double l=NormalizeDouble(Low[iLowest(NULL,0,MODE_LOW,Count,Start)],Digits);
double channel=(h-l)/Point+Delta*2;
if(channel>=ChannelWidth)
{
if(Bid<h-DeltaPrice*Point)
{
if(BuyStop) PutOrder(4,h+Delta*Point);
if(SellLimit) PutOrder(3,h+Delta*Point);
}
if(Bid>l+DeltaPrice*Point)
{
if(BuyLimit) PutOrder(2,l-Delta*Point);
if(SellStop) PutOrder(5,l-Delta*Point);
}
}
PutHLine("Res Line: "+(string)l,l,Blue);
PutHLine("Supp Line: "+(string)h,h,Red);
Comment("\n Channel Width: ",NormalizeDouble(channel,0));
}
//+------------------------------------------------------------------+
Минимальное расстояние между отложками включая отступ в пунктах.
И минимальное расстояние текущей цены от минимальной и максимальной цены в пунктах.
//+------------------------------------------------------------------+
//| Unlimited.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
#property show_inputs
//--- Inputs
extern double Lot = 0.1; // Trade volume
extern int StopLoss = 0; // Order sroploss
extern int TakeProfit = 0; // Order takeprofit
extern int Expiration = 60; // The expiry of the order in minutes
extern int Delta = 100; // Distance from the price
extern int Count = 5; // Bars count
extern int Slip = 3; // Slippage
extern int Magic = 123; // Magic number
extern bool BuyLimit = true; // BuyLimit
extern bool SellLimit = true; // SellLimit
extern bool BuyStop = true; // BuyStop
extern bool SellStop = true; // SellStop
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void PutOrder(int type,double price)
{
int r=0,err=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,Lot,NormalizeDouble(price,Digits),Slip,sl,tp,"",Magic,TimeCurrent()+Expiration*60,clr);
return;
}
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
double h=High[iHighest(NULL,0,MODE_HIGH,Count,0)];
double l=High[iLowest(NULL,0,MODE_LOW,Count,0)];
if(Bid<h)
{
if(BuyStop) PutOrder(4,h+Delta*Point);
if(SellLimit) PutOrder(3,h+Delta*Point);
}
if(Bid>l)
{
if(BuyLimit) PutOrder(2,l-Delta*Point);
if(SellStop) PutOrder(5,l-Delta*Point);
}
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Grid.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
#property indicator_chart_window
input int Step=55; // шаг между линиями
input int Count=5; // число линий
input int Days=3; // дней для расчета
input int Koef=4; // делитель волатильности
input bool D=false; // флаг расчета по дням
input color ColorSup=Red; // цвет сопротивления
input color ColorRes=Blue; // цвет поддержки
bool Put=true;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
Comment("");
ObjectsDeleteAll(0,0,OBJ_HLINE);
}
//+------------------------------------------------------------------+
//| Горизонтальная линия |
//+------------------------------------------------------------------+
void PutHLine(string name,double p,color clr)
{
ObjectDelete(0,name);
ObjectCreate(0,name,OBJ_HLINE,0,0,p);
//--- установим цвет линии
ObjectSetInteger(0,name,OBJPROP_COLOR,clr);
//--- установим толщину линии
ObjectSetInteger(0,name,OBJPROP_WIDTH,1);
}
//+------------------------------------------------------------------+
//| 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 delta=0,pr1=0,pr2=0;
for(int i=1;i<=Days;i++)
{
delta=((iHigh(NULL,PERIOD_D1,i)-iLow(NULL,PERIOD_D1,i))/Days/Koef)/Point;
}
if(Put)
{
for(int i=1;i<=Count;i++)
{
if(D)
{
pr1=NormalizeDouble(Bid+delta*Point*i,Digits);
PutHLine("Supp Line: "+(string)pr1,pr1,ColorSup);
pr2=NormalizeDouble(Bid-delta*Point*i,Digits);
PutHLine("Res Line: "+(string)pr2,pr2,ColorRes);
Put=false;
}
if(D==false)
{
pr1=NormalizeDouble(Bid+Step*Point*i,Digits);
PutHLine("Supp Line: "+(string)pr1,pr1,ColorSup);
pr2=NormalizeDouble(Bid-Step*Point*i,Digits);
PutHLine("Res Line: "+(string)pr2,pr2,ColorRes);
Put=false;
}
}
}
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Grider.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 Lot = 0.1; // Trade volume
extern double MinLot = 0.1; // Minimum lot
extern double MaxLot = 5; // Maximum lot
extern double Risk = 10; // Risk
extern int ProfitPoints = 0; // Profit Points
extern int StopLoss = 0; // Order sroploss
extern int TakeProfit = 0; // Order takeprofit
extern int Count = 5; // Orders count
extern int Expiration = 60; // The expiry of the order in minutes
extern int Step = 100; // Order step
extern int Delta = 100; // Distance from the price
extern int Slip = 3; // Slippage
extern int Magic = 123; // Magic number
bool PutGrid=true;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
Comment("");
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void PutOrder(int type,double price)
{
int r=0,err=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(type),NormalizeDouble(price,Digits),Slip,sl,tp,"",Magic,TimeCurrent()+Expiration*60,clr);
return;
}
//+------------------------------------------------------------------+
//| Закрытие позиции по типу ордера |
//+------------------------------------------------------------------+
void CloseProfit(int ot=-1)
{
bool cl;
int err=0;
for(int i=OrdersTotal()-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
{
if(OrderType()==0 && (ot==0 || ot==-1))
{
RefreshRates();
if(OrderProfit()>0) cl=OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(Bid,Digits),Slip,White);
}
if(OrderType()==1 && (ot==1 || ot==-1))
{
RefreshRates();
if(OrderProfit()>0) cl=OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(Ask,Digits),Slip,White);
}
}
}
}
}
//+------------------------------------------------------------------+
//| Подсчет ордеров по типу |
//+------------------------------------------------------------------+
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);
}
//+------------------------------------------------------------------+
//| Профит прибыльных ордеров по типу ордера |
//+------------------------------------------------------------------+
double AllProfit(int ot=-1)
{
double pr=0;
for(int i=OrdersTotal()-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
{
if(OrderType()==0 && (ot==0 || ot==-1))
{
if(OrderProfit()>0) pr+=(Bid-OrderOpenPrice())/Point;
}
if(OrderType()==1 && (ot==1 || ot==-1))
{
if(OrderProfit()>0) pr+=(OrderOpenPrice()-Ask)/Point;
}
}
}
}
return(pr);
}
//+------------------------------------------------------------------+
//| Лот для гридера |
//+------------------------------------------------------------------+
double Lots(int type)
{
double lots=Lot;
if(Lot==0) lots=NormalizeDouble(AccountFreeMargin()*Risk/(100000*Count*2),2);
if(lots>MaxLot)lots=MaxLot;
if(lots<MinLot)lots=MinLot;
return(lots);
}
//+------------------------------------------------------------------+
//| Удаление отложенных ордеров |
//+------------------------------------------------------------------+
void DelOrder()
{
bool del;
for(int i=OrdersTotal()-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
{
if(OrderType()>1) del=OrderDelete(OrderTicket());
}
}
}
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
if(PutGrid)
{
DelOrder();
for(int i=1; i<=Count;i++)
{
{
PutOrder(4,Bid+Delta*Point+Step*Point*i);//buystop
PutOrder(5,Bid-Delta*Point-Step*Point*i);//sellstop
}
}
PutGrid=false;
}
if(AllProfit()>ProfitPoints && ProfitPoints>0)
{
CloseProfit();
PutGrid=true;
}
Comment("\n All Profit: ",AllProfit(-1),
"\n Buy Profit: ",AllProfit(0),
"\n Sell Profit: ",AllProfit(1),
"\n Buy Positions: ",CountOrders(0),
"\n Sell Positions: ",CountOrders(1),
"\n All Positions: ",CountOrders(0)+CountOrders(1),
"\n Account Free Margin: ",NormalizeDouble(AccountFreeMargin(),2));
}
//+------------------------------------------------------------------+
Главное по Мартину: он должен учитывать сумму закрывшейся пары. Если общий минус – увеличивает, если плюс – нет.
Баннеры можно размещать в группах, которые ты сам создавал.
В данном случае разместить может Администрация (и, скорее всего, разместит)
Это как это? Формулы, примеры пожалуйста?
AM2