MQL-to-ACT converter etc...

Posted By user666 Saturday, October 25, 2014
Add to Favorites1
Author Message
user666
 Posted Saturday, October 25, 2014
Supreme Being

Supreme Being - (1,364 reputation)Supreme Being - (1,364 reputation)Supreme Being - (1,364 reputation)Supreme Being - (1,364 reputation)Supreme Being - (1,364 reputation)Supreme Being - (1,364 reputation)Supreme Being - (1,364 reputation)Supreme Being - (1,364 reputation)Supreme Being - (1,364 reputation)

Group: Forum Members
Last Active: Tuesday, October 28, 2014
Posts: 5, Visits: 29
Hi

I tried several mq4 Expert Advisor convert to ActTrader strategy.

Conversion was made without any errors. But no one of Strategy obtained NEVER OPEN ORDERS.

No any errors and no new orders openned.

Who and how can help me ?
user666
 Posted Saturday, October 25, 2014
Supreme Being

Supreme Being - (1,364 reputation)Supreme Being - (1,364 reputation)Supreme Being - (1,364 reputation)Supreme Being - (1,364 reputation)Supreme Being - (1,364 reputation)Supreme Being - (1,364 reputation)Supreme Being - (1,364 reputation)Supreme Being - (1,364 reputation)Supreme Being - (1,364 reputation)

Group: Forum Members
Last Active: Tuesday, October 28, 2014
Posts: 5, Visits: 29
Here is example of EA which was successfully converted, but no trades at all. Who can explain ?

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;
user666
 Posted Sunday, October 26, 2014
Supreme Being

Supreme Being - (1,364 reputation)Supreme Being - (1,364 reputation)Supreme Being - (1,364 reputation)Supreme Being - (1,364 reputation)Supreme Being - (1,364 reputation)Supreme Being - (1,364 reputation)Supreme Being - (1,364 reputation)Supreme Being - (1,364 reputation)Supreme Being - (1,364 reputation)

Group: Forum Members
Last Active: Tuesday, October 28, 2014
Posts: 5, Visits: 29
I see nobody interested in this strategy or all are newbie, like me.
It's great mistake. It's very good EA. 100% profitable. In any market conditions. 100% win expert advisor (Strategy). Work with any pair, any instrument. Using this Strategy in some way you can earn at list 60% income from deposit per year. Note : IN ANY MARKET CONDITIONS !!!

How many profitable strategies you can represent like this ?

Are all of this forum without hands and brains and nobody can help me and himself ? Is really this platform has poor interest ? It can be true.

I want move from scam MT4 brokers. Most of them are pure scam - freez platform, shutdown platform and make different others surprises if see trader is profitable.

I'm seeking to move to other platform and hope to find help here before I study this new algorithmic programming language.

Thank you advance.

user666
 Posted Monday, October 27, 2014
Supreme Being

Supreme Being - (1,364 reputation)Supreme Being - (1,364 reputation)Supreme Being - (1,364 reputation)Supreme Being - (1,364 reputation)Supreme Being - (1,364 reputation)Supreme Being - (1,364 reputation)Supreme Being - (1,364 reputation)Supreme Being - (1,364 reputation)Supreme Being - (1,364 reputation)

Group: Forum Members
Last Active: Tuesday, October 28, 2014
Posts: 5, Visits: 29
Here http://www.actfx.com/Download50188.aspx
there was found interesting strategy, I think.
But code from 2011 year and script for BB indicator changed from that time.
I made changes in the code of strategy and strategy was compiled without errors. Here is code after changes.

const

StrategyName = 'BBOpenClose';

var

History: TCandleHistory;

Account: TAccount;

Amount: Double;

TraderRange: integer;

BB: TIndicatorScript;

BB_set: TMovingAverage;

procedure OnCreate;

begin

AddCandleHistorySetting(@History, 'Candle History', 'USDCHF', CI_5_Minutes, 100);

History.OnNewCandleEvent := @OnNewCandle;

