You are setting count to one. Once set, it will always be that — thus a straight line at the bottom.
I know, that's just so I can test that it's working. Once I can get a line plotted on a chart I'm going to add the rest of the code. I've never used MQL4 before so I'm trying to understand how buffering works and how to plot values onto charts.
I figured it out, didn't realize I had to put the buffer inside of a for loop.
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello, I have what I know is a very basic problem, but I can't seem to figure out how to use the object draw function to create a line.
As you can see below, I'm using an if statement to determine if the current price is close to the 5 minute moving average. If it is, the count variable is assigned a value of 1. I then want a separate window below the price to plot a line at either 0 or 1 to show at what points the price is close to the moving average.
When creating the new indicator, the parameters I had to enter had me choose the line type and color as well as the fact that I want the window to be separate from the chart. Unfortunately I can't seem to figure out how to actually plot it from here.
Reading the documentation I'm having trouble figuring out how to use the object draw function to do so. At first I thought just assigning the value to the TestIndicatorBuffer[0] would plot it at the current bar, but I see now that I have to use the objectdraw function. Though since I already defined the line type, color, and style at the top of the code, would it be redundant to declare those values again in the objectdraw function? If someone could give me an example of how to plot it from here I would be very appreciative.
Also, is there any suggested documentation for how to learn this? I am an amateur programmer with a little experience with C# and C++, but all of the tutorials I can find for MQL4 assume I know everything and they basically just copy and paste code and explain vaguely what each block of code does. I tried also reading the reference which shows the definition of each function but not how to put it all together.