Problem in script

 

Hi. I am building a script that does the following:

From a list of symbols, it opens (ChartOpen) a singular symbol in PERIOD_H4 and analizes Close[1] and makes certain calculations on Chart's max and min prices. Writes results in a file depend on calculatios. Close chart (CloseChart). When ends analyzing all symbols, close file. Then prepares a report.

The problem is:

- If there are trades opened in Explorer when script is executed, before opening the symbol from process list, the system opens the first symbol in Explorer (chart opened with black background). Then opens the process list's symbol. Arrays Open, Close, High, Low contain information from symbol in Explorer, instead of symbol in process list, but in screen is the information of symbol of process list. Example: in Explorer there is a trade opened for EURUSD. In the script process list there are 2 symbols: AUDJPY and CHFNZD. When script is fired, takes first AUDJPY. But system opens chart EURUSD, then opens AUDJPY but arrays Open, Close, High and low contain EURUSD data. Same happens with CHFNDZ symbol.

- If there are not trades opened in Explorer when script is executed, nothing happens. The script isn't executed.

Requirements:

- Analyze data from each symbol in process list.

Please, I need help.

Thanks.