History.OnNewRateEvent := @OnNewRate;

AddAccountSetting(@Account, 'Account', '');

AddFloatSetting(@Amount, 'Amount(Lots)', 1);

AddIntegerSetting(@TraderRange, 'Trader Range', 0);


// BB_set.CalculationType := cbClose;
// BB_set.AverageType := makSimple;
// BB_set: TMovingAverage;

BB := TIndicatorScript.Create(History, 'BollingerBands' , 'Bollinger Bands');

BB_set.Period := 20;

BB.SetVariableValue('Dev', 2);

BB_set := BB.VariableValue('MA');

end;


procedure closeOpenPos;

var

i : integer;

begin

i:=TradeList.Count-1;

while i >= 0 do

begin

if TradeList.Get(i).Tag = 'BBOpenClose' then

CloseTrade(TradeList.Get(i), amount, traderrange, '');

i := i-1;

end;

end;

function countTrades : integer;

var

i, sum : integer;

begin

sum := 0;

for i:= 0 to TradeList.Count-1 do

if TradeList.Get(i).Tag = 'BBOpenClose' then sum:= sum+1;

result := sum;

end;

procedure OnNewRate;

begin

if ((History.Instrument.Sell > BB.GetGraph(0).Last) and

(countTrades = 0)) then

CreateOrder(History.Instrument, Account, Amount, bsSell,

NullRate,

NullRate, TraderRange, 'BBOpenClose');

if ((History.Instrument.Sell < BB.GetGraph(2).Last)and

(countTrades = 0)) then

CreateOrder(History.Instrument, Account, Amount, bsBuy,

NullRate,

NullRate, TraderRange, 'BBOpenClose');

if (((History.Instrument.Sell <= BB.GetGraph(1).Last) and

(History.Last(0).Open > BB.GetGraph(1).Last)) or

((History.Instrument.Sell >= BB.GetGraph(1).Last) and

(History.Last(0).Open < BB.GetGraph(1).Last))) then

closeOpenPos;

end;

But when I try run strategy in tester I'm getting such error:






EXCEPTION
EAccessViolation in TdxBarButton
CODE

MESSAGE
Exception at trading strategy "BBOpenClose" in routine OnCreate at Line:Column 46:3
Reference to undefined object
DETAILS

