How to plot existing file under the main price window

 

Hi! I have some COT data that I want to plot under the main price window as an indicator. The COT data are external data, i.e. independent of the prices. So one can not write it like a traditional indicator calculated from the prices. Since I have all the data needed, I don't need to do any calculation. I only need to convert the date and time so that it aligns with the price chart. I will figure out how to do it later. Now, if we ignore the alignment, what I want to ask is how could I plot the data under the price chart? Thanks!  

 
Not later, now. Take the time, get the shift (iBarShift.) Put the value in the correct buffer shift. What's the problem?
 
whroeder1:
Not later, now. Take the time, get the shift (iBarShift.) Put the value in the correct buffer shift. What's the problem?

No, I think you misunderstood. I mean I don't even know how to finish the first step: to plot my external data under the chart. 

I need to know how to plot the data under the chart first, and then see if there is any misalignment. If there is, of course I will try iBarShift, but before that, could you tell me (if you know), how to plot my data under the chart? I could not find any plot option in MT4. Thanks in advance!


Of course, I could export the prices to excel and plot every thing using excel or matlab, but it seems easier if I could do it directly in MT4.
 
fyang8: I could not find any plot option in MT4.
  1. Perhaps you should read the manual. Program Properties (#property)
  2. Or you could have looked in the CodeBase for any indicator that creates a subwindow.
 
whroeder1:
  1. Perhaps you should read the manual. Program Properties (#property)
  2. Or you could have looked in the CodeBase for any indicator that creates a subwindow.

Thanks! The examples in Program Properties (#property) don't seem to be very clear.

Do you know how to load external data when writing an indicator?

Program Properties (#property) - Preprocessor - Language Basics - MQL4 Reference
Program Properties (#property) - Preprocessor - Language Basics - MQL4 Reference
  • docs.mql4.com
Program Properties (#property) - Preprocessor - Language Basics - MQL4 Reference
 
fyang8: Do you know how to load external data when writing an indicator?
  1. You need to RTFM before posting such moronic questions or are you a troll?
  2. File Functions - MQL4 Reference

 
whroeder1:
  1. You need to RTFM before posting such moronic questions or are you a troll?
  2. File Functions - MQL4 Reference

I'm not a programmer. I couldn't understand 100% of the manual.

Let's say, for each currency pair, I have a separate excel file, named as "concise_COT_USDCAD.csv", "concise_COT_USDJPY.csv", "concise_COT_EURUSD.csv", "concise_COT_GBPUSD.csv" and so on. In each excel file, there are 5 columns, named as "Date", "net_NonComm", "net_Comm", "differential" and "diff_52_Week_Percentile". In MT4, under the chart window, I want to make 2 more separate windows, the first one for the plot of "net_NonComm", "net_Comm" and "differential" and the second one for the plot of "diff_52_Week_Percentile". How should I do it?

 
fyang8: I'm not a programmer. I couldn't understand 100% of the manual.
Then there is no common language for us to communicate. You have only three choices: Search for it, learn to code it, or pay (Freelance) someone to code it. We're not going to code it for you (although it could happen if you are lucky or the problem is interesting.) We are willing to help you when you post your attempt (using SRC) and the nature of your problem.
 
whroeder1:

Then there is no common language for us to communicate. You have only three choices: Search for it, learn to code it, or pay (Freelance) someone to code it. We're not going to code it for you (although it could happen if you are lucky or the problem is interesting.) We are willing to help you when you post your attempt (using SRC) and the nature of your problem.
I guess you don't know either. You come here to help people. I don't see a reason why you should hide the answers. That's why I guess you don't know either. It's a simple question. If you know the answer, you could explain it in a simple way to a non-professional programmer. (I do use Matlab a lot in my work. So I'm not that bad at C based languages either.) Just a problem about the loading of data. Give me a simple example how you load data from a .csv file, and how the .csv file should look like. I don't know why there is not such a example in the manual. All you suggested did not point to such examples either.
 

The answers to your questions, while they may appear simple, are actually detailed and lengthy.

It is unlikely that a contributor will have the time to formulate a single post to take you through it all step-by-step.

I'll give you the nuts and bolts:

First, you need to learn the file functions (as linked above by whroeder1).

You'll open the csv file and read the contents. There are examples in the help files about doing this.

You then need to get an understanding of how custom indicators are written. The best way to do this is probably take a look at the code of some of the default indicators included with the platform. A good starting point would be to forget about reading from the csv file and just create an indicator that plots a line in a subwindow with some value assigned to it (like volume). Once you can do that, you can move on to working with the data from the csv file.

Essentially, your indicator will need to loop through all the bars on the chart and assign the value you read from your csv file to the appropriate index of your new indicator's buffer. The way you align the data from your csv file to the correct bar index is by using the function iBarShift().

You also need to remember to close the file when you're done with it.

I will say this is probably not the best "beginners project", so it may take you some time to sort out; it is possibly not a weekend job for a beginner in MQL...

Here is some sample code that would be useful: https://docs.mql4.com/files/filereaddatetime

Good luck!

FileReadDatetime - File Functions - MQL4 Reference
FileReadDatetime - File Functions - MQL4 Reference
  • docs.mql4.com
FileReadDatetime - File Functions - MQL4 Reference
Reason: