Incompatible types

Unlike MQL4, ActFX supports only strict type variables. So if a function contains a parameter of integer type, then only integer value can be used for this parameter in the converted script.

ActFX Strategy Editor will return one of the following messages:

Compilation Error: Incompatible types
Compilation Error: Incompatible types: 'Integer', 'Extended'
Compilation Error: Incompatible types: 'Integer', 'Boolean'
Compilation Error: Incompatible types: 'Extended', 'Boolean'

 

To fix the problem all you need is to use one of the “Mathematical” or “Data Type Conversion Functions” described here.

 

hmtoggle_plus1Assigning parameter to a variable without transforming to the corresponding type (int:=real or int:=bool or real:=bool);

Example:

var saUp: Real;

var saDn: Real;

var saDif: Integer;

saDif := (saUp - saDn) / Point;

Here saDif variable is integer, but expert adviser’s author tries to assign a floating value.

converter_err1

Solution:

Change the type of result variable: var saDif: Real;

Use functions that will remove fractional part of the number (Trunc(); Round(); Int();): saDif := Trunc((saUp - saDn) / Point);

 

hmtoggle_plus1 Assigning Integer or Float values to Boolean variables

Example:

var buyBE: Boolean;

buyBE := 1;

Here buyBE variable is Boolean, but expert adviser’s author tries to assign an integer value.

converter_err2

Solution:

Use standard parameters true/false instead of numbers: buyBE := True;
Change the type of result variable: var buyBE: Integer;
In case you are not sure what type you need to use, you can initiate Variant variable: var buyBE: Variant;
Use data type conversion functions based on String value: buyBE:= StrToBool(IntToStr(1));

 

hmtoggle_plus1Using a value as a string parameter ('text'+int or  'text'+real or 'text'+bool);

Example:

var OrderCnt: Integer;

var sComment: String;

sComment := sComment + 'Open orders =' + OrderCnt;

Here sComment variable is string, but author tries to assign an integer value OrderCnt without type conversion.

converter_err3

Solution:

Use type convertor function (IntToStr(); FloatToStr() etc.): sComment := sComment + 'Open orders =' + IntToStr(OrderCnt);

 

hmtoggle_plus1 More than 2 parameters in logical expression

Example:

if (((Open (2) < Open (1) < Open (0)))) then

 

FXApps does not support such logical expressions.

converter_err4

Solution:

Divide the expression into pair: if (Open (2) < Open (1)) and (Open (1) < Open (0)) then
Show/Hide Hidden Text