CALL STACK
kernel32.dll=>=>MultiByteToWideChar=>0
kernel32.dll=>=>GetCurrentThreadId=>0
kernel32.dll=>=>SetEvent=>0
kernel32.dll=>=>SetEvent=>0
kernel32.dll=>=>ResumeThread=>0
kernel32.dll=>=>SleepEx=>0
kernel32.dll=>=>Sleep=>0
kernel32.dll=>=>Sleep=>0
fx_client.exe=>dxBar.pas=>Finalization=>54619
kernel32.dll=>=>MultiByteToWideChar=>0
fx_client.exe=>StrategyProcessor.pas=>TStrategyProcessor.CallFSFunction=>772
ntdll.dll=>=>KiUserExceptionDispatcher=>0
fx_client.exe=>ACT_Script.CallMethods.pas=>CallMethods.TFastScriptCallMethods.SP_MovingAverage=>563
fx_client.exe=>fs_iinterpreter.pas=>TfsPropertyHelper.SetValue=>1299
fx_client.exe=>fs_iinterpreter.pas=>TfsDesignator.DoCalc=>1954
fx_client.exe=>fs_iinterpreter.pas=>TfsDesignator.DoCalc=>1903
fx_client.exe=>fs_iinterpreter.pas=>TfsDesignator.SetValue=>2006
fx_client.exe=>fs_iinterpreter.pas=>TfsAssignmentStmt.Execute=>2988
fx_client.exe=>fs_iinterpreter.pas=>TfsStatement.Execute=>2952
fx_client.exe=>fs_iinterpreter.pas=>TfsProcVariable.GetValue=>1153
fx_client.exe=>fs_iinterpreter.pas=>TfsScript.CallFunction=>2568
fx_client.exe=>fs_iinterpreter.pas=>TfsScript.CallFunction=>2559
fx_client.exe=>StrategyProcessor.pas=>TStrategyProcessor.CallFSFunction=>769
fx_client.exe=>StrategyProcessor.pas=>TStrategyProcessor.CallFSFunction=>764
fx_client.exe=>StrategyProcessor.pas=>TStrategyProcessor.OnCreate=>730
fx_client.exe=>StrategyProcessor.pas=>TStrategyProcessor.OnCreate=>727
fx_client.exe=>StartedStrategyList.pas=>TRanStrategyList.AddStrategyProcessor=>145
fx_client.exe=>StartedStrategyList.pas=>TRanStrategyList.AddStrategyProcessor=>137
fx_client.exe=>StrategyUtils.pas=>RunStrategy=>70
fx_client.exe=>StrategyUtils.pas=>RunStrategy=>53
fx_client.exe=>UserStrategiesEditor.pas=>TForm_UserStrategiesEditor.Button_TestClick=>94
fx_client.exe=>dxBar.pas=>Finalization=>54619
fx_client.exe=>dxBar.pas=>Finalization=>54619
fx_client.exe=>dxBar.pas=>TdxBarSkinnedPainter.SubMenuControlGetScrollArrowSize=>53068
fx_client.exe=>dxBar.pas=>TdxBarSkinnedPainter.SubMenuControlDrawMarkContent=>53046
fx_client.exe=>dxBar.pas=>Finalization=>54619
fx_client.exe=>dxBar.pas=>TdxBarWinControl.SysKeyDown=>37951
fx_client.exe=>dxBar.pas=>TdxBarWinControl.SetFocused=>37926
fx_client.exe=>dxBar.pas=>TdxBarStandardPainter.DrawItemBackgroundInSubMenu=>47173
kernel32.dll=>=>GetCurrentThreadId=>0
fx_client.exe=>dxBar.pas=>DrawRightBorder=>49445
fx_client.exe=>dxBar.pas=>TdxBarItem.SetVisible=>39151
fx_client.exe=>dxBar.pas=>TdxBarItem.SetEnabled=>39147
fx_client.exe=>dxBar.pas=>TdxBarItem.Create=>38683
fx_client.exe=>dxBar.pas=>TdxBarButtonLikeControl.StartSubMenuTracking=>38347
USER32.dll=>=>CallNextHookEx=>0
fx_client.exe=>dxBar.pas=>TdxBarButtonLikeControl.GetFadingParams=>38282
fx_client.exe=>dxBar.pas=>TdxBarFlatPainter.DateNavigatorDrawButton=>48687
USER32.dll=>=>GetPropW=>0
USER32.dll=>=>GetPropW=>0
USER32.dll=>=>DispatchMessageW=>0
USER32.dll=>=>DispatchMessageW=>0
fx_client.exe=>Fx_Client.dpr=>=>489
kernel32.dll=>=>BaseThreadInitThunk=>0

WINDOWS VERSION
6.0.6002 Service Pack 2
APPLICATION INFO
fx_client.exe 4.7.223.87/4.7.223
http://demo4.sysfx.com:8172/xml/; edforex172; ТРЕЙДЕР: demo6519
RAISE TIME
2014-10-27 14:25:59
Server Time: 9:25:51 AM



I don't know how I can resolve this problem. May be somebody can help.
Monday, October 27, 2014 by user666
Admin
 Posted Monday, October 27, 2014
Administrator

Administrator - (130,561 reputation)

Group: Administrators
Last Active: Friday, June 02, 2017
Posts: 548, Visits: 3,295
Dear user666,


Thenewest strategies and indicators are available in the FXApp store inside theplatform (there are opened sources strategies as well).

The EA you have provided works with some "Magic" number = 2008.
Based on the source - the positions should be opened due to some conditions,based on "Magic" number. So it needs to be monitoring, maybe the 2008value haven't reach during the testing. You can try to use less number, forexample 10.


Best regards

