Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 1043

 
nikelodeon:

I will describe it well in more detail.

The main indicator is located on the euro-dollar pair. This indicator calls indicators from other pairs of gold, dollar index, and euro currency. This indicator works on 1-minute pairs and sometimes there is no quotes on the dollar index, for example, the euro has a 15-minute candlestick, but the dollar index does not have such a candlestick, the index is frozen and does not tick. Then, after some time, the 16-minute candlestick appears on the EUR and the 16-minute candlestick appears on the USD index. What is the question? How to synchronise the calculation of the indicator, so it is only counted when the bars on all called symbols coincide in time????

I tried this construction

It seems to be cool, but the calculation is performed only for the current day, there are no signals for the previous days. Maybe there is a standard solution for synchronization of symbols????

Try in a timer in the loop SymbolInfoTick() to get data on the symbols. And there already synchronize as you need.

The thing is, that on the current symbol, the program starts only with the arrival of the tick for this symbol. Therefore, you will not be able to get the ticks from the other symbols in time. But in a timer that runs independently of the ticks, you will be able to get ticks from other symbols.

The timer can be set to millisecond if you need a fast response to a tick on a symbol that is not your own.

 
artmedia70:
And you have a terribly blurred question and only you can understand it.

HAIL TO YOU!!! THANK YOU! HAPPY HOLIDAYS!

2 more points, dear. 1) you can remove the indicator from a separate window?

2)add a function, if the current ATR is higher than the ATR (for H period), then the ATR above the bar, would it be highlighted in a different colour? or the value would be written only above this bar?

 
kocunyc89:

HAIL TO YOU!!! THANK YOU! HAPPY HOLIDAYS!

2 more points, dear. 1) Can you remove the indicator from a separate window?

2)add a function, if current ATR is more than ATR (for H period), then ATR above the bar would be highlighted in a different colour? or the value would be written only above this bar?

Oh, dear... Here, edit it yourself:

//+------------------------------------------------------------------+
//|                                                 iATRwithData.mq4 |
//|              Copyright 2016, Artem A. Trishkin, Skype artmedia70 |
//|                       https://login.mql5.com/ru/users/artmedia70 |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016, Artem A. Trishkin, Skype artmedia70"
#property link      "https://login.mql5.com/ru/users/artmedia70"
#property version   "1.00"
#property strict
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_plots   1
//--- plot ATR
#property  indicator_label1  "ATR"
#property  indicator_type1   DRAW_LINE
#property  indicator_color1  clrDodgerBlue
#property  indicator_style1  STYLE_SOLID
#property  indicator_width1  1
//+------------------------------------------------------------------+
//| enums                                                          |
//+------------------------------------------------------------------+
enum enumYN
  {
   enYes=1, // Yes
   enNo=0,  // No
  };
//+------------------------------------------------------------------+
//| input parameters                                                 |
//+------------------------------------------------------------------+
input int      PeriodATR=14;           // ATRs calculation period
int periodATR=(PeriodATR<1)?1:PeriodATR;
sinput enumYN DrawGraphic=enYes;       // Drawing ATR data over the candles
sinput int StartDrawingBar=100;        // Max bar for drawing ATRs data
int startDrawingBar;
sinput int TextSize=5;                 // Text size
sinput color TextColor=clrDodgerBlue;  // Text color
//--- indicator buffers
double         BufferATR[];
string Prefix;
//+------------------------------------------------------------------+
//| Classes                                                          |
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0,BufferATR);
   
   Prefix="iATRwd("+IntegerToString(periodATR)+")";
   IndicatorSetString(INDICATOR_SHORTNAME,Prefix);
   int bars=Bars(Symbol(),Period());
   startDrawingBar=(StartDrawingBar<1)?1:(StartDrawingBar>bars)?bars:StartDrawingBar;
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//--- delete graphics
   ObjectsDeleteAll(0,Prefix,0);
//---
  }
//+------------------------------------------------------------------+
//| 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[])
  {
//---
   if(rates_total<periodATR) return(0);
   int limit=rates_total-prev_calculated;
   if(limit>1) limit=rates_total-periodATR-1;
   //---
   for(int i=limit; i>=0; i--) {
      BufferATR[i]=iATR(Symbol(),Period(),periodATR,i);
      if(DrawGraphic && i<startDrawingBar) {
         string tm_txt=TimeToString(time[i],TIME_DATE|TIME_MINUTES);
         string nm=Prefix+"_"+tm_txt;
         string text=IntegerToString(int(BufferATR[i]/Point()));
         string tooltip="ATRs period for candle on "+tm_txt+" is "+text;
         SetArrowText(0,nm,TextColor,text,0,ANCHOR_LOWER,time[i],high[i],"Arial",TextSize,tooltip);
         }
      }
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
//| Timer function                                                   |
//+------------------------------------------------------------------+
void OnTimer()
  {
//---
   
  }
//+------------------------------------------------------------------+
//| ChartEvent function                                              |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Functions                                                        |
//+------------------------------------------------------------------+
void SetArrowText(long chart_id, string name, color text_color, string text, int sub_window, 
                  long text_anchor, long text_time1, double text_price1, string font="Arial", long font_size=5, 
                  string tooltip="\n", bool selection=false, bool hidden=true) {
   
   if(ObjectFind(chart_id,name)<0) ObjectCreate(chart_id,name,OBJ_TEXT,sub_window,text_time1,text_price1);
   ObjectSetInteger(chart_id,name,OBJPROP_ANCHOR,text_anchor);
   ObjectSetInteger(chart_id,name,OBJPROP_WIDTH,font_size);
   ObjectSetString(chart_id,name,OBJPROP_FONT,font);
   ObjectSetString(chart_id,name,OBJPROP_TEXT,text);
   ObjectSetInteger(chart_id,name,OBJPROP_COLOR,text_color);
   ObjectSetInteger(chart_id,name,OBJPROP_FONTSIZE,font_size);
   ObjectSetInteger(chart_id,name,OBJPROP_TIME1,text_time1);
   ObjectSetDouble(chart_id,name,OBJPROP_PRICE1,text_price1);
   ObjectSetInteger(chart_id,name,OBJPROP_SELECTED,selection);
   ObjectSetInteger(chart_id,name,OBJPROP_SELECTABLE,selection);
   ObjectSetInteger(chart_id,name,OBJPROP_HIDDEN,hidden);
   ObjectSetString(chart_id,name,OBJPROP_TOOLTIP,tooltip);
}
//+------------------------------------------------------------------+

Or do you want me to do everything for you as well?

 
artmedia70:

Oh, dear... Here, you do it yourself:

Or should I do it for you too?

Thank you very much! Good man!
 
kocunyc89:
Thank you very much! kind man!
You are welcome.
 
Good evening, is it possible to make the indicator display buffer data in two windows, part on the main chart and part in the sub-end? If so, please advise how ...
 
artmedia70:

You're welcome. If it's no secret, why do you need a timestamp showing the time of the last run of your program - the time in it won't change.

Just idle curiosity...

It's for the offline tick chart.



 
Hello.

What functions can be used to send variables between two MT4 terminals? If possible, please add a link to the documentation.
 
abeiks What functions are available for sending variables between two MT4 terminals?

int Flags=FILE_WRITE+FILE_TXT+FILE_COMMON;

int Info = FileOpen(fName,Flags);

FileWrite(Info,What's Up); On the other terminal, read. Cursor on FileOpen and F1 - get help

 
LRA:

int Flags=FILE_WRITE+FILE_TXT+FILE_COMMON;

int Info = FileOpen(fName,Flags);

FileWrite(Info,What's Up); On the other terminal, read. Cursor on FileOpen and F1 - get help

Thanks, I will have a look!
Reason: