|
|
|
Forum Newbie
      
Group: Forum Members
Last Login: 11/9/2010 11:49:09 PM
Posts: 7,
Visits: 84
|
|
Hello Every one,
I am a new here, and using the ACT Trader from Forex Club.
The following strategy is in the ACT Trader
I was trying it but I found that has problem. Would you guys please fix it for me. I am not a programmer. Thank you so much.
The problem is that ES EL orders could not cancel automatically when the position is closed. So if I was not in front of computer, it became very crazy. It accumulates a lot of ES or EL orders.
Please let the ES or EL automatically cancel when the position is closed.
Would you guys please kindly help me to fix it?
Thank you very so much. Have a nice day.
//==========================================================================================
// This strategy uses the MACD indicator. It opens a Buy position when the MACD rises above
// its Signal line, and a Sell position, when the MACD falls below its Signal line.
// It also outputs a message into the log when a position is opened.
//==========================================================================================
const
StrategyName = 'MACD_Strategy';
var //declaration of the variables
History: TCandleHistory;
Account: TAccount;
Amount, Point: Double;
Opposite_entry_stop, Opposite_entry_limit, TraderRange: Integer;
MACD: TIndicatorMACD;
procedure OnCreate;
begin
AddCandleHistorySetting(@History, 'History', '', 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(@Opposite_entry_stop, 'Opposite_entry_stop', 20); //setting up stop in pips
AddIntegerSetting(@Opposite_entry_limit, 'Opposite_entry_limit', 30); //setting up limit in pips
AddIntegerSetting(@TraderRange, 'Trader Range', 0); //setting up the trader range in pips
MACD := TIndicatorMACD.Create(History, 'MACD'); //creating the MACD indicator
MACD.PeriodShorterEMA := 12;
MACD.PeriodLongerEMA := 26;
MACD.PeriodForSignal := 9; //setting up the MACD indicator periods
end;
// this procedure runs when a new candle opens
procedure OnNewCandle;
begin
Point := History.Instrument.PointSize;
// if the MACD rises above its Signal line
if (MACD.Graph.Last(1) > MACD.SignalGraph.Last(1))
and (MACD.Graph.Last(2) < MACD.SignalGraph.Last(2)) then
begin
// output the message into the log
log ('The MACD crossed the Signal line bottom-up. A Buy position opened.');
// open a Buy position
CreateOrder(History.Instrument, Account, Amount, bsBuy,
NullRate, NullRate, TraderRange, 'MACDTrade');
CreateEntryOrder(History.Instrument, Account, Amount, bsSell,
History.Instrument.Sell - Point*Opposite_entry_stop,
NullRate, NullRate,
otEStop,'EntryStopSell');
CreateEntryOrder(History.Instrument, Account, Amount, bsSell,
History.Instrument.Sell + Point*Opposite_entry_limit,
NullRate, NullRate,
otELimit,'EntryLimitSell');
end;
// if the MACD falls below its Signal line
if (MACD.Graph.Last(1) < MACD.SignalGraph.Last(1))
and (MACD.Graph.Last(2) > MACD.SignalGraph.Last(2)) then
begin
// output the message into the log
log ('The MACD crossed the Signal line top-down. A Sell position opened.');
// open a Sell position
CreateOrder(History.Instrument, Account, Amount, bsSell,
NullRate, NullRate, TraderRange, 'MACDTrade');
CreateEntryOrder(History.Instrument, Account, Amount, bsBuy,
History.Instrument.Buy + Point*Opposite_entry_stop,
NullRate, NullRate,
otEStop,'EntryStopSell');
CreateEntryOrder(History.Instrument, Account, Amount, bsBuy,
History.Instrument.Buy - Point*Opposite_entry_limit,
NullRate, NullRate,
otELimit,'EntryLimitSell');
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;
procedure OnOrderChange(const Action: TDataModificationType; const Order: TOrder);
var i:integer;
begin
if Action=dmtDelete then
begin
for i:=orderlist.count-1 to 0 do
begin
if OrderList.Count>0 then orderlist.get(i).Remove;
end;
end;
end;
Edited: 8/29/2010 9:34:16 PM by ntsai
|
|
|
|
|
Administrator
Group: Administrators
Last Login: 2/7/2012 9:02:20 AM
Posts: 245,
Visits: 1,220
|
|
|
|
|
|
Forum Newbie
      
Group: Forum Members
Last Login: 11/9/2010 11:49:09 PM
Posts: 7,
Visits: 84
|
|
Thank you so much.
Could you please explain what is the NFA rule?
if there is limitation, how can we trade freely? sounds not fair to trade...
do you know there is any other plate form or software can trade freely?
Thank you so much~
|
|
|
|