plz convert this EA back to MQL for EA 1:,,,

Posted By kkptra Sunday, July 03, 2016
Add to Favorites0
Author Message
kkptra
 Posted Sunday, July 03, 2016
Supreme Being

Supreme Being - (333 reputation)Supreme Being - (333 reputation)Supreme Being - (333 reputation)Supreme Being - (333 reputation)Supreme Being - (333 reputation)Supreme Being - (333 reputation)Supreme Being - (333 reputation)Supreme Being - (333 reputation)Supreme Being - (333 reputation)

Group: Forum Members
Last Active: Tuesday, July 19, 2016
Posts: 3, Visits: 10
333
hi, I have a converted ActFX (from Mql file), conversion done error-less but ACtFx code is not opening any order,,, and do not have the MQL file... can anyone help to to convert back this converted Actfx code to MQL code..

Here is EA which was successfully converted, but no trades at all.

Please provide the MQL file for below.
Here is the code for EA 1:

uses 'LibMQL4.actlib';
const StrategyName = 'Trader2014.mq4';
const copyright_1 = 'XYZ';
const link_2 = '';
const version_3 = '1.00';
const strict_4 = 'Parameters property sheet with confirmation always appears in ActFX language';
const link_5 = '';
var Step: Variant = 120;
var FirstLot: Real = 0.1;
var IncLot: Real = 0;
var MinProfit: Real = 450;
var Magic: Variant = 2008;
var gLotSell: Real = 0;
var gLotBuy: Real = 0;
var LSP: Real;
var LBP: Real;

function OnStart : Variant;
begin
Comment ('ESB Monetary SA');
GlobalVariableSet ('OldBalance', AccountBalance ());
Result := (0);
Exit;
end;

function OnStop : Variant;
begin
Comment ('');
Result := (0);
Exit;
end;

function OnNewCandle : Variant;
var i: Integer;
var sl: Real;
var p: Real;
begin
if (AccountEquity () >= GlobalVariableGet ('OldBalance') + MinProfit) then
begin
DeletePendingOrders (Magic);
CloseOrders (Magic);
GlobalVariableSet ('OldBalance', 0);

end;

GlobalVariableSet ('OldBalance', AccountBalance ());
if (MyOrdersTotal (Magic) = 0) then
begin
OrderSend (Symbol (), OP_BUYLIMIT, FirstLot, (Ask - Step * Point), 3, 0, 0, '', Magic, 0, Green);
OrderSend (Symbol (), OP_SELLLIMIT, FirstLot, (Bid + Step * Point), 3, 0, 0, '', Magic, 0, Red);

end;

LSP := GetLastSellPrice (Magic);
LBP := GetLastBuyPrice (Magic);
if (LSP - Bid) <= 5 * Point then
OrderSend (Symbol (), OP_SELLLIMIT, (gLotSell + IncLot), LSP + Step * Point, 3, 0, 0, '', Magic, 0, Red);

if (Ask - LBP) <= 5 * Point then
OrderSend (Symbol (), OP_BUYLIMIT, (gLotBuy + IncLot), LBP - Step * Point, 3, 0, 0, '', Magic, 0, Red);

Result := (0);
Exit;
end;

function DeletePendingOrders (Magic : Variant) : Variant;
var total: Variant;
var cnt: Variant;
begin
total := (OrdersTotal ());
begin
for cnt := total - 1
downto 0 do begin
OrderSelect (cnt, SELECT_BY_POS, MODE_TRADES);
if ((OrderMagicNumber () = Magic) and (OrderSymbol () = Symbol ()) and ((OrderType () <> OP_BUY) or (OrderType () <> OP_SELL))) then
OrderDelete (OrderTicket ());

end;

end;
Result := (0);
Exit;
end;

function CloseOrders (Magic : Variant) : Variant;
var total: Variant;
var cnt: Variant;
begin
total := (OrdersTotal ());
begin
for cnt := total - 1
downto 0 do begin
OrderSelect (cnt, SELECT_BY_POS, MODE_TRADES);
if ((OrderMagicNumber () = Magic) and (OrderSymbol () = Symbol ())) then
begin
if (OrderType () = OP_BUY) then
OrderClose (OrderTicket (), OrderLots (), Bid, 3);

if (OrderType () = OP_SELL) then
OrderClose (OrderTicket (), OrderLots (), Ask, 3);

end;

end;

end;
Result := (0);
Exit;
end;

function MyOrdersTotal (Magic : Variant) : Variant;
var c: Variant;
var total: Variant;
var cnt: Variant;
begin
c := (0);
total := (OrdersTotal ());
begin
for cnt := 0 to total - 1 do begin
OrderSelect (cnt, SELECT_BY_POS, MODE_TRADES);
if ((OrderMagicNumber () = Magic) and (OrderSymbol () = Symbol ())) then
Inc (c);

end;

end;
Result := (c);
Exit;
end;

function GetLastBuyPrice (Magic : Variant) : Real;
var total: Variant;
var cnt: Variant;
begin
total := (OrdersTotal () - 1);
begin
for cnt := total
downto 0 do begin
OrderSelect (cnt, SELECT_BY_POS, MODE_TRADES);
if ((((OrderMagicNumber () = Magic) and (OrderSymbol () = Symbol ()) and ((OrderType () = OP_BUYLIMIT) or (OrderType () = OP_BUY))))) then
begin
gLotBuy := OrderLots ();
Result := (OrderOpenPrice ());
Exit; break;

end;

end;

end;
Result := (0);
Exit;
end;

function GetLastSellPrice (Magic : Variant) : Real;
var total: Variant;
var cnt: Variant;
begin
total := (OrdersTotal () - 1);
begin
for cnt := total
downto 0 do begin
OrderSelect (cnt, SELECT_BY_POS, MODE_TRADES);
if ((((OrderMagicNumber () = Magic) and (OrderSymbol () = Symbol ()) and ((OrderType () = OP_SELLLIMIT) or (OrderType () = OP_SELL))))) then
begin
gLotSell := OrderLots ();
Result := (OrderOpenPrice ());
Exit; break;

end;

end;

end;
Result := (100000);
Exit;
end;

procedure OnCreate;
begin
Settings.AddAccount(@Account, 'Account', '30');
Settings.AddCandleHistory(@History, 'Candle History', 'EURUSD', CI_15_Minutes, 100);
History.OnNewCandleEvent := @OnNewCandle;
Settings.AddInteger(@Step, 'Step', Step);
Settings.AddFloat(@FirstLot, 'FirstLot', FirstLot);
Settings.AddFloat(@IncLot, 'IncLot', IncLot);
Settings.AddFloat(@MinProfit, 'MinProfit', MinProfit);
Settings.AddInteger(@Magic, 'Magic', Magic);

end;

Similar Topics

Expand / Collapse

Reading This Topic

Expand / Collapse

Back To Top