Você está perdendo oportunidades de negociação:
- Aplicativos de negociação gratuitos
- 8 000+ sinais para cópia
- Notícias econômicas para análise dos mercados financeiros
Registro
Login
Você concorda com a política do site e com os termos de uso
Se você não tem uma conta, por favor registre-se
É mais ou menos assim:
Boa tarde, Alguém pode sugerir uma solução para este problema? Há um código com entrada na M15, mas o sinal de H1 é levado em conta. Enquanto há um sinal na H1, na M15 o indicador dá vários sinais. A questão é como limitá-lo a um (ou seja, o primeiro sinal).
k=0;
for (i=OrdensTotal()-1;i>=0;i--)
{
RefreshRates();
if(OrderSelect (i, SELECT_BY_POS, MODE_TRADES) == true) a = 0;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic) k++;
}
if( stM1 >= 80 && stM0 < 80 && stH0 < 30 && k==0 && opp != Tempo[0]) // venda
Eu escrevi um pequeno painel informativo:
extern color PanelBackgroundColor = Black;
extern color PanelTextColor = White;
double MaxDD;
int OnInit()
{
//--- indicator buffers mapping
ObjectCreate("Background", OBJ_RECTANGLE_LABEL, 0, 0, 0);
ObjectSet("Background", OBJPROP_CORNER, 0);
ObjectSet("Background", OBJPROP_XDISTANCE, 5);
ObjectSet("Background", OBJPROP_YDISTANCE, 35);
ObjectSet("Background", OBJPROP_XSIZE, 215);
ObjectSet("Background", OBJPROP_YSIZE, 220);
ObjectSet("Background", OBJPROP_BGCOLOR, PanelBackgroundColor);
ObjectCreate("Account information", OBJ_LABEL, 0, 0, 0);
ObjectSet("Account information", OBJPROP_CORNER, 0);
ObjectSet("Account information", OBJPROP_XDISTANCE, 15);
ObjectSet("Account information", OBJPROP_YDISTANCE, 45);
ObjectSetText("Account information","=====Account information=====",10,"Arial",PanelTextColor);
ObjectCreate("Balance", OBJ_LABEL, 0, 0, 0);
ObjectSet("Balance", OBJPROP_CORNER, 0);
ObjectSet("Balance", OBJPROP_XDISTANCE, 15);
ObjectSet("Balance", OBJPROP_YDISTANCE, 60);
ObjectCreate("Profit/DD", OBJ_LABEL, 0, 0, 0);
ObjectSet("Profit/DD", OBJPROP_CORNER, 0);
ObjectSet("Profit/DD", OBJPROP_XDISTANCE, 15);
ObjectSet("Profit/DD", OBJPROP_YDISTANCE, 75);
ObjectCreate("Max DD", OBJ_LABEL, 0, 0, 0);
ObjectSet("Max DD", OBJPROP_CORNER, 0);
ObjectSet("Max DD", OBJPROP_XDISTANCE, 15);
ObjectSet("Max DD", OBJPROP_YDISTANCE, 90);
ObjectCreate("Equity", OBJ_LABEL, 0, 0, 0);
ObjectSet("Equity", OBJPROP_CORNER, 0);
ObjectSet("Equity", OBJPROP_XDISTANCE, 15);
ObjectSet("Equity", OBJPROP_YDISTANCE, 105);
ObjectCreate("Free margin", OBJ_LABEL, 0, 0, 0);
ObjectSet("Free margin", OBJPROP_CORNER, 0);
ObjectSet("Free margin", OBJPROP_XDISTANCE, 15);
ObjectSet("Free margin", OBJPROP_YDISTANCE, 120);
ObjectCreate("Pair information", OBJ_LABEL, 0, 0, 0);
ObjectSet("Pair information", OBJPROP_CORNER, 0);
ObjectSet("Pair information", OBJPROP_XDISTANCE, 15);
ObjectSet("Pair information", OBJPROP_YDISTANCE, 150);
ObjectSetText("Pair information","=======Pair information======",10,"Arial",PanelTextColor);
ObjectCreate("Pair", OBJ_LABEL, 0, 0, 0);
ObjectSet("Pair", OBJPROP_CORNER, 0);
ObjectSet("Pair", OBJPROP_XDISTANCE, 15);
ObjectSet("Pair", OBJPROP_YDISTANCE, 165);
ObjectSetText("Pair","Pair: "+Symbol(),10,"Arial",PanelTextColor);
ObjectCreate("Margin required", OBJ_LABEL, 0, 0, 0);
ObjectSet("Margin required", OBJPROP_CORNER, 0);
ObjectSet("Margin required", OBJPROP_XDISTANCE, 15);
ObjectSet("Margin required", OBJPROP_YDISTANCE, 180);
ObjectCreate("Price pips", OBJ_LABEL, 0, 0, 0);
ObjectSet("Price pips", OBJPROP_CORNER, 0);
ObjectSet("Price pips", OBJPROP_XDISTANCE, 15);
ObjectSet("Price pips", OBJPROP_YDISTANCE, 195);
ObjectCreate("Spread", OBJ_LABEL, 0, 0, 0);
ObjectSet("Spread", OBJPROP_CORNER, 0);
ObjectSet("Spread", OBJPROP_XDISTANCE, 15);
ObjectSet("Spread", OBJPROP_YDISTANCE, 210);
ObjectCreate("Leverage", OBJ_LABEL, 0, 0, 0);
ObjectSet("Leverage", OBJPROP_CORNER, 0);
ObjectSet("Leverage", OBJPROP_XDISTANCE, 15);
ObjectSet("Leverage", OBJPROP_YDISTANCE, 225);
//---
return(INIT_SUCCEEDED);
}
void start()
{
//Расчет максимальной просадки
if (AccountProfit()<0)
{
if (AccountProfit()<MaxDD)
MaxDD=AccountProfit();
}
ObjectSetText("Balance","Balance: "+DoubleToString (AccountBalance(),2)+" "+AccountCurrency(),10,"Arial",PanelTextColor);
ObjectSetText("Profit/DD","Profit/DD: "+DoubleToString (AccountProfit(),2)+" ("+DoubleToString((AccountProfit()*100)/AccountBalance(),2)+"%)",10,"Arial",PanelTextColor);
ObjectSetText("Max DD","Max DD: "+DoubleToString (MaxDD,2)+" ("+DoubleToString((MaxDD*100)/AccountBalance(),2)+"%)",10,"Arial",PanelTextColor);
ObjectSetText("Equity","Equity: "+DoubleToString (AccountEquity(),2),10,"Arial",PanelTextColor);
ObjectSetText("Free margin","Free margin: "+DoubleToString (AccountFreeMargin(),2),10,"Arial",PanelTextColor);
ObjectSetText("Margin required","Margin required: "+DoubleToString(MarketInfo(Symbol(), MODE_MARGINREQUIRED), 2)+" $",10,"Arial",PanelTextColor);
ObjectSetText("Price pips","Price pips: "+DoubleToString(MarketInfo(Symbol(), MODE_TICKVALUE), 2)+" $",10,"Arial",PanelTextColor);
ObjectSetText("Spread","Spread: "+DoubleToString(MarketInfo(Symbol(),MODE_SPREAD),2),10,"Arial",PanelTextColor);
ObjectSetText("Leverage","Leverage: 1:"+IntegerToString(AccountLeverage(), 0),10,"Arial",PanelTextColor);
}
Tudo funciona, exibe as informações corretamente, mas assim que você reinicia o terminal, o painel pára de funcionar (escreve que o saldo é 0 e o resto das informações pára de atualizar e congela em uma posição, simplesmente desliga). Como combater isso?
Uma captura de tela é anexada:Eu escrevi um pequeno painel informativo:
extern color PanelBackgroundColor = Black;
extern color PanelTextColor = White;
double MaxDD;
int OnInit()
{
//--- indicator buffers mapping
ObjectCreate("Background", OBJ_RECTANGLE_LABEL, 0, 0, 0);
ObjectSet("Background", OBJPROP_CORNER, 0);
ObjectSet("Background", OBJPROP_XDISTANCE, 5);
ObjectSet("Background", OBJPROP_YDISTANCE, 35);
ObjectSet("Background", OBJPROP_XSIZE, 215);
ObjectSet("Background", OBJPROP_YSIZE, 220);
ObjectSet("Background", OBJPROP_BGCOLOR, PanelBackgroundColor);
ObjectCreate("Account information", OBJ_LABEL, 0, 0, 0);
ObjectSet("Account information", OBJPROP_CORNER, 0);
ObjectSet("Account information", OBJPROP_XDISTANCE, 15);
ObjectSet("Account information", OBJPROP_YDISTANCE, 45);
ObjectSetText("Account information","=====Account information=====",10,"Arial",PanelTextColor);
ObjectCreate("Balance", OBJ_LABEL, 0, 0, 0);
ObjectSet("Balance", OBJPROP_CORNER, 0);
ObjectSet("Balance", OBJPROP_XDISTANCE, 15);
ObjectSet("Balance", OBJPROP_YDISTANCE, 60);
ObjectCreate("Profit/DD", OBJ_LABEL, 0, 0, 0);
ObjectSet("Profit/DD", OBJPROP_CORNER, 0);
ObjectSet("Profit/DD", OBJPROP_XDISTANCE, 15);
ObjectSet("Profit/DD", OBJPROP_YDISTANCE, 75);
ObjectCreate("Max DD", OBJ_LABEL, 0, 0, 0);
ObjectSet("Max DD", OBJPROP_CORNER, 0);
ObjectSet("Max DD", OBJPROP_XDISTANCE, 15);
ObjectSet("Max DD", OBJPROP_YDISTANCE, 90);
ObjectCreate("Equity", OBJ_LABEL, 0, 0, 0);
ObjectSet("Equity", OBJPROP_CORNER, 0);
ObjectSet("Equity", OBJPROP_XDISTANCE, 15);
ObjectSet("Equity", OBJPROP_YDISTANCE, 105);
ObjectCreate("Free margin", OBJ_LABEL, 0, 0, 0);
ObjectSet("Free margin", OBJPROP_CORNER, 0);
ObjectSet("Free margin", OBJPROP_XDISTANCE, 15);
ObjectSet("Free margin", OBJPROP_YDISTANCE, 120);
ObjectCreate("Pair information", OBJ_LABEL, 0, 0, 0);
ObjectSet("Pair information", OBJPROP_CORNER, 0);
ObjectSet("Pair information", OBJPROP_XDISTANCE, 15);
ObjectSet("Pair information", OBJPROP_YDISTANCE, 150);
ObjectSetText("Pair information","=======Pair information======",10,"Arial",PanelTextColor);
ObjectCreate("Pair", OBJ_LABEL, 0, 0, 0);
ObjectSet("Pair", OBJPROP_CORNER, 0);
ObjectSet("Pair", OBJPROP_XDISTANCE, 15);
ObjectSet("Pair", OBJPROP_YDISTANCE, 165);
ObjectSetText("Pair","Pair: "+Symbol(),10,"Arial",PanelTextColor);
ObjectCreate("Margin required", OBJ_LABEL, 0, 0, 0);
ObjectSet("Margin required", OBJPROP_CORNER, 0);
ObjectSet("Margin required", OBJPROP_XDISTANCE, 15);
ObjectSet("Margin required", OBJPROP_YDISTANCE, 180);
ObjectCreate("Price pips", OBJ_LABEL, 0, 0, 0);
ObjectSet("Price pips", OBJPROP_CORNER, 0);
ObjectSet("Price pips", OBJPROP_XDISTANCE, 15);
ObjectSet("Price pips", OBJPROP_YDISTANCE, 195);
ObjectCreate("Spread", OBJ_LABEL, 0, 0, 0);
ObjectSet("Spread", OBJPROP_CORNER, 0);
ObjectSet("Spread", OBJPROP_XDISTANCE, 15);
ObjectSet("Spread", OBJPROP_YDISTANCE, 210);
ObjectCreate("Leverage", OBJ_LABEL, 0, 0, 0);
ObjectSet("Leverage", OBJPROP_CORNER, 0);
ObjectSet("Leverage", OBJPROP_XDISTANCE, 15);
ObjectSet("Leverage", OBJPROP_YDISTANCE, 225);
//---
return(INIT_SUCCEEDED);
}
void start()
{
//Расчет максимальной просадки
if (AccountProfit()<0)
{
if (AccountProfit()<MaxDD)
MaxDD=AccountProfit();
}
ObjectSetText("Balance","Balance: "+DoubleToString (AccountBalance(),2)+" "+AccountCurrency(),10,"Arial",PanelTextColor);
ObjectSetText("Profit/DD","Profit/DD: "+DoubleToString (AccountProfit(),2)+" ("+DoubleToString((AccountProfit()*100)/AccountBalance(),2)+"%)",10,"Arial",PanelTextColor);
ObjectSetText("Max DD","Max DD: "+DoubleToString (MaxDD,2)+" ("+DoubleToString((MaxDD*100)/AccountBalance(),2)+"%)",10,"Arial",PanelTextColor);
ObjectSetText("Equity","Equity: "+DoubleToString (AccountEquity(),2),10,"Arial",PanelTextColor);
ObjectSetText("Free margin","Free margin: "+DoubleToString (AccountFreeMargin(),2),10,"Arial",PanelTextColor);
ObjectSetText("Margin required","Margin required: "+DoubleToString(MarketInfo(Symbol(), MODE_MARGINREQUIRED), 2)+" $",10,"Arial",PanelTextColor);
ObjectSetText("Price pips","Price pips: "+DoubleToString(MarketInfo(Symbol(), MODE_TICKVALUE), 2)+" $",10,"Arial",PanelTextColor);
ObjectSetText("Spread","Spread: "+DoubleToString(MarketInfo(Symbol(),MODE_SPREAD),2),10,"Arial",PanelTextColor);
ObjectSetText("Leverage","Leverage: 1:"+IntegerToString(AccountLeverage(), 0),10,"Arial",PanelTextColor);
}
Tudo funciona, exibe as informações corretamente, mas quando você reinicia o terminal, o painel pára de funcionar (escreve que o saldo é 0, e o resto das informações pára de se atualizar e congela em uma posição, simplesmente desliga). Como lidar com isso?
Estou anexando uma captura de tela:Problema semelhante discutido não há muito tempo, se você olhou para o registro ou guia de especialista, eu posso dizer com 100% de certeza que você tem uma divisão por erro zero nestas linhas
ObjectSetText("Max DD","Max DD: "+DoubleToString (MaxDD,2)+" ("+DoubleToString((MaxDD*100)/AccountBalance(),2)+"%)",10,"Arial",PanelTextColor);
...
Eu escrevi um pequeno painel informativo:
{
//Расчет максимальной просадки
if (AccountProfit()<0)
{
if (AccountProfit()<MaxDD)
MaxDD=AccountProfit();
}
ObjectSetText("Balance","Balance: "+DoubleToString (AccountBalance(),2)+" "+AccountCurrency(),10,"Arial",PanelTextColor);
...
ObjectSetText("Leverage","Leverage: 1:"+IntegerToString(AccountLeverage(), 0),10,"Arial",PanelTextColor);
}
Tudo funciona, exibe as informações corretamente, mas assim que você reinicia o terminal, o painel pára de funcionar (escreve que o saldo é 0 e o resto das informações pára de atualizar e congela em uma posição, simplesmente desliga). Como lutar contra isso?
Foto da tela anexada:Experimente assim:
{
if (AccountBalance()<5) return; // <<< if (AccountBalance()==0) return;
//Расчет максимальной просадки
if (AccountProfit()<0)
{
if (AccountProfit()<MaxDD)
MaxDD=AccountProfit();
}
ObjectSetText("Balance","Balance: "+DoubleToString (AccountBalance(),2)+" "+AccountCurrency(),10,"Arial",PanelTextColor);
...
ObjectSetText("Leverage","Leverage: 1:"+IntegerToString(AccountLeverage(), 0),10,"Arial",PanelTextColor);
}
Escreveu um pequeno painel de informações:
extern color PanelBackgroundColor = Black;
extern color PanelTextColor = White;
Tudo funciona, as informações são exibidas corretamente, mas assim que o terminal é reiniciado, o painel para de funcionar (diz que o saldo é 0 e o restante das informações para de atualizar e congela em uma posição, simplesmente congela). Como lidar com isso?
Captura de tela anexada:Fiz uma pequena mágica no seu painel. Peguei esse código, eliminei o erro de divisão por zero .
//| test_panel.mq4 |
//| Sergey Gritsay |
//| https://www.mql5.com/ru/users/sergey1294 |
//+------------------------------------------------------------------+
#property copyright "Sergey Gritsay"
#property link "https://www.mql5.com/ru/users/sergey1294"
#property version "1.00"
#property strict
sinput string Display= NULL ; //Настройки отображения
input color PanelBackgroundColor = clrBlack ;
input color PanelTextColor = clrWhite ;
input color ColorMinus= clrRed ;
input color ColorPlus= clrBlueViolet ;
input color ColorZero= clrMediumAquamarine ;
double balans= 0.0 ;
double profit= 0.0 ;
double profit_dd_procent= 0.0 ;
double MaxDD= 0.0 ;
double MaxDD_procent= 0.0 ;
double Equity= 0.0 ;
double Freemargin= 0.0 ;
double Marginrequired= 0.0 ;
double Pricepips= 0.0 ;
int Spread= 0 ;
int Leverage= 0 ;
string symbol= NULL ;
string currency= NULL ;
int X= 15 ;
int Y= 45 ;
int size= 15 ;
int x_sdvig= 150 ;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit ()
{
//---
Refresh();
Panel();
//---
return ( INIT_SUCCEEDED );
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit ( const int reason)
{
//---
RectLabelDelete( 0 , "Background" );
LabelDelete( 0 , "Account information" );
LabelDelete( 0 , "Balance" );
LabelDelete( 0 , "Balance value" );
LabelDelete( 0 , "Profit/DD" );
LabelDelete( 0 , "Profit/DD value" );
LabelDelete( 0 , "Max DD" );
LabelDelete( 0 , "Max DD value" );
LabelDelete( 0 , "Equity" );
LabelDelete( 0 , "Equity value" );
LabelDelete( 0 , "Free margin" );
LabelDelete( 0 , "Free margin value" );
LabelDelete( 0 , "Pair information" );
LabelDelete( 0 , "Pair" );
LabelDelete( 0 , "Pair value" );
LabelDelete( 0 , "Margin required" );
LabelDelete( 0 , "Margin required value" );
LabelDelete( 0 , "Price pips" );
LabelDelete( 0 , "Price pips value" );
LabelDelete( 0 , "Spread" );
LabelDelete( 0 , "Spread value" );
LabelDelete( 0 , "Leverage" );
LabelDelete( 0 , "Leverage value" );
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick ()
{
//---
Refresh();
Panel();
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void Refresh()
{
symbol= _Symbol ;
currency= AccountInfoString ( ACCOUNT_CURRENCY );
balans = AccountInfoDouble ( ACCOUNT_BALANCE );
profit = AccountInfoDouble ( ACCOUNT_PROFIT );
Equity = AccountInfoDouble ( ACCOUNT_EQUITY );
Freemargin= AccountInfoDouble ( ACCOUNT_MARGIN_FREE );
Marginrequired= MarketInfo (symbol, MODE_MARGINREQUIRED );
Pricepips= SymbolInfoDouble (symbol, SYMBOL_TRADE_TICK_VALUE );
Leverage=( int ) AccountInfoInteger ( ACCOUNT_LEVERAGE );
double ask= SymbolInfoDouble (symbol, SYMBOL_ASK );
double bid= SymbolInfoDouble (symbol, SYMBOL_BID );
double point= SymbolInfoDouble (symbol, SYMBOL_POINT );
Spread=( int ) SymbolInfoInteger (symbol, SYMBOL_SPREAD );
if (Spread== 0 )Spread= int ((ask-bid)/point);
//Расчет максимальной просадки
if (profit< 0 )
if (profit<MaxDD)
MaxDD=profit;
if (balans!= 0 )
{
profit_dd_procent=profit* 100.0 /balans;
MaxDD_procent=MaxDD* 100.0 /balans;
}
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void Panel()
{
RectLabelCreate( 0 , "Background" , 0 , 5 , 35 , 300 , 230 ,PanelBackgroundColor);
LabelCreate( 0 , "Account information" , 0 ,X,Y, "=====Account information=====" ,PanelTextColor);Y+=size;
LabelCreate( 0 , "Balance" , 0 ,X,Y, "Balance (" +currency+ "):" ,PanelTextColor);
LabelCreate( 0 , "Balance value" , 0 ,x_sdvig,Y, DoubleToString (balans, 2 ),ColorValue(balans));Y+=size;
LabelCreate( 0 , "Profit/DD" , 0 ,X,Y, "Profit/DD (" +currency+ " / %):" ,PanelTextColor);
LabelCreate( 0 , "Profit/DD value" , 0 ,x_sdvig,Y, DoubleToString (profit, 2 )+ " / " + DoubleToString (profit_dd_procent, 2 ),ColorValue(profit));Y+=size;
LabelCreate( 0 , "Max DD" , 0 ,X,Y, "Max DD (" +currency+ " / %):" ,PanelTextColor);
LabelCreate( 0 , "Max DD value" , 0 ,x_sdvig,Y, DoubleToString (MaxDD, 2 )+ " / " + DoubleToString (MaxDD_procent, 2 ),ColorValue(MaxDD));Y+=size;
LabelCreate( 0 , "Equity" , 0 ,X,Y, "Equity (" +currency+ "):" ,PanelTextColor);
LabelCreate( 0 , "Equity value" , 0 ,x_sdvig,Y,( string )Equity,ColorValue(Equity));Y+=size;
LabelCreate( 0 , "Free margin" , 0 ,X,Y, "Free margin (" +currency+ "):" ,PanelTextColor);
LabelCreate( 0 , "Free margin value" , 0 ,x_sdvig,Y,( string )Freemargin,ColorValue(Freemargin));Y+=size;Y+=size;
LabelCreate( 0 , "Pair information" , 0 ,X,Y, "=======Pair information======" ,PanelTextColor);Y+=size;
LabelCreate( 0 , "Pair" , 0 ,X,Y, "Pair:" ,PanelTextColor);
LabelCreate( 0 , "Pair value" , 0 ,x_sdvig,Y,symbol,PanelTextColor);Y+=size;
LabelCreate( 0 , "Margin required" , 0 ,X,Y, "Margin required (" +currency+ "):" ,PanelTextColor);
LabelCreate( 0 , "Margin required value" , 0 ,x_sdvig,Y,( string )Marginrequired,ColorValue(Marginrequired));Y+=size;
LabelCreate( 0 , "Price pips" , 0 ,X,Y, "Price pips (" +currency+ "):" ,PanelTextColor);
LabelCreate( 0 , "Price pips value" , 0 ,x_sdvig,Y,( string )Pricepips,ColorValue(Pricepips));Y+=size;
LabelCreate( 0 , "Spread" , 0 ,X,Y, "Spread:" ,PanelTextColor);
LabelCreate( 0 , "Spread value" , 0 ,x_sdvig,Y,( string )Spread,ColorValue(Spread));Y+=size;
LabelCreate( 0 , "Leverage" , 0 ,X,Y, "Leverage:" ,PanelTextColor);
LabelCreate( 0 , "Leverage value" , 0 ,x_sdvig,Y, "1:" +( string )Leverage,PanelTextColor);
}
//+------------------------------------------------------------------+
//| Создает прямоугольную метку |
//+------------------------------------------------------------------+
bool RectLabelCreate( const long chart_ID= 0 , // ID графика
const string name= "RectLabel" , // имя метки
const int sub_window= 0 , // номер подокна
const int x= 0 , // координата по оси X
const int y= 0 , // координата по оси Y
const int width= 50 , // ширина
const int height= 18 , // высота
const color back_clr= C'236,233,216' , // цвет фона
const ENUM_BORDER_TYPE border= BORDER_SUNKEN , // тип границы
const ENUM_BASE_CORNER corner= CORNER_LEFT_UPPER , // угол графика для привязки
const color clr= clrRed , // цвет плоской границы (Flat)
const ENUM_LINE_STYLE style= STYLE_SOLID , // стиль плоской границы
const int line_width= 1 , // толщина плоской границы
const bool back= false , // на заднем плане
const bool selection= false , // выделить для перемещений
const bool hidden= true , // скрыт в списке объектов
const long z_order= 0 ) // приоритет на нажатие мышью
{
//--- сбросим значение ошибки
ResetLastError ();
//--- создадим прямоугольную метку
if ( ObjectFind (chart_ID,name)!=sub_window)
{
if (! ObjectCreate (chart_ID,name, OBJ_RECTANGLE_LABEL ,sub_window, 0 , 0 ))
{
Print ( __FUNCTION__ ,
": не удалось создать прямоугольную метку! Код ошибки = " , GetLastError ());
return ( false );
}
}
//--- установим координаты метки
ObjectSetInteger (chart_ID,name, OBJPROP_XDISTANCE ,x);
ObjectSetInteger (chart_ID,name, OBJPROP_YDISTANCE ,y);
//--- установим размеры метки
ObjectSetInteger (chart_ID,name, OBJPROP_XSIZE ,width);
ObjectSetInteger (chart_ID,name, OBJPROP_YSIZE ,height);
//--- установим цвет фона
ObjectSetInteger (chart_ID,name, OBJPROP_BGCOLOR ,back_clr);
//--- установим тип границы
ObjectSetInteger (chart_ID,name, OBJPROP_BORDER_TYPE ,border);
//--- установим угол графика, относительно которого будут определяться координаты точки
ObjectSetInteger (chart_ID,name, OBJPROP_CORNER ,corner);
//--- установим цвет плоской рамки (в режиме Flat)
ObjectSetInteger (chart_ID,name, OBJPROP_COLOR ,clr);
//--- установим стиль линии плоской рамки
ObjectSetInteger (chart_ID,name, OBJPROP_STYLE ,style);
//--- установим толщину плоской границы
ObjectSetInteger (chart_ID,name, OBJPROP_WIDTH ,line_width);
//--- отобразим на переднем (false) или заднем (true) плане
ObjectSetInteger (chart_ID,name, OBJPROP_BACK ,back);
//--- включим (true) или отключим (false) режим перемещения метки мышью
ObjectSetInteger (chart_ID,name, OBJPROP_SELECTABLE ,selection);
ObjectSetInteger (chart_ID,name, OBJPROP_SELECTED ,selection);
//--- скроем (true) или отобразим (false) имя графического объекта в списке объектов
ObjectSetInteger (chart_ID,name, OBJPROP_HIDDEN ,hidden);
//--- установим приоритет на получение события нажатия мыши на графике
ObjectSetInteger (chart_ID,name, OBJPROP_ZORDER ,z_order);
//--- успешное выполнение
return ( true );
}
//+------------------------------------------------------------------+
//| Создает текстовую метку |
//+------------------------------------------------------------------+
bool LabelCreate( const long chart_ID= 0 , // ID графика
const string name= "Label" , // имя метки
const int sub_window= 0 , // номер подокна
const int x= 0 , // координата по оси X
const int y= 0 , // координата по оси Y
const string text= "Label" , // текст
const color clr= clrRed , // цвет
const string font= "Arial" , // шрифт
const int font_size= 10 , // размер шрифта
const double angle= 0.0 , // наклон текста
const ENUM_BASE_CORNER corner= CORNER_LEFT_UPPER , // угол графика для привязки
const ENUM_ANCHOR_POINT anchor= ANCHOR_LEFT_UPPER , // способ привязки
const bool back= false , // на заднем плане
const bool selection= false , // выделить для перемещений
const bool hidden= true , // скрыт в списке объектов
const long z_order= 0 ) // приоритет на нажатие мышью
{
//--- сбросим значение ошибки
ResetLastError ();
//--- создадим текстовую метку
if ( ObjectFind (chart_ID,name)!=sub_window)
{
if (! ObjectCreate (chart_ID,name, OBJ_LABEL ,sub_window, 0 , 0 ))
{
Print ( __FUNCTION__ ,
": не удалось создать текстовую метку! Код ошибки = " , GetLastError ());
return ( false );
}
}
//--- установим координаты метки
ObjectSetInteger (chart_ID,name, OBJPROP_XDISTANCE ,x);
ObjectSetInteger (chart_ID,name, OBJPROP_YDISTANCE ,y);
//--- установим угол графика, относительно которого будут определяться координаты точки
ObjectSetInteger (chart_ID,name, OBJPROP_CORNER ,corner);
//--- установим текст
ObjectSetString (chart_ID,name, OBJPROP_TEXT ,text);
//--- установим шрифт текста
ObjectSetString (chart_ID,name, OBJPROP_FONT ,font);
//--- установим размер шрифта
ObjectSetInteger (chart_ID,name, OBJPROP_FONTSIZE ,font_size);
//--- установим угол наклона текста
ObjectSetDouble (chart_ID,name, OBJPROP_ANGLE ,angle);
//--- установим способ привязки
ObjectSetInteger (chart_ID,name, OBJPROP_ANCHOR ,anchor);
//--- установим цвет
ObjectSetInteger (chart_ID,name, OBJPROP_COLOR ,clr);
//--- отобразим на переднем (false) или заднем (true) плане
ObjectSetInteger (chart_ID,name, OBJPROP_BACK ,back);
//--- включим (true) или отключим (false) режим перемещения метки мышью
ObjectSetInteger (chart_ID,name, OBJPROP_SELECTABLE ,selection);
ObjectSetInteger (chart_ID,name, OBJPROP_SELECTED ,selection);
//--- скроем (true) или отобразим (false) имя графического объекта в списке объектов
ObjectSetInteger (chart_ID,name, OBJPROP_HIDDEN ,hidden);
//--- установим приоритет на получение события нажатия мыши на графике
ObjectSetInteger (chart_ID,name, OBJPROP_ZORDER ,z_order);
//--- успешное выполнение
return ( true );
}
//+------------------------------------------------------------------+
//| Изменяет текст объекта |
//+------------------------------------------------------------------+
bool LabelTextChange( const long chart_ID= 0 , // ID графика
const string name= "Label" , // имя объекта
const string text= "Text" ) // текст
{
//--- сбросим значение ошибки
ResetLastError ();
//--- изменим текст объекта
if (! ObjectSetString (chart_ID,name, OBJPROP_TEXT ,text))
{
Print ( __FUNCTION__ ,
": не удалось изменить текст! Код ошибки = " , GetLastError ());
return ( false );
}
//--- успешное выполнение
return ( true );
}
//+------------------------------------------------------------------+
//| Удаляет текстовую метку |
//+------------------------------------------------------------------+
bool LabelDelete( const long chart_ID= 0 , // ID графика
const string name= "Label" ) // имя метки
{
//--- сбросим значение ошибки
ResetLastError ();
//--- удалим метку
if (! ObjectDelete (chart_ID,name))
{
Print ( __FUNCTION__ ,
": не удалось удалить текстовую метку! Код ошибки = " , GetLastError ());
return ( false );
}
//--- успешное выполнение
return ( true );
}
//+------------------------------------------------------------------+
//| Удаляет прямоугольную метку |
//+------------------------------------------------------------------+
bool RectLabelDelete( const long chart_ID= 0 , // ID графика
const string name= "RectLabel" ) // имя метки
{
//--- сбросим значение ошибки
ResetLastError ();
//--- удалим метку
if (! ObjectDelete (chart_ID,name))
{
Print ( __FUNCTION__ ,
": не удалось удалить прямоугольную метку! Код ошибки = " , GetLastError ());
return ( false );
}
//--- успешное выполнение
return ( true );
}
//+------------------------------------------------------------------+
color ColorValue( double value)
{
if (value> 0 ) return (ColorPlus);
if (value< 0 ) return (ColorMinus);
return (ColorZero);
}
//+------------------------------------------------------------------+
....
Fiz algum trabalho no seu painel de instrumentos. Tenho este código, o erro de divisão por zero foi eliminado.
//| test_panel.mq4 |
//| Sergey Gritsay |
//| https://www.mql5.com/ru/users/sergey1294 |
//+------------------------------------------------------------------+
#property copyright "Sergey Gritsay"
#property link "https://www.mql5.com/ru/users/sergey1294"
#property version "1.00"
#property strict
....
Bem, é na forma de EA, e muito provavelmente você precisa de um indicador, porque depois de instalar esta EA, você não pode mais instalar uma EA e você tem que escolher, ou instalar uma EA comercial, ou um painel EA =)
Bem, isto é na forma de uma EA, e você provavelmente precisará de um indicador, porque depois de instalar esta EA, não será mais possível instalar uma EA, e você terá que escolher, seja para instalar uma EA comercial ou um painel EA =)
Não é muito difícil copiar este código em um indicador. Não havia nenhuma indicação na pergunta de que ele estava escrevendo o indicador.
No testador de estratégia, vá para a aba "Otimização" -
É aqui que serão exibidos os resultados da otimização.