As NT does not officially support multi timeframe indicators (not yet, but I need them) I found a rather complicated work around (programmed in ninja script) to create multi timeframe indicators and it works very well with the exception that I only can plot higher time frames on lower time frames but not lower time frames on higher timeframes (I can plot a 60min SMA for example on a 5min chart but not a 5min on a 60min).
Now I am in need to also plot some indicators from lower to higher time frame and the unique possible simple solution I can think of is to plot signals from the lower to the higher time frame instead of plotting the whole indicator.
I mean, for example, I crate a indicator based on a MA cross which does something like: if MA1 cross above MA2 plot0.set 1 ; if MA1 cross bellow MA2 plot0.set 2 else 0
and then I use a function to write this to a file.
Then I make a indicator on the 60min chart which reads the same file and according to what he reads plots a up arrow, a down arrow or nothing (something like: read file...., if output=1 up arrow, if output=2 down arrow).
THIS IS THE ROW IDEA!
HERE COMES MY PROBLEM:
I had a look at the examples of StreamReader and StreamWriter and they cannot read and write the same file at the same time (only support synchronous reading writing), so using StreamReader/StreamWriter for this will not work.
Then I searched MSDN and found that the FileStream Class supports asynchronous reading/writing, so it can be used to read a file and output whatever is appended to it in real time (at least I think so, correct me if I am wrong).
So basically I need to have in the lower timeframe indicator something like FileStream fs = new FileStream("signal.txt", FileMode.Append, FileAccess.Write, FileShare.Read); and then the command to write the number 1 or 2 to the file. And the higher timeframe should have something like FileStream fs = new FileStream("signal.txt", FileMode.Open,
FileAccess.Read); and then read what just was added to the file and compare it, if the comparison gives a true (1=1) plot something (up arrow for example).
This is again a ROW concept but I am lost in implementing it in NT.
Hope someone can help me with the implementation of this concept.
Sorry for the long post and my bad English, hope it is more or less understandable.
Thank you very much!
Comment