Comment(x_check+ " , "+y_check);
Comment() to check what the coords data are.
They should change when label goes right, but they don't.
IOW, coords are what they should be.
Label disappears to the right.
Coord are XDISTANCE = 225; YDISTANCE = 27; CORNER = 3;
First, loading the indi on the chart, label in place:
Second, closing MT4 and restarting it, label goes right:
Third, after shifting Tf's, label jumps back:
It's something to do with the Anchors related to Corner calculations and must be a bug in B646.
Thanks, I had the same issue with the objects not being deleted on deinit.
I was developing some indi, and got these strange results, then I saw on the objects list, they were still there.
I got around that, probably in the simplest way, by ObjectDelete() in the start().
Yup, changing init() to OnInit() and deinit() to OnDeinit() got the labels back right! Thanks!
Then after a while, it didn't!!! They are still doing the same dance.
You're welcome, Dadas. I wouldn't use ObjectDelete() in the start method, though. That's best done in OnDeInit(). The reason for that is this: if you put the code in OnStart() or OnCalculate() it's going to be executed every time a tick comes. That's bad for two reasons: 1) it adds a lot of operations using up time that you can't afford to waste in a real-time application and 2) it doesn't make sense to do that in most situations - usually it's only going to matter when a chart is de-initialized. You should only do it in the "startup" methods if a price change will affect your objects in some way. As an example, consider this(which is part of an app that I intend to sell, but sharing this is cool :-) ).
// If no trade is progress, there is no Position Value to display
if (ObjectFind("PositionValue") > 0)
if (ObjectFind("PipsProfitLoss") > 0)
if (ObjectFind("CurrentStop") > 0)
if (ObjectFind("PipsLockedIn") > 0)
if (ObjectFind("ProfitLockedIn") > 0)
This code catches objects that have been left over from a closed trade if they exist.
By the way - do NOT do this:
string AcctCurrency = AccountCurrency();
if (AcctCurrency == "")
You've misunderstood the intent of the code. It's designed to NOT run the indie until the server has "settled down". That's why I return 0. That way the indie code won't execute until all the info it needs is available. I honestly haven't worked with OnCalculate() yet because I haven't needed to but I can say that what you're doing is an invitation to disaster. You aren't telling your program, "Don't run this code until you have valid data." You're just casting stuff to the wind and hoping for the best. To tell you the truth, I don't know what your code would do if it wasn't getting dependable info from the server. After a considerable amount of reading, their new OnCalculate() method makes no sense to me. it looks to me like it's unnecessarily calculating and handing a load information that you would do for yourself if you needed to and saving yourself the computing time by not bothering with what you don't need. I'm not sure what they're trying to accomplish with this.
I have found the answer to the floating labels.
Looks like now we must Bind the Object Anchor in the code itself:
So, I must add smth like the following:
and then use another line to set the object:
Life is definetily not getting easier!
And then this doesn't help, after all!!!
BTW. I'll tell you what they are trying to accomplish:
They want to stop as many people as possible from messing around with codes.
It has to be as commercial as possible.
Until recently, almost anybody was able to mess around with simple mql4.
Now, the goal is to commercialize everything!
their new OnCalculate() method makes no sense to me. it looks to me like it's unnecessarily calculating and handing a load information that you would do for yourself if you needed to and saving yourself the computing time by not bothering with what you don't need. I'm not sure what they're trying to accomplish with this.
OnCalculate provides the result of calculating how many bars have already been processed by the indicator. It replaces old IndicatorCounted function. It also achieves compatability with mql5 because the series arrays are passed to it by reference, vs the old mql4 way of using the global series arrays. From a coding point of view there is very little difference.
Once again, you're welcome, Dadas. I had forgotten about using the ANCHOR properties even though I make use of it in some of my stuff.
SDC, thanks for the info. The documentation doesn't really clarify its purpose. I suspect the meaning may have gotten lost in the translation from Russian to English. Now it makes more sense. I assume that it isn't meant to be used in place of OnStart() but instead used in place of IndicatorCounted(). It would be a good addition to the documentation to provide an example that shows a sort of "before" and "after" demonstrating the replacement of IndicatorCounted() with OnCalculate(). I'll have to go back and review the documentation in light of your explanation and see how the pieces come together. Thanks again.
You use int OnCalculate() in place of int start(). It runs on every tick like start(). A before and after would look something like this,
int i=0, limit=0;
//---- check for possible errors
if(counted_bars < 0) return(-1);
limit = Bars-counted_bars-1;
for (i = limit; i >= 0; i--)
//---- indicator calculations
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time,
const double &open,
const double &high,
const double &low,
const double &close,
const long& tick_volume,
const long& volume,
const int& spread)
int i=0, limit=0;
//--- check for possible errors
if(prev_calculated < 0) return(-1);
limit = rates_total-prev_calculated;
for(i = limit; i >= 0; i--)
//--- indicator calculations
OnCalculate's formal parameters make it more self contained, the coder doesn't have to rely on calling all kinds of globals which apparently in oop circles is bad bad coder, slap on wrist. In practice there really is not much difference between using either of them. Also OnCalculate is the same as mql5 so you have the option to write compatabie code.