-ACTFX© Forum Administrator
user666
 Posted Monday, October 27, 2014
Supreme Being

Supreme Being - (1,364 reputation)Supreme Being - (1,364 reputation)Supreme Being - (1,364 reputation)Supreme Being - (1,364 reputation)Supreme Being - (1,364 reputation)Supreme Being - (1,364 reputation)Supreme Being - (1,364 reputation)Supreme Being - (1,364 reputation)Supreme Being - (1,364 reputation)

Group: Forum Members
Last Active: Tuesday, October 28, 2014
Posts: 5, Visits: 29
Below there is other relatively good EA. Convertion from MQ4-to-ACTFX without any errors.
But no opened orders at all. No errors.
Please explain !!!!!!1!!!!
I want to see this EA workable after convertion. I cannot understand reason why no trade.

uses 'LibMQL4.actlib';
const StrategyName = 'TSD v12.3.mq4';
const copyright_1 = 'Copyright © 2009, http://www.forex-tsd.com';
const link_2 = 'http://www.forex-tsd.com';
var MagicNumber: Variant = 10001;
var Lots: Real = 1.0;
var TakeProfit: Variant = 100;
var TrailingStop: Variant = 60;
var Slippage: Variant = 5;
var UseTimeLimit: Boolean = true;
var UseAutomaticMM: Boolean = true;
var Risk: Real = 1.5;
var _: String = 'Does it allow multiple trades per bar';
var OneTradePerBar: Boolean = false;
var __: String = 'Setting for friday positions close';
var CloseOnFriday: Boolean = false;
var FridayCloseHour: Variant = 21;
var FridayCloseMinute: Variant = 59;
var StartMinute1: Real = 0;
var EndMinute1: Real = 0;
var StartMinute2: Real = 0;
var EndMinute2: Real = 0;
var StartMinute3: Real = 0;
var EndMinute3: Real = 0;
var StartMinute4: Real = 0;
var EndMinute4: Real = 0;
var StartMinute5: Real = 0;
var EndMinute5: Real = 0;
var StartMinute6: Real = 0;
var EndMinute6: Real = 0;
var StartMinute7: Real = 0;
var EndMinute7: Real = 0;
var PriceOpen: Real = 0;
var NewPrice: Real = 0;
var newbar: Real = 0;

function OnNewCandle : Variant;
var pipMultiplier: Real;
var i: Integer;
var symbolFound: Boolean;
var withinTimeLimit: Boolean;
var TradesThisSymbol: Variant;
var OsMAPrevious: Real;
var OsMAPrevious2: Real;
var Force: Real;
var ForcePos: Boolean;
var ForceNeg: Boolean;
var OsMADirection: Real;
var tp: Real;
var ts: Real;
var sl: Real;
var ticket: Variant;
begin
if ((Digits = 3) or (Digits = 5)) then
pipMultiplier := 10

else pipMultiplier := 1;
if (CloseOnFriday) and (TimeDayOfWeek (TimeCurrent ()) = 5) then
begin
if (TimeHour (TimeCurrent ()) > FridayCloseHour) or ((TimeHour (TimeCurrent ()) = FridayCloseHour) and (TimeMinute (TimeCurrent ()) >= FridayCloseMinute)) then
begin
for i := OrdersTotal () - 1
downto 0 do begin
OrderSelect (i, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol () <> Symbol ()) then
continue;

if (OrderMagicNumber () <> MagicNumber) then
continue;

if (OrderType () = OP_BUYSTOP) then
begin
OrderDelete (OrderTicket (), CLR_NONE);
continue;

end;

if (OrderType () = OP_SELLSTOP) then
begin
OrderDelete (OrderTicket (), CLR_NONE);
continue;

end;

if (OrderType () = OP_BUY) then
begin
OrderClose (OrderTicket (), OrderLots (), Ask, 0, CLR_NONE);
continue;

end;

if (OrderType () = OP_SELL) then
begin
OrderClose (OrderTicket (), OrderLots (), Bid, 0, CLR_NONE);
continue;

