In Part 81, we began looking at the code to detect when price action enters a graphical rectangle object. We’ll continue that discussion here.
After declaring all the necessary variables, we calculate our usual AdjPoint and FiveDig variables. It’s annoying to do this over and over in included functions, but global variables from the calling programs are not available for use in included functions. Next we set the global variables to false so we only have to deal with them when we actually find price action in or near an action rectangle.
Now we want to go through the list of objects to find Action Rectangles. As we’ve done in the past, we use the integer variable i as our counter and find the name of each object using the ObjectName() function. Once we have the name of each object, we can test for type and color.
I noticed there are no comments on my last article. I purposely put a big error in the code to see if anyone was paying attention……
And if you believe that one, I have some land in Florida to sell you real cheap…. 😉
OK. Now that the egg has been removed from my face, I’ll show you what I did wrong:
Is totally meaningless. ObjectGet() returns a color, not a boolean. But, of course, booleans, doubles, integers, colors and datetimes are all just numbers. So the code would have worked without kicking out errors, but it would never have worked right. We’re supposed to be detecting an Action Rectangle so we have to test for ObjectType() and color. The line should look like this:
if(ObjectType(name) == OBJ_RECTANGLE && ObjectGet(name,OBJPROP_COLOR) == ActionColor)
Since we connect these two items with the AND (&&), then both items must be true for the whole statement to be true and for the code enclosed by the braces following the if() statement will be executed. If they are both true, then the object we are currently testing is an Action Rectangle. Just to clarify, Action Rectangle is not an official MT4 term, that’s just what I call it. It’s a rectangle at which action will occur. I use the terminology for any graphical object at which action (trade, order, alert, etc.) should occur.
Now that we’ve got another of my numerous bugs fixed (see, even seasoned programmers make mistakes), next time we can continue our discussion of this function. Thanks for your attention and please follow me on Twitter and LinkedIn.
Latest posts by admin (see all)
- Money Management in Forex: More Than Just Trading - February 17, 2018
- Identifying Trends through Synchronization - February 17, 2018
- Using Multiple Trendlines to Identify Better Trades - February 15, 2018
Winner’s Edge Trading, as seen on: