extern bool ShowButtons = 1; // кнопки
double allpro=CountTrades()*AllLots()*AllPro; // 5*(0.1+0.2+0.3+0.4+0.5)*20=150
if(AllProfit()>allpro && AllPro>0)
CloseAll();
//+------------------------------------------------------------------+
//| Procent2.mq4 |
//| Copyright 2019, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2019, AM2"
#property link "http://www.forexsystems.biz"
#property version "1.00"
#property strict
#property indicator_chart_window
input int x=88;
input int y=44;
input int corner=3;
input double procent=0;
input color fon=Black;
bool p=1;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
Comment("");
ObjectDelete(0,"PRO");
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
double Pro()
{
double pro=(AccountEquity()-AccountBalance())/AccountBalance()*100;//(1100-1000)/1000
return(pro);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void PutButton(string text)
{
ObjectDelete(0,"PRO");
ObjectCreate(0,"PRO",OBJ_BUTTON,0,0,0);
//--- установим координаты кнопки
ObjectSetInteger(0,"PRO",OBJPROP_XDISTANCE,x);
ObjectSetInteger(0,"PRO",OBJPROP_YDISTANCE,y);
//--- установим размер кнопки
ObjectSetInteger(0,"PRO",OBJPROP_XSIZE,50);
ObjectSetInteger(0,"PRO",OBJPROP_YSIZE,30);
//--- установим угол графика, относительно которого будут определяться координаты точки
ObjectSetInteger(0,"PRO",OBJPROP_CORNER,corner);
//--- установим текст
ObjectSetString(0,"PRO",OBJPROP_TEXT,text);
//--- установим шрифт текста
ObjectSetString(0,"PRO",OBJPROP_FONT,"Arial");
//--- установим размер шрифта
ObjectSetInteger(0,"PRO",OBJPROP_FONTSIZE,12);
//--- установим цвет текста
ObjectSetInteger(0,"PRO",OBJPROP_COLOR,Red);
//--- установим цвет фона
ObjectSetInteger(0,"PRO",OBJPROP_BGCOLOR,fon);
//--- установим цвет границы
ObjectSetInteger(0,"PRO",OBJPROP_BORDER_COLOR,White);
}
//+------------------------------------------------------------------+
//| 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[])
{
//---
PutButton((string)(NormalizeDouble(Pro(),2))+" %");
if(Pro()<procent)
p=1;
if(Pro()>procent && p)
{
Alert("Профит : "+(string)NormalizeDouble(Pro(),2)+" %");
p=0;
}
if(Pro()>0)
ObjectSetInteger(0,"PRO",OBJPROP_COLOR,Lime);
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+
Расшифруйте пожалуйста пункт.
«На каком баре сигнал индикатора»
С какими настройками вы тестировали советник? На вашем скрине сделки открываются и закрываются где-попало.
Советник торгует не учитывая направление средней линии
индикатора
double up = iCustom(NULL,0,IndName,TimeFrame,HalfLength,Price,ATRMultiplier,ATRPeriod,Interpolate,1,Shift);
double dn = iCustom(NULL,0,IndName,TimeFrame,HalfLength,Price,ATRMultiplier,ATRPeriod,Interpolate,2,Shift);
double s1 = iCustom(NULL,0,IndName,TimeFrame,HalfLength,Price,ATRMultiplier,ATRPeriod,Interpolate,0,Shift);
double s2 = iCustom(NULL,0,IndName,TimeFrame,HalfLength,Price,ATRMultiplier,ATRPeriod,Interpolate,0,Shift+1);
if(CloseSig>0)
{
if(Bid>up)
{
CloseAll(0);
}
if(Bid<dn)
{
CloseAll(1);
}
}
if(CountTrades()<1)
{
if(Open[0]<dn && Ask>dn && s1>s2)
{
PutOrder(0,Ask);
}
if(Open[0]>up && Bid<up && s1<s2)
{
PutOrder(1,Bid);
}
}
С какими настройками вы тестировали советник?
extern string TimeFrame = "current time frame";
extern int HalfLength = 56;
extern int Price = PRICE_CLOSE;
extern double ATRMultiplier = 2.0;
extern int ATRPeriod = 100;
extern bool Interpolate = true;
«перенос индикатора в советник» не возможен именно индикатора FL23 или любого другого тоже?
AM2