Page 1 of 1

How to use Delphi's Dialog box in a Strategy

Posted: Wed Dec 25, 2013 11:50 am
by hendiyes
Suppose you have a Forex Tester's strategy, and within your strategy, you wish to selectively taking signal through a dialog box, i.e., when a trigger signal is registered, you would choose between taking and skipping that signal.

You would take the signal if the market condition is right, otherwise skip the trigger signal.

Here's sample codes to implement user's selection. I have tested it on FT, my compiler is Lazarus.

library PoppingUpDialogue;

uses

Interfaces, // for LCL in Lazarus Compiler
Windows, // for MessageBox
StrategyInterfaceUnit // for Print
;

{-----Init strategy----------------------------------------------------------}
procedure InitStrategy; stdcall;
begin
end;

{-----Done strategy----------------------------------------------------------}
procedure DoneStrategy; stdcall;
begin

end;

{-----Reset strategy---------------------------------------------------------}
procedure ResetStrategy; stdcall;
begin
//
end;


{-----Process single tick----------------------------------------------------}
procedure GetSingleTick; stdcall;

var
temp: Word;


begin


Pause;
temp := MessageBox(0, PChar('Do you want to do something?'), PChar('Think please :)'), MB_YESNO+MB_ICONQUESTION);
Pause;

if (temp = IDYES) then Print('Do something!');
if (temp = IDNO) then Print('Do NOTHING!');
Pause;


end;

exports
InitStrategy, DoneStrategy,
ResetStrategy,
GetSingleTick;

end.