Read / Write to/from External Files

To add comments, please log in or register
rcrill
22
rcrill  

I am designing a robot in MetaTrader 4 that will trade 7 currencies, at a time.

I want to make a B (Buy) S (Sell) or W (Wait) decision in the Current (1 of 7) currencies based on the current signals from the BSW signals in the other 6 currencies. 

The way that I set it up, each currency has a small .txt file with only one record in it, “B” or “S” or “W”.  I have written 7 functions (one for each text file) to retrieve the current value from each of the 7 text files.

Technically, I have this coded this but there are A LOT of hits to these texts files, writing and reading simultaneously.  I think that too many many read and write accesses are conflicting.

My question is, what is the best way to do something like this? 

1.       I am using .txt (are other formats faster)

2.       Can I use error trapping to test access to a text file and if it is being block continue trying until I get the value read.

Sample code?  I am a developer but only 1 year with meta trader 4 so I am learning.

3.       I am working with Void Tick (every tick).  Would a timer format be better to control access to the text files?

Any other suggestions.

 

Thank you


 

Marco vd Heijden
Moderator
12697
Marco vd Heijden  

Why are you using text files and not an array or even single variables ?

Yes a timer would be better because sometimes it takes a long time for a new tick to arrive.

rcrill
22
rcrill  

I don't know how to do this, use an array.

Is there a way to get the current candle information from external  currencies (currencies that are outside my current currency (for example retrieve the

AUDUSD candle base value (and set the value to a variable in the EURUSD EA) while the EA is operating in the EURUSD currency?

I am exporting to a text file from AUDUSD so that I can import to the EURUSD EA and set to a variable for calculations in the EURUSD EA>

Is there a way to drop the text file deal, which is not reliable enough, at this point and pull the AUDUSD market values directly from the Market.

That would change my life!


 


 


 

kypa
1079
kypa  

https://docs.mql4.com/function_indices

read this

List of MQL4 Functions - MQL4 Reference
List of MQL4 Functions - MQL4 Reference
  • docs.mql4.com
Reads from the file of the CSV type a string of one of the formats: "YYYY.MM.DD HH:MM:SS", "YYYY.MM.DD" or "HH:MM:SS" - and converts it into a datetime value
To add comments, please log in or register