В ваших настройках ничего не понял, это БО или Форекс.
тп, сл, трал, бу, время работыэто будет.
//+------------------------------------------------------------------+
//| Color.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
//--- Inputs
extern double Lots = 0.1; // лот
extern int StopLoss = 2000; // лось
extern int TakeProfit = 3000; // язь
extern double Loss = 4500; // лось в рублях
extern double Profit = 20; // язь в рублях
extern int Delta = 100; // расстояние от МА
extern int Slip = 30; // реквот
extern int Shift = 1; // на каком баре сигнал индикатора
extern int Magic = 123; // магик
extern string IndName = "STDC60";
extern int InpKPeriod = 60; // K Period
extern int InpDPeriod = 3; // D Period
extern int InpSlowing = 3; // Slowing
extern string IndName2="Color ma BDv8_12_31";
extern int MA_Period = 50;
extern int MA_Type = 5;
extern int MA_Applied = 0;
extern double T3MA_VolumeFactor = 0.8;
extern double JMA_Phase = 0;
extern int Step_Period = 1;
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 OpenPos()
{
double lim = iCustom(NULL,0,IndName,InpKPeriod,InpDPeriod,InpSlowing,0,Shift);
double red = iCustom(NULL,0,IndName,InpKPeriod,InpDPeriod,InpSlowing,1,Shift);
double ma = iCustom(NULL,0,IndName2,MA_Period,MA_Type,MA_Applied,T3MA_VolumeFactor,JMA_Phase,Step_Period,3,Shift);
if(lim<1000 && Bid<(ma-Delta*Point))
{
PutOrder(0,Ask);
}
if(red<1000 && Bid>(ma+Delta*Point))
{
PutOrder(1,Bid);
}
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void ClosePos()
{
double gre = iCustom(NULL,0,IndName2,2,Shift);
double mag = iCustom(NULL,0,IndName2,1,Shift);
if(gre<1000)
{
CloseAll(0);
}
if(mag<1000)
{
CloseAll(1);
}
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void CloseAll(int ot=-1)
{
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()==0 && (ot==0 || ot==-1))
{
RefreshRates();
cl=OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(Bid,Digits),Slip,White);
}
if(OrderType()==1 && (ot==1 || ot==-1))
{
RefreshRates();
cl=OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(Ask,Digits),Slip,White);
}
}
}
}
}
//+------------------------------------------------------------------+
//| Профит всех ордеров по типу ордера |
//+------------------------------------------------------------------+
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))
{
pr+=OrderProfit()+OrderCommission()+OrderSwap();
}
if(OrderType()==1 && (ot==1 || ot==-1))
{
pr+=OrderProfit()+OrderCommission()+OrderSwap();
}
}
}
}
return(pr);
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
double ma=iCustom(NULL,0,IndName2,0,Shift);
double gre=iCustom(NULL,0,IndName2,2,Shift);
double mag = iCustom(NULL,0,IndName2,1,Shift);
double lim = iCustom(NULL,0,IndName,0,Shift);
double red = iCustom(NULL,0,IndName,1,Shift);
if((Profit>0 && AllProfit()>Profit) || (Loss>0 && AllProfit()<-Loss)) CloseAll();
if(t!=Time[0])
{
OpenPos();
t=Time[0];
}
ClosePos();
Comment("\n lim: ",lim,
"\n red: ",red,
"\n ma: ",ma,
"\n gre: ",gre,
"\n mag: ",mag,
"\n MA+D: ",ma+Delta*Point,
"\n MA-D: ",ma-Delta*Point);
}
//+------------------------------------------------------------------+
ТЗ в текстовом файлетз мне нужно видеть в топике целиком
AM2