Fxgeditor

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

Forex Generator Block Editor version 1.

Forex Generator Block Editor version 1.x


Copyright 2009-2016 Etasoft Inc.
Main website http://www.forexgenerator.com
Purpose ........................................................................................................ 2
Requirements ............................................................................................... 2
Limited Support............................................................................................ 2
Main Program ............................................................................................... 2
License Agreement ....................................................................................... 2
Code Library vs. FXG Block Editor................................................................. 2
Blocks .......................................................................................................... 3
Block Name Conflicts .................................................................................... 4
Parameters .................................................................................................. 4
Parameter Scopes ........................................................................................ 5
Special Parameter ~next~ ........................................................................... 5
Additional Code ............................................................................................ 6
Test And Compile ......................................................................................... 7
Examples...................................................................................................... 8
Example 1: Technical Analysis Block ............................................................ 8
Example 2: Buy Order ................................................................................ 10
General Recommendations......................................................................... 11

Etasoft Inc.

Page 1

1/7/2016

Forex Generator Block Editor version 1.x

Purpose
Forex Generator Block Editor is designed to help you create your own blocks for Forex Generator platform.
Requirements
Minimum Requirements
Software
Hardware
Permissions
Personal Requirements
Knowledge

Windows XP/Vista/Server 2003/Windows 7/8/10


Forex Generator version 6 or higher
Pentium 1.4GHz, 1Gbt RAM
Use run as Administrator if you are not an Administrator on that computer
You should have basic programming knowledge with MQL language for MT4 or MT5

Limited Support
This product is provided as free companion product for Forex Generator. Technical support for Forex Generator does not extend
to this product. You have to have programming knowledge to use this product.
MT5 compiler support is experimental. We recommend MT4 at the time of this release.
Main Program
Before you start your first building block make sure to enter compiler.

Forex Generator Block Editor version 1.x supports both MT4 and MT5 terminals. Depending on what version of the terminal you
choose you will have to use different MQ language.
If you do not setup compiler Editor will not be able to compile test code for you. Make sure you have \MQL4\Experts subfolder
under the folder where you have mql.exe. Numbers in the path between words Terminal and mql.exe will be different
depending on your broker account number.
License Agreement
In no event will Etasoft Inc. be liable for any damages whatsoever, including direct, indirect, special, consequential, incidental,
exemplary, punitive or other damages such as lost profits or revenue, business interruption, data loss, costs of replacement goods
or damages to your computer equipment arising out of or in connection with the use of, or inability to use this software or the
information contained. Please use at your own risk.
Code Library vs. FXG Block Editor
Forex Generator contains basic facility where you can create your own blocks. It is under Project->Code Library menu. Blocks
created in Code Library are not interchangeable with blocks created in FXG Block Editor. If you create block in Code Library you
can not easily edit it in FXG Block Editor and vice verse.
This is because different parameters have been used to setup building bocks in those two facilities. Code Library uses much more
simplified model to create blocks while FXG Block Editor uses full power of Generator to create blocks that look-and-feel like
native building blocks.
Etasoft Inc.

Page 2

1/7/2016

Forex Generator Block Editor version 1.x

Therefore it is best to use FXG Block Editor for any serious building block development. Code Library should be used only for
quick testing of ideas and small bits of code.

Blocks
Forex Generator groups blocks based on they functionality. Therefore it is a good idea to follow the same logic and assign your
blocks to already predefined groups. Once you open FXG Block Editor or click on New menu, press Edit->Block
Propertiesmenu.

|
This screen lets you set various block parameters. Most important of them is Block Id, Block Name and Type. Try to keep
Block Id and Block Name unique. Also do not name your blocks with the same name that is already used by built-in blocks
unless you want totally replace existing built-in block. Type allows you to assign your block to one of the existing groups in Forex
Generator.
Do not use carriage return and line feed (do not press Enter) when entering text in the Description field.
Blocks in groups "custom_utility" and custom_user are special. They can not have ~next~ in them and are used as stand-alone
(not connected by lines) pieces of code in the diagram. Therefore they have to have full body of the function because Generator
will not create function name and surrounding braces {} for it. Use "custom_utility" and custom_user groups only in special
cases.

Etasoft Inc.

Page 3

1/7/2016

Forex Generator Block Editor version 1.x

