Other News

How to find the length of the candle body


Q:

I want to get the length of the candle body. I wanted to take the difference between the open and close. Can that be done and how?

 

A:

Yes, it can be done.

 

Drag and drop a Variable Element  from the New Elements toolbox pane onto the Drawing pad. Click the (+) to configure it:


 

 

Set the of data type to double, and perhaps give it a nice name, like CandleBody

 


 

 

 Click the Assignment tab and enter: High[0] – Low[0]

 


 

 Three points:

(1)

The brackets [] get the value for the “candle shift”, for any of the 4 values (High, low, Open, Close) where 0 is the current candle. There is more info about shift here:


 

(2)

You should put logic in front of this to detect if the High value is greater or less than the Low value

 

(3)

Always click the Build button after you have edited the Assignment tab to see if you have accidently injected any syntax errors.

 


 

 

Finally, I am going to add a function to the Toolbox to make this easier. Look for it in the next release (4.0.0.77) under the “Bar” menu.

 

 

 


 

RAQ

Custom Indicator that output dots and crosses

Q: My indicator outputs round dots and crosses. Where can I find a solution to implement this indicator?

A: These kinds of things written onto a MetaTrader chart are called “objects”.  MT defines many object types such as thumbs, arrows, dots, etc.

The best way to work with these kinds of indicators is to use the functions “fnGetObjectByType” or “fnGetObjectByName”. These are found in the Functions toolbox under the “Chart Objects” menu. (They are part of the Chart Object Plug-in)

Create a simple EA that uses these functions and writes the values to the chart (use the Message tab) to see how and when the custom indicator writes the objects. Once you understand that, you can use the info within the logic of your EA for opening/closing trades. 

Video

Here is a link to a video showing how to configure a simple MT custom indicator. It’s an older version of VTS, but the configuration is exactly the same.

RAQ