What I am trying to do is this... Run one indicator on a chart X ... and scan through stocks b,c,d,e,...etc
Now the problem is this... when a new candle opens on chart X ... a new tick may not have arrived on chart a,b or c... which means even though iTime() of chart X shows the latest results, the iTime() of chart b does not show the latest result. And so it prints the old results.
What i want is this.... at the start of a new bar on each of b,c,d,e ..etc it should to print those values that I am looking for. for example rsi or open or close of that bar.
So if the opening tick is a few seconds delayed on stock b,c,d,e...etc it must print the values only once the new tick arrives.
in the meanwhile for all the other stocks where the tick has arrived , it must print it out.
When I run this code here are the print values...
Now the problem is this... when a new candle opens on chart X ... a new tick may not have arrived on chart a,b or c... which means even though iTime() of chart X shows the latest results, the iTime() of chart b does not show the latest result. And so it prints the old results.
What i want is this.... at the start of a new bar on each of b,c,d,e ..etc it should to print those values that I am looking for. for example rsi or open or close of that bar.
So if the opening tick is a few seconds delayed on stock b,c,d,e...etc it must print the values only once the new tick arrives.
in the meanwhile for all the other stocks where the tick has arrived , it must print it out.
Inserted Code
//+------------------------------------------------------------------+ //| ProjectName | //| Copyright 2018, CompanyName | //| http://www.companyname.net | //+------------------------------------------------------------------+ #property copyright "" #property link "" #property indicator_chart_window #property indicator_buffers 2 #property indicator_color1 DarkGreen #property indicator_color2 Red //---- buffers string Pairs[2] = {"ASIANPAINT#", "SBIN#",}; int period = 1; // one minute //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { Comment("Running"); //---- if(IsthisANewCandle()) { string ct = TimeToStr(iTime(Symbol(),period,0)+1800, TIME_SECONDS); for(int j=0; j<=1; j++) { string oo = TimeToStr(iTime(Pairs[j],period,0)+1800,TIME_SECONDS); int handle=FileOpen("print.csv", FILE_CSV|FILE_WRITE|FILE_READ, '\t'); if(handle>0) { FileSeek(handle, 0, SEEK_END); FileWrite(handle, "The opening time of the Mother Script Chart is", ct,"\n", // Mother Script Chart is the chart where the indicator is running "Child Chart is", Pairs[j],"\n", // Child Chart are the list of stocks in Array listed at the beginning "Open time of the child chart is",oo," \n" "------------------"); FileClose(handle); } } } //---- return(0); } //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ bool IsthisANewCandle() { static int BarsOnChart = 0; if(Bars == BarsOnChart) return(false); BarsOnChart = Bars; return(true); } //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ bool NewBar() { static datetime lastbar; datetime curbar = Time[0]; if(lastbar!=curbar) { lastbar=curbar; return (true); } else { return(false); } } //+------------------------------------------------------------------+ //+------------------------------------------------------------------+
When I run this code here are the print values...
Inserted Code
The opening time of the Mother Script Chart is 11:36:00 Child Chart is ASIANPAINT# Open time of the child chart is 11:36:00 ------------------ The opening time of the Mother Script Chart is 11:36:00 Child Chart is SBIN# Open time of the child chart is 11:35:00 ------------------ The opening time of the Mother Script Chart is 11:37:00 Child Chart is ASIANPAINT# Open time of the child chart is 11:36:00 ------------------ The opening time of the Mother Script Chart is 11:37:00 Child Chart is SBIN# Open time of the child chart is 11:37:00 ------------------ The opening time of the Mother Script Chart is 11:38:00 Child Chart is ASIANPAINT# Open time of the child chart is 11:37:00 ------------------ The opening time of the Mother Script Chart is 11:38:00 Child Chart is SBIN# Open time of the child chart is 11:38:00 ------------------ The opening time of the Mother Script Chart is 11:39:00 Child Chart is ASIANPAINT# Open time of the child chart is 11:38:00 ------------------ The opening time of the Mother Script Chart is 11:39:00 Child Chart is SBIN# Open time of the child chart is 11:38:00 ------------------ The opening time of the Mother Script Chart is 11:40:00 Child Chart is ASIANPAINT# Open time of the child chart is 11:39:00 ------------------ The opening time of the Mother Script Chart is 11:40:00 Child Chart is SBIN# Open time of the child chart is 11:40:00 ------------------ The opening time of the Mother Script Chart is 11:41:00 Child Chart is ASIANPAINT# Open time of the child chart is 11:40:00 ------------------ The opening time of the Mother Script Chart is 11:41:00 Child Chart is SBIN# Open time of the child chart is 11:40:00 ------------------ The opening time of the Mother Script Chart is 11:42:00 Child Chart is ASIANPAINT# Open time of the child chart is 11:41:00 ------------------ The opening time of the Mother Script Chart is 11:42:00 Child Chart is SBIN# Open time of the child chart is 11:41:00 ------------------ The opening time of the Mother Script Chart is 11:43:00 Child Chart is ASIANPAINT# Open time of the child chart is 11:42:00 ------------------ The opening time of the Mother Script Chart is 11:43:00 Child Chart is SBIN# Open time of the child chart is 11:42:00 ------------------ The opening time of the Mother Script Chart is 11:44:00 Child Chart is ASIANPAINT# Open time of the child chart is 11:43:00 ------------------ The opening time of the Mother Script Chart is 11:44:00 Child Chart is SBIN# Open time of the child chart is 11:43:00 ------------------ The opening time of the Mother Script Chart is 11:45:00 Child Chart is ASIANPAINT# Open time of the child chart is 11:44:00 ------------------ The opening time of the Mother Script Chart is 11:45:00 Child Chart is SBIN# Open time of the child chart is 11:44:00 ------------------ The opening time of the Mother Script Chart is 11:46:00 Child Chart is ASIANPAINT# Open time of the child chart is 11:45:00 ------------------ The opening time of the Mother Script Chart is 11:46:00 Child Chart is SBIN# Open time of the child chart is 11:45:00 ------------------ The opening time of the Mother Script Chart is 11:47:00 Child Chart is ASIANPAINT# Open time of the child chart is 11:46:00 ------------------ The opening time of the Mother Script Chart is 11:47:00 Child Chart is SBIN# Open time of the child chart is 11:47:00 ------------------ The opening time of the Mother Script Chart is 11:48:00 Child Chart is ASIANPAINT# Open time of the child chart is 11:47:00 ------------------ The opening time of the Mother Script Chart is 11:48:00 Child Chart is SBIN# Open time of the child chart is 11:47:00 ------------------ The opening time of the Mother Script Chart is 11:49:00 Child Chart is ASIANPAINT# Open time of the child chart is 11:48:00 ------------------ The opening time of the Mother Script Chart is 11:49:00 Child Chart is SBIN# Open time of the child chart is 11:48:00 ------------------ The opening time of the Mother Script Chart is 11:50:00 Child Chart is ASIANPAINT# Open time of the child chart is 11:49:00 ------------------ The opening time of the Mother Script Chart is 11:50:00 Child Chart is SBIN# Open time of the child chart is 11:49:00 ------------------ The opening time of the Mother Script Chart is 11:51:00 Child Chart is ASIANPAINT# Open time of the child chart is 11:50:00 ------------------ The opening time of the Mother Script Chart is 11:51:00 Child Chart is SBIN# Open time of the child chart is 11:50:00 ------------------ The opening time of the Mother Script Chart is 11:52:00 Child Chart is ASIANPAINT# Open time of the child chart is 11:51:00 ------------------ The opening time of the Mother Script Chart is 11:52:00 Child Chart is SBIN# Open time of the child chart is 11:52:00 ------------------ The opening time of the Mother Script Chart is 11:53:00 Child Chart is ASIANPAINT# Open time of the child chart is 11:52:00 ------------------ The opening time of the Mother Script Chart is 11:53:00 Child Chart is SBIN# Open time of the child chart is 11:53:00 ------------------ The opening time of the Mother Script Chart is 11:54:00 Child Chart is ASIANPAINT# Open time of the child chart is 11:54:00 ------------------ The opening time of the Mother Script Chart is 11:54:00 Child Chart is SBIN# Open time of the child chart is 11:54:00 ------------------ The opening time of the Mother Script Chart is 11:55:00 Child Chart is ASIANPAINT# Open time of the child chart is 11:55:00 ------------------ The opening time of the Mother Script Chart is 11:55:00 Child Chart is SBIN# Open time of the child chart is 11:55:00 ------------------ The opening time of the Mother Script Chart is 11:56:00 Child Chart is ASIANPAINT# Open time of the child chart is 11:56:00 ------------------ The opening time of the Mother Script Chart is 11:56:00 Child Chart is SBIN# Open time of the child chart is 11:55:00 ------------------ The opening time of the Mother Script Chart is 11:57:00 Child Chart is ASIANPAINT# Open time of the child chart is 11:56:00 ------------------ The opening time of the Mother Script Chart is 11:57:00 Child Chart is SBIN# Open time of the child chart is 11:57:00 ------------------