import os
from pathlib import Path
import time
from datetime import datetime

while True:
    source = os.path.join(os.path.dirname(os.path.realpath(__file__)), "Feedback", "Module9553", "SymbolSeries", "EURUSD__00_00_00__00_00_00__BARS_CURRENT.csv")
    if os.path.exists(source):
        try:
            with open(source, 'r') as read:
                for line in read:
                    if "M15" in line:
                        splitted = line.split(";")
                        close_price = float(splitted[5])
            
                        write = open(Path(__file__).with_name('MyExternalIndicatorSignal.txt'), 'w')
                        write.write(str(close_price))
                        write.close()
                        print("MyExternalIndicatorSignal.txt update -> ", str(close_price))
            read.close()
        except:
            pass

    time.sleep(0.1)