MT人工智能之二(4h CHF)
针对4小时图,USD/CHF
/*[[
Name := 4H_USDCHF
Author := Copyright ?2004, David W Honeywell
Link := [email protected]
Update on every tick := Yes
Enable Alerts := Yes
Disable alert once hit := No
Lots := 1.00
Stop Loss := 300
Take Profit := 500
Trailing Stop := 35
]]*/
If timeyear(time)<2004 Then Exit;
If Abs(H-L)<(15*Point)Then Exit;
If FreeMargin<1000 Then Exit;
If TrailingStop<5 Then{
print("Invalid trailing stop");Exit;};
Defines: slippage(5),mm(0),risk(10);
Var: trd(0),tst(0),lotsi(0);
Var: a1(0),b1(0),askb(0),bids(0);
Var: prvo(0),prvc(0),prvh(0),prvl(0);
Var: med(0),med1(0);
a1=Ask+5*Point;
b1=Bid-5*Point;
askb=Ask+10*Point;
bids=Bid-10*Point;
prvo=Open[1];
prvc=Close[1];
prvh=High[1];
prvl=Low[1];
med=(H+L)/2;
med1=(H[1]+L[1])/2;
If mm<>0 Then{
lotsi=Ceil(Balance*Risk/10000)/10;
If lotsi>1 Then{
lotsi=Ceil(lotsi);};
If lotsi>100 Then{
lotsi=100;}}
Else{lotsi=Lots;};
If TotalTrades<1 Then{
If (b1<L)Then{
SetOrder(OP_SELLSTOP,lotsi,bids,slippage,bids+stoploss*point,bids-takeprofit*point,Gold);Exit;};
If (a1>H)Then{
SetOrder(OP_BUYSTOP,lotsi,askb,slippage,askb-stoploss*point,askb+takeprofit*point,white);Exit;};};
For trd=1 to totaltrades{
If (b1<L)Then{
If Ord(trd,VAL_SYMBOL)=Symbol and Ord(trd,VAL_TYPE)=OP_BUY Then
CloseOrder(Ord(trd,VAL_TICKET),Ord(trd,VAL_LOTS),Ord(trd,VAL_CLOSEPRICE),slippage,White)
Else If Ord(trd,VAL_TYPE)=OP_BUYSTOP Then
DeleteOrder(Ord(trd,VAL_TICKET),White);};
If (a1>H)Then{
If Ord(trd,VAL_SYMBOL)=Symbol and Ord(trd,VAL_TYPE)=OP_SELL Then
CloseOrder(Ord(trd,VAL_TICKET),Ord(trd,VAL_LOTS),Ord(trd,VAL_CLOSEPRICE),slippage,Gold)
Else If Ord(trd,VAL_TYPE)=OP_SELLSTOP Then
DeleteOrder(Ord(trd,VAL_TICKET),Gold);};};
For tst=1 to TotalTrades{
If Ord(tst,VAL_SYMBOL)=Symbol and Ord(tst,VAL_TYPE)=OP_BUY Then{
If Ord(tst,VAL_STOPLOSS)<(Bid-TrailingStop*Point) Then{
ModifyOrder(Ord(tst,VAL_TICKET),Ord(tst,VAL_OPENPRICE),
Bid-TrailingStop*Point,Ord(tst,VAL_TAKEPROFIT),White);Exit;};};
If Ord(tst,VAL_TYPE)=OP_SELL Then{
If Ord(tst,VAL_STOPLOSS)>(Ask+TrailingStop*Point) Or Ord(tst,VAL_STOPLOSS)=0 Then{
ModifyOrder(Ord(tst,VAL_TICKET),Ord(tst,VAL_OPENPRICE),
Ask+TrailingStop*Point,Ord(tst,VAL_TAKEPROFIT),Gold);Exit;};};};
// End
// Modified by trendless
// Last updated on 2004/09/14.
[此帖子已被 hilow 在 2004-9-27 2:45:28 编辑过]