There are special groups of blocks called custom_utility and custom_user. Generator does not place function name and braces
{ } around them so when you create custom block for one of these groups make sure you have function name and { } in place.
Note that all other groups of the blocks do not need function name and { } braces around the function. See more examples in
Examples section of this document.
Block Name Conflicts
If you plan to share your blocks over the Internet make sure to pick unique names for your blocks. Keep in mind that Forex
Generator does not allow two blocks imported with the same Block Id. Even if Generator would allow this having more than one
block in the Generator toolbar with the same name would be confusing.
We recommend prefixing your block names with two or three lowercase letters in order to decrease possibility to have block name
conflicts. Example: let say you have created new better Technical Analysis block. If you call it Technical Analysis then block will
be hard to import into Generator (you would have to delete built-in Technical Analysis block first). Instead you can call it
exTechnical Analysis for extended technical analysis. Now this new block will import fine and can be reused by others.
Parameters
Main difference between custom blocks you create in Forex Generator itself and this tool is that FXG Block Editor blocks can have
defined parameters. This makes FXG Block Editor blocks look and feel like they are built-in blocks. Generator uses ~parameter~
syntax to store placeholders for parameters inside the original block code.
You can add parameters by simply using Add Parameter menu. Parameters have number of attributes:
1. Id - is unique identifier for the parameter. This is the text that Block Editor uses to find it in block source code and replace
it with value or move it to generated file scope (in case if it is external variable).
Etasoft Inc.

Page 4

1/7/2016

Forex Generator Block Editor version 1.x

2. Name is the text that user of your block will see in Forex Generator. Therefore it is important that Name would be
meaningful and clear to understand. Name can have spaces.
3. Scope defines if parameter can be exported (can become extern/input) or not. Some parameter Type like function can
not have any other Scope but verbatim because functions can not be exported. Functions only generated as verbatim
text in the output.
4. Type there are number of typical types such as bool, int, double. Also some exotic types such as function and
datetime. String type should be enclosed with double quotes in the code editor. Doublearray is a special type that is
used only in Custom Indicator MT4 mode.
5. Hidden if set to True this parameter creates hidden variable that user of the block can not access via Generator block
parameter list. It is hidden from the list and can not be changed by end user of the block. This is useful if you want to have
some way to store dynamic information between block executions. There are number of blocks that use this flag.
6. Acceptable Values is a comma separated list of values. If this parameter is not empty end user of the block will be
restricted to these choices and can only select one of the values. This is useful for number of constants such as colors,
_OrderIds, Order Types, etc. If you use this parameter make sure that next Default Value parameter has meaningful
value from this list.
7. Default Value it is recommended to always have a value in this parameter.

Once you enter new parameter it will show up in the code editor as ~parameter~ placeholder. You can move it inside the code.
But if you decide to delete it, make sure to remove it from the code editor and also use Edit->Delete Parameter menu to delete it
from existing parameter list for the block. Parameter Id can not be changed once parameter is added. But you can change
parameter Name. Name is what end user sees in the Forex Generator once he/she drops block on the diagram. Parameter Id
is hidden from the end user.
Parameter Scopes
1. verbatim is the simplest scope. Anything that is entered as Default Value for this parameter will be written verbatim
into the generated final block code. This should be default scope for functions.
2. fixed similar to verbatim scope. But end user of the block may choose to Export it using Export tab in the Forex
Generator in which case fixed becomes the same as external.
3. external it makes parameter Exported by default.
4. global it is scope usually used by Hidden variables. This allows you to have variable at the file scope but without it
being Exported via extern/input.
Most parameters usually have fixed or external scope. If parameter has Type=function then it must have Scope=verbatim.
Special Parameter ~next~
Special parameter called ~next~ is used by Generator to call other to this block attached blocks. If you have a block that is
designed to call other blocks based on actions in it, use ~next~ parameter and Generator will create function calls to execute
blocks attached to this block.

Etasoft Inc.

Page 5

1/7/2016

Forex Generator Block Editor version 1.x

