bool Deinitialized;
int Chart_Scale,Bar_Width;
int init() {
Deinitialized = false;
//Determine the current chart scale (chart scale number should be 0-5)
Chart_Scale = ChartScaleGet();
//Set bar widths
if(Chart_Scale == 0) {Bar_Width = 1;}
else {if(Chart_Scale == 1) {Bar_Width = 2;}
else {if(Chart_Scale == 2) {Bar_Width = 2;}
else {if(Chart_Scale == 3) {Bar_Width = 3;}
else {if(Chart_Scale == 4) {Bar_Width = 6;}
else {Bar_Width = 13;} }}}}
SetIndexStyle(0, DRAW_HISTOGRAM,0,Bar_Width);
return(0);
}
//+-------------------------------------------------------------------------------------------+
//| Subroutine: Set up to get the chart scale number |
//+-------------------------------------------------------------------------------------------+
void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam)
{
Chart_Scale = ChartScaleGet();
init();
}
//+-------------------------------------------------------------------------------------------+
//| Subroutine: Get the chart scale number |
//+-------------------------------------------------------------------------------------------+
int ChartScaleGet()
{
long result = -1;
ChartGetInteger(0,CHART_SCALE,0,result);
return((int)result);
}
//+-------------------------------------------------------------------------------------------+
//|Custom indicator end |
//+-------------------------------------------------------------------------------------------+
void SendTick() {
int message = RegisterWindowMessageW("MetaTrader4_Internal_Message");
int hwd = WindowHandle(Symbol(), Period());
PostMessageW(hwd, message, 2, 1);
}
extern string Suffix=":)";
int OnInit()
{
if(StringFind(AccountInfoString(ACCOUNT_COMPANY),"TW",0) >= 0 && StringFind(Symbol(),"i",0) >= 0) { Suffix = "i" ; } else
if(StringFind(AccountInfoString(ACCOUNT_COMPANY),"Gain",0) >= 0) { Suffix = "pro" ; }
return(0);
}
extern double Percent = 50;//процент закрытия ордера
double LotClose;
LotClose = OrderLots()*Percent/100;
if (OrderType()==OP_BUY ) OrderClose (OrderTicket(),LotClose,MarketInfo(OrderSymbol(),MODE_BID),slippage);
//--------------------------------------------------------------------------------------------//
//рисование уровня % до "Margin Call"
//---------------------------------------------------------------------------------------------//
int shift_p;
shift_p = Ld_24 - Ld_24*Procent/100;
ObjectDelete("ZeroLevel3");
ObjectCreate("ZeroLevel3", OBJ_HLINE, 0, 0, Bid - shift_p*Point);
ObjectSet("ZeroLevel3", OBJPROP_COLOR, Colour_ZM);
ObjectSet("ZeroLevel3", OBJPROP_STYLE, Style_ZM);
ObjectSet("ZeroLevel3", OBJPROP_WIDTH, Width_ZM);
//----
extern int History = 100; //максимальное количество баров для расчета индикатора (-1 - все бары)
//----
int MAX;
//------------------------------
int i;
int CountedBars=IndicatorCounted();
if(CountedBars<0) return(-1);
if(CountedBars>0) CountedBars--;
int limit=fmin(Bars-CountedBars,Bars-2); //+MAX*10*TFK
if (History>MAX) limit=fmin(History,Bars-2); //limit+=MAX; Comment(limit);
//------
for (i=0; i<=12; i++) {
SetIndexEmptyValue(i,0.0); //--- значение 0 отображаться не будет
if (History>MAX) SetIndexDrawBegin(i,Bars-History); //--- пропуск отрисовки первых баров
if (History<=MAX) SetIndexDrawBegin(i,MAX*1); } //--- пропуск отрисовки первых баров
//+------------------------------------------------------------------+
С этим вопросом лучше в ветку: https://forexsystemsru.com/threads/vashi-voprosy-po-jazyku-mql4.65289/, так как здесь выкладываю все с чем приходится сталкиваться, чтобы не запамятовать.Вопрос, если можно. Есть ли способ реинициализировать индикатор по таймеру, напр. позвать init(), или использовать WindowRedraw() ,чтобы, так сказать, 'поставить на своё место' рисующие индикаторы .