Слова автора «как сделать чтобы было только когда меняю ТФ», а в вашем варианте «пищит» на все
//+------------------------------------------------------------------+
//| GDV.mq4 |
//| Copyright 2019, |
//| |
//+------------------------------------------------------------------+
#property copyright "GDV"
#property version "1.00"
#property strict
#property indicator_chart_window
input string mus="alert.wav";
int OnInit()
{
GlobalVariableSet("val",1);
return(INIT_SUCCEEDED);
}
void OnDeinit(const int reason)
{
if(reason==1)
GlobalVariablesDeleteAll(); else PlaySound(mus);
Comment("\n Total: ",GlobalVariablesTotal());
}
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[])
{
Comment("\n Total: ",GlobalVariablesTotal());
return(rates_total);
}
//+------------------------------------------------------------------+
//| Profit.mq4 |
//| GDV |
//| 2019.01 |
//+------------------------------------------------------------------+
#property copyright "GDV"
#property link "2019.01"
#property version "1.00"
#property strict
//+------------------------------------------------------------------+
extern int MagicBuy = 1; //Если прописать магик то будет закрывать
extern int MagicSell = 2; //определенные ордера(например только от советника)
//выставленные вручную нетогает
extern double Profit = 10.0; //Желаемый Min доход
double PR_S,PR_B;
//+------------------------------------------------------------------+
int OnInit()
{
return(INIT_SUCCEEDED);
}
//---------------------------------------------------------------------------------------------------
int CountBYU()
{
int count=0;
for(int i=OrdersTotal()-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicBuy)
{
if(OrderType()==OP_BUY) count++;
}
}
}
return(count);
}
//-----------------------------------------------------------------------------------------------------
int CountSELL()
{
int count=0;
for(int i=OrdersTotal()-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicSell)
{
if(OrderType()==OP_SELL) count++;
}
}
}
return(count);
}
int start()
{
if (CountBYU()==1)
{
for(int i=OrdersTotal()-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol()==Symbol() && OrderType()==OP_BUY && OrderMagicNumber()==MagicBuy)
{
if(OrderProfit()>Profit){
PR_B=OrderProfit();
bool cl=OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(Bid,Digits),30,White);}
}
}
}
}
if (CountSELL()==1)
{
for(int j=OrdersTotal()-1;j>=0;j--)
{
if(OrderSelect(j,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol()==Symbol() && OrderType()==OP_SELL && OrderMagicNumber()==MagicSell)
{
if(OrderProfit()>Profit){
PR_S=OrderProfit();
bool cl=OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(Ask,Digits),30,White);}
}
}
}
}
if (IsTesting() && OrdersTotal()==0)
{
bool l1= OrderSend(Symbol(),OP_BUY,0.5,NormalizeDouble(Ask,Digits),30,0,0,NULL,MagicBuy,0,clrBlue);
bool l2= OrderSend(Symbol(),OP_SELL,0.5,NormalizeDouble(Bid,Digits),30,0,0,NULL,MagicSell,0,clrRed);
}
Comment("\n",CountBYU(),
"\n",CountSELL(),
"\n",PR_B,
"\n",PR_S);
return(0);
}
//+------------------------------------------------------------------+
Вот я и переделал
Servir