end;

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

end;

symbolFound := (false);
if (checkSymbol ('USDCHF')) then
begin
setMinutes (0, 1, 8, 9, 16, 17, 24, 25, 32, 33, 40, 41, 48, 49);
symbolFound := true;

end;

if (checkSymbol ('GBPUSD')) then
begin
setMinutes (2, 3, 10, 11, 18, 19, 26, 27, 34, 35, 42, 43, 50, 51);
symbolFound := true;

end;

if (checkSymbol ('USDJPY')) then
begin
setMinutes (4, 5, 12, 13, 20, 21, 28, 29, 36, 37, 44, 45, 52, 53);
symbolFound := true;

end;

if (checkSymbol ('EURUSD')) then
begin
setMinutes (6, 7, 14, 15, 22, 23, 30, 31, 38, 39, 46, 47, 54, 59);
symbolFound := true;

end;

if (not symbolFound) then
begin
Result := (0);
Exit;
end;

if UseTimeLimit then
withinTimeLimit := (((Minute () >= StartMinute1) and (Minute () <= EndMinute1)) or ((Minute () >= StartMinute2) and (Minute () <= EndMinute2)) or ((Minute () >= StartMinute3) and (Minute () <= EndMinute3)) or ((Minute () >= StartMinute4) and (Minute () <= EndMinute4)) or ((Minute () >= StartMinute5) and (Minute () <= EndMinute5)) or ((Minute () >= StartMinute6) and (Minute () <= EndMinute6)) or ((Minute () >= StartMinute7) and (Minute () <= EndMinute7)))

else withinTimeLimit := true;
if (not withinTimeLimit) then
begin
Result := (0);
Exit;
end;

TradesThisSymbol := (0);
begin
for i := OrdersTotal () - 1
downto 0 do begin
OrderSelect (i, SELECT_BY_POS, MODE_TRADES);
if (OrderMagicNumber () <> MagicNumber) then
continue;

if (OrderSymbol () <> Symbol ()) then
continue;

Inc (TradesThisSymbol);

end;

end;
OsMAPrevious := (iOsMA (NULL, PERIOD_W1, 12, 26, 9, PRICE_CLOSE, 1));
OsMAPrevious2 := (iOsMA (NULL, PERIOD_W1, 12, 26, 9, PRICE_CLOSE, 2));
Force := (iForce (NULL, PERIOD_D1, 2, MODE_EMA, PRICE_CLOSE, 1));
ForcePos := (Force > 0);
ForceNeg := (Force < 0);
if OsMAPrevious > OsMAPrevious2 then
OsMADirection := (1);

if OsMAPrevious < OsMAPrevious2 then
OsMADirection := - 1;

if (OsMAPrevious = OsMAPrevious2) then
OsMADirection := 0;

if (not IsTesting ()) or ((IsTesting ()) and (IsVisualMode ())) then
Comment ('TSD for MT4 ver beta 0.3 - DO NOT USE WITH REAL MONEY YET', '', '', 'Weekly OsMAPrevious = ', OsMAPrevious, '', 'Weekly OsMAPrevious2 = ', OsMAPrevious2, '', 'Weekly OsMADirection = ', OsMADirection, '', '', 'Daily Force = ', Force, '', 'Is Daily Force Bullish = ', ForcePos, '', 'Is Daily Force Bearish = ', ForceNeg, '', '', 'Total Orders = ', OrdersTotal (), '', 'Trades this Symbol(', Symbol (), ') = ', TradesThisSymbol, '', '', 'New Bar Time is ', MQLTimeToStr (newbar), '', '', 'Daily High[1] = ', High (1), '', 'Daily High[2] = ', High (2), '', 'Daily Low[1] = ', Low (1), '', 'Daily Low[2] = ', Low (2), '', '', 'Current Ask Price + 16 pips = ', (Ask + (16 * Point * pipMultiplier)), '', 'Current Bid Price - 16 pips = ', Bid - (16 * Point * pipMultiplier));

