In this EA I build in a GetOrderInfo function to get the OpenPrice of the placed order.
Subsequently the OpenPrice will be displayed in a popup window.
This EA is only for figuring out how to script the GetOrderFunction.
Is this EA I get the error message: [dcc32 Error] Test.dpr(77): E2033 Types of actual and formal var parameters must be identical.
Clearly the GetOrderInfo function is not set up properly.
Please somebody help with implementing the GetOrderInfo function correctly.
Code: Select all
library Test;
uses
SysUtils,
StrategyInterfaceUnit,
DateUtils,
Windows,
Math;
var
LastTime: TDateTime;
Timeframe: integer;
OrderHandle: integer;
SymbolName: PAnsiChar = nil;
lot: double = 1;
TakeProfit: integer = 10000;
StopLoss: integer = 2650;
x:integer = 0;
OpenPrice:integer;
Oprice: double;
{-----Init strategy---------------------------------------------------------}
procedure InitStrategy; stdcall;
begin
// set strategy name and description
StrategyShortName('GetOrderInfo check');
StrategyDescription('EA to figure out how to script GetOrderInfo');
// register parameters
AddSeparator('Trade settings');
RegOption('Symbol', ot_Currency, SymbolName);
ReplaceStr(SymbolName, 'USDJPY');
RegOption('Lot', lot, 1, 0.1, 10);
RegOption('Take Profit', TakeProfit, 1, 100000);
RegOption('Stop Loss', StopLoss, 1, 100000);
RegOption('Timeframe', ot_TimeFrame, Timeframe);
Timeframe := PERIOD_H4;
end;
{-----Done strategy---------------------------------------------------------}
procedure DoneStrategy; stdcall;
begin
FreeMem(SymbolName);
end;
{-----Reset strategy--------------------------------------------------------}
procedure ResetStrategy; stdcall;
begin
LastTime := 0; // reset options before new test
end;
{-----Code Testing Popup Window--------------------------------------------}
procedure TestWindow;
begin
if (x = 0) then
begin
x := x + 1;
MessageBox(0, PChar('Open price: '+FloatToStr(Oprice)),PChar('Test Window'), MB_OK);
end;
end;
{-----Process single tick---------------------------------------------------}
procedure GetSingleTick; stdcall;
begin
SetCurrencyAndTimeFrame(SymbolName, Timeframe);
if (OrdersTotal = 0) then
begin
SendInstantOrder(SymbolName, op_Buy, Lot, Ask - StopLoss*Point, Ask + TakeProfit*Point, '', 1, OrderHandle);
end;
GetOrderInfo(OrderHandle, OpenPrice);
Oprice := OpenPrice;
TestWindow;
end;
exports
InitStrategy,
DoneStrategy,
ResetStrategy,
GetSingleTick;
Begin
end.