There is example of ~next~ parameter in use. Do not add more than one ~next~ inside your block.
If you miss to enter ~next~ parameter Block Editor will show warning message in the status line during Test And Compile.
You can enter parameter ~next~ in the editor window. No need to use Add Parameter menu.
Additional Code
Some blocks require additional code in Properties, OnInit and OnDeInit sections of the generated EA or Custom Indicator. You
can enter those using Edit->Additional Code menu.
You have to understand how code gets assembled into final block in order use these Properties, OnInit and OnDeInit sections. It
is for advanced use only. Blocks that contain Properties, OnInit and OnDeInit sections are harder to create and require more
testing in Forex Generator.
If you just start using FXG Block Editor do not create blocks that require these sections. Start with smaller blocks first.

Etasoft Inc.

Page 6

1/7/2016

Forex Generator Block Editor version 1.x

In this screenshot additional code for Histogram2 block is displayed.


Test And Compile
Test And Compile does not guarantee that your block will perform well when used in Forex Generator. However it allows you to
test and syntax check your block. When you press Test And Compile Block Editor creates mock EA and tries to compile it using
MT compiler. All the errors reported are indicated in the Tester Output window.
Test And Compile is built to create mock EA and test blocks for EAs so it is not suitable when you need to test blocks for Custom
Indicators. You can still syntax check basic code but also use Forex Generator to test blocks you build for Custom Indicators.

Etasoft Inc.

Page 7

1/7/2016

Forex Generator Block Editor version 1.x

Errors indicated inside Tester Output window.


Examples
Please take a look at examples folder under FXG Block Editor installation for various sample building blocks. There is also
library folder that contains almost every block there is in default Forex Generator. Note that blocks in library folder have been
built using simple text editor tools prior to FXG Block Editor therefore they lack proper indentation.
Example 1: Technical Analysis Block
Technical Analysis is one of the most important blocks in Forex Generator. But it only contains few parameters and is easy to
understand since code is so short. Basically it is IF statement with few parameters.
Pay special attention to parameter properties Scope and Type.

Etasoft Inc.

Page 8

1/7/2016

Forex Generator Block Editor version 1.x

There are two ~functions~ in this example and both are used with typical Scope=verbatim and Type=function. This means that
function can not be exported as external parameter by the end user.
As you may notice parameters have Ids ~Function1~ and ~Function2~ but they Names to the end user are _First Function and
Second Function.
~Compare~ parameter is special. Since we do not want user to be able to choose any other values than >, <, ==, etc. It is also
setup with Scope=verbatim but Type=string. String because we want ~Compare~ to be produced in the output AS IS.

Etasoft Inc.

Page 9

1/7/2016

Forex Generator Block Editor version 1.x

Acceptable Values parameter allows us to restrict values to only specific set number of values. Because values are restricted we
need to set Default Value same as one of the values listed in Acceptable Values list.
Parameter ~next~ is inside IF statement. Therefore any other connected blocks to this block will be executed only if statement
with functions/indicators will be True.
Example 2: Buy Order
Buy Order block contains much more parameters and is more complex due to support for both regular and ECN brokers. ECN
brokers require than order stoploss and takeprofit would be sent as separate Order Modify command. Therefore Buy Order
contain Boolean variable called ~ECNBroker~.

Etasoft Inc.

Page 10

1/7/2016

Forex Generator Block Editor version 1.x

Boolean parameters are set to Scope=fixed (can be external) and Type=bool. In order to limit values that can be assigned
Acceptable Values is set to true,false and Default Value=true.
Most other Buy Order block parameters have either Scope=fixed or Scope=external. The difference between two is very small.
Scope=external simply makes block variable exported-by-default. While Scope=fixed makes block variable not exported-bydefault.
General Recommendations
1. Restrict block variable values to only valid values. In other words, do not allow end user select values of variables that
would make block work incorrectly or do not work at all. This is usually done via Type and Acceptable Values parameters.
2. Provide detailed block Description via Block Properties screen.
3. Provide valid values in Developer and Version fields. Change Version field every time significant change is made to the
block.
4. Design connectable blocks using ~next~ parameter. Connectable blocks are much more natural to work with. Since Forex
Generator provides diagram interface natural user expectation is to be able to drop blocks on the diagram and connect
them.
5. Make sure end user uses same version of the Forex Generator as you are. Subtle and hard to understand errors can
arise if Forex Generator versions are different. Tester Output window contains version number of Forex Generator it is
targeting (check few first lines of the output in Tester Output window).
Useful tip: you can drag-and-drop *.def file from Windows Explorer into FXG Block Editor and it will open.

Etasoft Inc.

Page 11

1/7/2016

You might also like