tp := (NormalizeDouble ((TakeProfit * Point * pipMultiplier), Digits));
ts := (NormalizeDouble ((TrailingStop * Point * pipMultiplier), Digits));
if (newbar <> iTime (NULL, 0, 0)) then
begin
newbar := iTime (NULL, 0, 0);
if (TradesThisSymbol < 1) and (canOpenTrade (Period ())) then
begin
RefreshRates ();
if (OsMADirection = 1) and (ForceNeg) then
begin
sl := (Low (1) - 1.0 * Point * pipMultiplier);
PriceOpen := High (1) + 1.0 * Point * pipMultiplier;
if PriceOpen > (Ask + 16.0 * Point * pipMultiplier) then
begin
OrderSend (Symbol (), OP_BUYSTOP, (PriceOpen - sl), PriceOpen, Slippage, sl, PriceOpen + tp, 'Buy Entry Order placed at ' + TimeCurrent (), MagicNumber, 0, Green);
Result := (0);
Exit;
end

else begin
NewPrice := Ask + 16.0 * Point * pipMultiplier;
OrderSend (Symbol (), OP_BUYSTOP, (NewPrice - sl), NewPrice, Slippage, sl, NewPrice + tp, 'Buy Entry Order placed at ' + TimeCurrent (), MagicNumber, 0, Green);
Result := (0);
Exit;
end;

end;

if (OsMADirection = - 1) and (ForcePos) then
begin
sl := High (1) + 1.0 * Point * pipMultiplier;
PriceOpen := Low (1) - 1.0 * Point * pipMultiplier;
if PriceOpen < (Bid - 16.0 * Point * pipMultiplier) then
begin
OrderSend (Symbol (), OP_SELLSTOP, (sl - PriceOpen), PriceOpen, Slippage, sl, PriceOpen - tp, 'Sell Entry Order placed at ' + TimeCurrent (), MagicNumber, 0, Green);
Result := (0);
Exit;
end

else begin
NewPrice := Bid - 16 * Point * pipMultiplier;
ticket := (OrderSend (Symbol (), OP_SELLSTOP, (sl - NewPrice), NewPrice, Slippage, sl, NewPrice - tp, 'Sell Entry Order placed at ' + TimeCurrent (), MagicNumber, 0, Green));
Result := (0);
Exit;
end;

end;

end;

if TradesThisSymbol > 0 then
begin
begin
for i := OrdersTotal () - 1
downto 0 do begin
OrderSelect (i, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol () <> Symbol ()) then
continue;

if (OrderMagicNumber () <> MagicNumber) then
continue;

RefreshRates ();
if (OrderType () = OP_BUYSTOP) then
begin
if (OsMADirection = - 1) then
begin
OrderDelete (OrderTicket ());
Result := (0);
Exit;
end;

if ((High (1) < High (2))) then
if (High (1) > (Ask + 16.0 * Point * pipMultiplier)) then
begin
OrderModify (OrderTicket (), (High (1) + 1.0 * Point * pipMultiplier), Low (1) - 1.0 * Point * pipMultiplier, OrderTakeProfit (), 0, Cyan);
Result := (0);
Exit;
end

else begin
OrderModify (OrderTicket (), (Ask + 16.0 * Point * pipMultiplier), Low (1) - 1.0 * Point * pipMultiplier, OrderTakeProfit (), 0, Cyan);
Result := (0);
Exit;
end;

end;

if (OrderType () = OP_SELLSTOP) then
begin
if (OsMADirection = 1) then
begin
OrderDelete (OrderTicket ());
Result := (0);
Exit;
end;

if ((Low (1) > Low (2))) then
if (Low (1) < (Bid - 16.0 * Point * pipMultiplier)) then
begin
OrderModify (OrderTicket (), (Low (1) - 1.0 * Point * pipMultiplier), High (1) + 1.0 * Point * pipMultiplier, OrderTakeProfit (), 0, Cyan);
Result := (0);
Exit;
end

