Metatrader Forum | Forex Expert-Advisor | Broker & Forex Tools

Metatrader Forum | Forex Expert-Advisor | Broker & Forex Tools (http://www.expert-advisor.com/forum/index.php)
-   Programmierung MQL4 (http://www.expert-advisor.com/forum/forumdisplay.php?f=220)
-   -   Von Actfx auf Metatrader umprogrammieren (http://www.expert-advisor.com/forum/showthread.php?t=1668)

xerof 18.10.11 18:45

Von Actfx auf Metatrader umprogrammieren
 
Servus!

Ich habe zur Zeit ein Demo Konto bei Gci. Seit ca. 2 Monaten befasse ich mich mit Auto-trading. Ist echt Interessant!!! Mein Problem, ich lasse zur zeit über Actfx eine Strategie im Probelauf Rennen. Möchte das Script aber auf Metatrader haben. Wer kann das umprogrammieren??? Ich bin ein Trottel auf dem Gebiet......;)

Also meine Erfahrung bisher, im Backtest kannst das vergessen, aber wenn das Ding läuft dann wirft es ein paar Euros ab;-)



Hier der Code:


const
StrategyName = 'Open a Position Dual';

var //declaration of the variables
History: TCandleHistory;
Account: TAccount;
Amount, Point: Double;
Stop, Limit, TraderRange: Integer;

procedure OnCreate;
begin
AddCandleHistorySetting(@History, 'Candle History', 'EUR/USD', CI_30_Minutes, 100); //setting up the chart history
History.OnNewCandleEvent := @OnNewCandle; //indicating the procedure to run when a new candle opens
AddAccountSetting(@Account, 'Account', ''); //the account number
AddFloatSetting(@Amount, 'Amount(Lots)', 1); //the number of lots
AddIntegerSetting(@Stop, 'Stop', 300); //setting up stop in pips
AddIntegerSetting(@Limit, 'Limit', 43); //setting up limit in pips
AddIntegerSetting(@TraderRange, 'Trader Range', 0); //setting up the trader range in pips
end;

// this procedure runs when a new candle opens
procedure OnNewCandle;
begin
Point := History.Instrument.PointSize;

// if the Close price of the last finished candle is higher than the Open price
if History.Last(1).Open < History.Last(1).Close then
// open a Buy position
CreateOrder(History.Instrument, Account, Amount, bsBuy,
History.Instrument.Sell - Point*Stop,
History.Instrument.Sell + Point*Limit, TraderRange, 'NewPosition Buy');
// if the Close price of the last finished candle is lower than the Open price
if History.Last(1).Open > History.Last(1).Close then
// open a Sell position
CreateOrder(History.Instrument, Account, Amount, bsSell,
History.Instrument.Buy + Point*Stop,
History.Instrument.Buy - Point*Limit, TraderRange, 'NewPosition Sell');


end;

// this procedure runs when some changes occur in the Open Positions list
procedure OnTradeChange(const Action: TDataModificationType; const Trade: TTrade);
begin
// if the position is opened, output the information into the log
if (Action=dmtInsert) and (Trade.Tag='NewPosition') then
begin
log ('Sell position opened');
log ('Open Rate: ' +FloatToStr(Trade.OpenRate));
if Trade.StopOrder<>nil then log ('Stop Rate: ' +FloatToStr(Trade.StopOrder.Rate));
if Trade.LimitOrder<>nil then log ('Limit Rate: ' +FloatToStr(Trade.LimitOrder.Rate));
end;
end;


Alle Zeitangaben in WEZ +2. Es ist jetzt 23:58 Uhr.

Powered by vBulletin® Version 3.8.5 (Deutsch)
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.6.1
Powered by vBCMS® 2.7.0 ©2002 - 2024 vbdesigns.de
Copyright ©2009 - 2023 by Expert-Advisor.com - Das Metatrader Forum