النتائج 1 إلى 2 من 2
الموضوع: مطلوب تصميم استراتيجيه بلغه مختلفه
- 19-07-2011, 09:25 PM #1
مطلوب تصميم استراتيجيه بلغه مختلفه
هل تعلمون تصميم اكسبيرت بهذه اللغه .
//================================================== ================================================== ===
// Please do not edit this script. In order to make any changes, clone it and save it under a new name
//================================================== ================================================== ===
//================================================== ================================================== ===
// This strategy uses the Stochastic indicator on two different charts - with the 15-minute chart
// interval, and the 1 hour chart interval. It opens a Sell position when the %D line of the Stochastic
// indicator on the 15-minute chart crosses the predefined Top Level top-down, and the %D line on the
// 1 hour chart is above the Top Level. The strategy opens a Buy position when the %D line crosses the
// predefined Bottom level bottom-up, and the %D line on the 1 hour chart is below the Bottom level.
// It also outputs a message into the log when a position is opened.
//================================================== ================================================== ===
const
StrategyName = 'MultiStochastic Strategy';
var //declaration of the variables
HistoryFast,HistorySlow: TCandleHistory;
Account: TAccount;
Amount, Point: Double;
TopLevel, BottomLevel, Stop, Limit, TraderRange: Integer;
StochasticFast: TIndicatorStochastic;
StochasticSlow: TIndicatorStochastic;
procedure OnCreate;
begin
AddCandleHistorySetting(@HistoryFast, 'History', '', CI_15_Minutes, 100); //setting up the 15 minute
//interval chart history
HistoryFast.OnNewCandleEvent := @OnNewCandle; //indicating the procedure to run when a new candle
//opens on the 15 minutes chart
AddCandleHistorySetting(@HistorySlow, 'History 2', '', CI_1_Hour, 100); //setting up the 1 hour
//interval chart history
HistorySlow.OnNewCandleEvent := @OnNewCandle; //indicating the procedure to run when a new candle
//opens on the 1 hour chart
AddAccountSetting(@Account, 'Account', ''); //the account number
AddFloatSetting(@Amount, 'Amount(Lots)', 1); //the number of lots
AddIntegerSetting(@Stop, 'Stop', 20); //setting up stop in pips
AddIntegerSetting(@Limit, 'Limit', 30); //setting up limit in pips
AddIntegerSetting(@TraderRange, 'Trader Range', 0); //setting up the trader range in pips
AddIntegerSetting(@TopLevel, 'Top Level', 80); //setting up the specific top level
//that will be used
AddIntegerSetting(@BottomLevel, 'Bottom Level', 20); //setting up the specific bottom level
//that will be used
StochasticFast := TIndicatorStochastic.Create(HistoryFast, 'Stochastic'); //creating the Stochastic
//indicator on the 15 minute
//interval chart history
StochasticFast.Period := 5;
StochasticFast.AveragePeriod := 3; //setting up the Stochastic indicator periods
StochasticSlow := TIndicatorStochastic.Create(HistorySlow, 'Stochastic'); //creating the Stochastic
//indicator on the 1 hour
//interval chart history
StochasticSlow.Period := 5;
StochasticSlow.AveragePeriod := 3; //setting up the Stochastic indicator periods
end;
// this procedure runs when a new candle opens
procedure OnNewCandle;
begin
Point := HistoryFast.Instrument.PointSize;
// if the %D line on the 15-minute chart crosses the Top Level top-down,
if (StochasticFast.GraphD.Last(2)>TopLevel)
and (StochasticFast.GraphD.Last(1)<TopLevel) then
begin
// output the message that the Stochastic has crossed the Top Level
log ('the Stochastic on the 15-minute chart has crossed the Top Level top-down');
// if the %D line on the 1-hour chart is above the Top Level,
if StochasticSlow.GraphD.Last(1)>TopLevel then
begin
// output the message into the log
log ('the Stochastic on the 1 hour chart is above the Top Level');
log ('Conditions for Sell position fulfilled. Position opened');
// open a Sell Position
CreateOrder(HistoryFast.Instrument, Account, Amount, bsSell,
HistoryFast.Instrument.Buy + Point*Stop,
HistoryFast.Instrument.Buy - Point*Limit, TraderRange, 'MultiTrade');
end;
end;
// if the %D line on the 15-minute chart crosses the Bottom Level bottom-up,
if (StochasticFast.GraphD.Last(1)>BottomLevel)
and (StochasticFast.GraphD.Last(2)<BottomLevel) then
begin
// output the message that the Stochastic has crossed the Top Level
log ('the Stochastic on the 15-minute chart has crossed the Bottom Level bottom-up');
// if the %D line on the 1-hour chart is below the Bottom Level,
if StochasticSlow.GraphD.Last(1)<BottomLevel then
begin
// output the message into the log
log ('the Stochastic on the 1 hour chart is below the Bottom Level');
log ('Conditions for Buy position fulfilled. Position opened');
// open a Buy Position
CreateOrder(HistoryFast.Instrument, Account, Amount, bsBuy,
HistoryFast.Instrument.Sell - Point*Stop,
HistoryFast.Instrument.Sell + Point*Limit, TraderRange, 'MultiTrade');
end;
end;
end;
// this procedure runs when some changes occur in the Open Positions list
procedure OnTradeChange(const Action: TDataModificationType; const Trade: TTrade);
begin
// if a new trade opened
if Action=dmtInsert then
begin
// output the trade information into the log
log('Instrument: ' +Trade.Instrument.Name);
log('Account: ' +Trade.Account.Id);
log('Amount: ' +FloatToStr(Trade.Amount));
log('Open rate: ' +FloatToStr(Trade.OpenRate));
end;
end;
- 20-07-2011, 12:28 AM #2نحن ننتضر خبراء المبرمجين
تحياتي .