else begin
OrderModify (OrderTicket (), (Bid - 16.0 * Point * pipMultiplier), High (1) + 1.0 * Point * pipMultiplier, OrderTakeProfit (), 0, Cyan);
Result := (0);
Exit;
end;

end;

end;

end;

end;

end;

if TradesThisSymbol > 0 then
begin
begin
for i := OrdersTotal () - 1
downto 0 do begin
if (OrderSelect (i, SELECT_BY_POS, MODE_TRADES) = false) then
break;

if (OrderSymbol () <> Symbol ()) then
continue;

if (OrderMagicNumber () <> MagicNumber) then
continue;

RefreshRates ();
if (OrderType () = OP_BUY) then
begin
if Ask - OrderOpenPrice () > (ts) then
begin
if OrderStopLoss () < (Ask - ts) then
begin
OrderModify (OrderTicket (), OrderOpenPrice (), (Ask - ts), Ask + tp, 0, Cyan);
Result := (0);
Exit;
end;

end;

end;

if (OrderType () = OP_SELL) then
begin
if OrderOpenPrice () - Bid > (ts) then
begin
if OrderStopLoss () > (Bid + ts) then
begin
OrderModify (OrderTicket (), OrderOpenPrice (), (Bid + ts), Bid - tp, 0, Cyan);
Result := (0);
Exit;
end;

end;

end;

end;

end;

end;

Result := (0);
Exit;
end;

function getLots (range : Real) : Real;
var step: Real;
var minLot: Real;
var maxLot: Real;
var lots: Real;
begin
RefreshRates ();
step := (MarketInfo (Symbol (), MODE_LOTSTEP));
minLot := (MarketInfo (Symbol (), MODE_MINLOT));
maxLot := (MarketInfo (Symbol (), MODE_MAXLOT));
lots := (Lots);
if UseAutomaticMM then
if Risk > 0 then
lots := AccountFreeMargin () * (Risk / 100.0) / (range * MarketInfo (Symbol (), MODE_TICKVALUE) / Point);

Result := (MathMax (MathMin (lots, maxLot), minLot));
Exit;
end;

function canOpenTrade (timeFrame : Variant) : Boolean;
var periodCount: Variant;
var startTime: Integer;
var endTime: Integer;
var i: Integer;
begin
periodCount := (0);
startTime := (iTime (Symbol (), timeFrame, iBarShift (Symbol (), timeFrame, iTime (NULL, 0, 0))));
endTime := (startTime + timeFrame * 60 - 1);
if (not OneTradePerBar) then
for i := OrdersHistoryTotal () - 1
downto 0 do begin
if (OrderSelect (i, SELECT_BY_POS, MODE_HISTORY) = false) then
break;

if (OrderMagicNumber () <> MagicNumber) then
continue;

if (OrderSymbol () <> Symbol ()) then
continue;

if (OrderOpenTime () < startTime) or (OrderOpenTime () > endTime) then
continue;

Inc (periodCount);

end;

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

function checkSymbol (compareToWhat : String) : Boolean;
begin
Result := (StringFind (Symbol (), compareToWhat) > - 1);
Exit;
end;

procedure setMinutes (sminute1 : Variant; eminute1 : Variant; sminute2 : Variant; eminute2 : Variant; sminute3 : Variant; eminute3 : Variant; sminute4 : Variant; eminute4 : Variant; sminute5 : Variant; eminute5 : Variant; sminute6 : Variant; eminute6 : Variant; sminute7 : Variant; eminute7 : Variant);
var Result: Variant;
begin
StartMinute1 := sminute1;
EndMinute1 := eminute1;
StartMinute2 := sminute2;
EndMinute2 := eminute2;
StartMinute3 := sminute3;
EndMinute3 := eminute3;
StartMinute4 := sminute4;
EndMinute4 := eminute4;
StartMinute5 := sminute5;
EndMinute5 := eminute5;
StartMinute6 := sminute6;
EndMinute6 := eminute6;
StartMinute7 := sminute7;
EndMinute7 := eminute7;

end;

procedure OnCreate;
begin
Settings.AddAccount(@Account, 'Account', '30');
Settings.AddCandleHistory(@History, 'Candle History', 'EURUSD', CI_15_Minutes, 100);
History.OnNewCandleEvent := @OnNewCandle;
Settings.AddInteger(@MagicNumber, 'MagicNumber', MagicNumber);
Settings.AddFloat(@Lots, 'Lots', Lots);
Settings.AddInteger(@TakeProfit, 'TakeProfit', TakeProfit);
Settings.AddInteger(@TrailingStop, 'TrailingStop', TrailingStop);
Settings.AddInteger(@Slippage, 'Slippage', Slippage);
Settings.AddCheckbox(@UseTimeLimit, 'UseTimeLimit', UseTimeLimit);
Settings.AddCheckbox(@UseAutomaticMM, 'UseAutomaticMM', UseAutomaticMM);
Settings.AddFloat(@Risk, 'Risk', Risk);
Settings.AddString(@_, '_', _);
Settings.AddCheckbox(@OneTradePerBar, 'OneTradePerBar', OneTradePerBar);
Settings.AddString(@__, '__', __);
Settings.AddCheckbox(@CloseOnFriday, 'CloseOnFriday', CloseOnFriday);
Settings.AddInteger(@FridayCloseHour, 'FridayCloseHour', FridayCloseHour);
Settings.AddInteger(@FridayCloseMinute, 'FridayCloseMinute', FridayCloseMinute);

end;
Monday, October 27, 2014 by user666
Admin
 Posted Friday, October 31, 2014
Administrator

Administrator - (130,561 reputation)

Group: Administrators
Last Active: Friday, June 02, 2017
Posts: 548, Visits: 3,295
Dear User,



The converter translates the existing code from one language into another.

It allows running the MT4 EA on ActTrader.
But because the logic of data capturing, orders monitoring etc. is different and there are some "special" features (such Magic number) available only on MT - some of the strategies need to be corrected manually after conversion. You don't need to rewrite the strategy, but only correct the specific functions.


Best regards

-ACTFX© Forum Administrator
Enrico
 Posted Thursday, March 03, 2016
Supreme Being

Supreme Being - (144 reputation)Supreme Being - (144 reputation)Supreme Being - (144 reputation)Supreme Being - (144 reputation)Supreme Being - (144 reputation)Supreme Being - (144 reputation)Supreme Being - (144 reputation)Supreme Being - (144 reputation)Supreme Being - (144 reputation)

Group: Forum Members
Last Active: Thursday, March 03, 2016
Posts: 1, Visits: 2
144
Hello !I am most interested in the usage of this converter,
Please let me know of any success and new developments,
write to me on,
enrico42@gmail.com
Most sincerely thanking you,
Enrico.
A new potential user of AVATRADER platform

user666 (10/25/2014)
Hi

I tried several mq4 Expert Advisor convert to ActTrader strategy.

Conversion was made without any errors. But no one of Strategy obtained NEVER OPEN ORDERS.

No any errors and no new orders openned.

Who and how can help me ?
Admin
 Posted Tuesday, March 08, 2016
Administrator

Administrator - (130,561 reputation)

Group: Administrators
Last Active: Friday, June 02, 2017
Posts: 548, Visits: 3,295
Dear Enrico,

The functionality of MQL->Actstrategy conversion is working. Unfortunately we are not supporting indicator conversionbecause of complicity. You can test this tool by yourself for example on demoaccount.



Best regards

-ACTFX© Forum Administrator
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,

Can u share the mql file and indicator needed ?

user666 (10/25/2014)
Hi

I tried several mq4 Expert Advisor convert to ActTrader strategy.

Conversion was made without any errors. But no one of Strategy obtained NEVER OPEN ORDERS.

No any errors and no new orders openned.

Who and how can help me ?

Similar Topics

Expand / Collapse

Reading This Topic

Expand / Collapse

Back To Top