6大币种1990年至2004年的测试图(改正版)
a.每次操作量为1手(1:100)
b.根据选汇条件及进场价位setorder().
c.止损100 point、止赢150 point,不采取跟踪止损。
d.当日获利小于150 point或亏损小于100 point时,次日开盘价必须closeorder()!
http://chenhj.sosoo.net/eurusd1990-2004.htm
http://chenhj.sosoo.net/gbpusd1990-2004.htm
http://chenhj.sosoo.net/audusd1990-2004.htm
http://chenhj.sosoo.net/usdchf1990-2004.htm
http://chenhj.sosoo.net/usdjpy1990-2004.htm
http://chenhj.sosoo.net/usdcad1990-2004.htm
[ 此消息由 chj0525 在 2004-05-11.09:31:31 编辑过 ]
3楼
事实证明外汇市场要比我国股市规范多了,一种有效的方法应该有效于全部外汇市场,我测试的其它交叉盘同样也有效.
你不是开玩笑吧,usd/jpy略有赢利做其他币种时都亏损,唯一的可能是你摸透了usd/jpy的脾性!jpy是最难凌驾的货币,有点类似我国股市,哎.....,东亞人都差不多!
概率游戏的法则就是见好就收,别玩什么理论。
发表于:2004-05-12 10:06只看该作者
10楼
我公布给大家看吧反正我也不会真抄汇
Name := zcz1955
Author := Copyright ?2002, MetaQuotes Software Corp
Link :=http://www.metaquotes.ru
Notes :=
Lots := 1
Stop Loss := 0
Take Profit := 80
Trailing Stop := 30
]]*/
defines: Slippage(2),MAFastPeriod(16),MASlowPeriod(60);
var: cnt(0),mode(0);
var: FastMa(0),FastMa2(0),FastMa5(0);
var: SlowMa(0),SlowMa2(0),SlowMa5(0);
If Bars<200 or TakeProfit<10 or TrailingStop<10 then Exit;
// setup values
FastMa=iMA(MAFastPeriod,MODE_EMA,0);
FastMa2=iMA(MAFastPeriod,MODE_EMA,2);
FastMa5=iMA(MAFastPeriod,MODE_EMA,5);
SlowMa=iMA(MASlowPeriod,MODE_EMA,0);
SlowMa2=iMA(MASlowPeriod,MODE_EMA,2);
SlowMa5=iMA(MASlowPeriod,MODE_EMA,5);
// if there are no open positions and orders
If TotalTrades<1 then
{
If FreeMargin<1000 then Exit;// not enough money
// there are no open positions - check the BUY option
// the opening condition:
// if EMA(16) crosses EMA(60) upwards
// and the current bar is bullish (Close>Open), we place
// waiting order BUY LIMIT 15 pips below the execution
// price for more optimal entering into the market
// If FastMa>SlowMa and FastMa2<SlowMa2 and FastMa5<SlowMa5 and Close>Open then
If (FastMa-SlowMa)>=Point and (SlowMa2-FastMa2)>=Point and (SlowMa5-FastMa5)>=Point and Close>Open then
{
// try to place a waiting order at the (Ask-15) points price
// with maximum slippage 2 points,
// while not settingStop Loss and setting Take Profit
// 40 points above the opening price.
// at the chart an upward green arrow appears
SetOrder(OP_BUYLIMIT,Lots,Ask-15*Point,Slippage,0,Ask+(TakeProfit-10)*Point,RED);
Exit; // now we exit as we are not allowed to operate the account in the nearest 10 sec
};
// the opening SELL condition:
// if EMA(16) crosses EMA(60) downwards
// and the current bar is bearish (Close<Open), than we place
// a waiting order SELL LIMIT 15 points above
// the execution price for more optimal entering the market
If (SlowMa-FastMa)>=Point and (FastMa2-SlowMa2)>=Point and (FastMa5-SlowMa5)>=Point and Close<Open then
{
// try to place 1 lot order at Bid+15 points price
// with 2 points maximum slippage,
// when not settingStop Loss and settingTake Profit
// 40 points below opening price.
// on the chart the downward red arrow will appear
SetOrder(OP_SELLLIMIT,Lots,Bid+15*Point,Slippage,0,Bid-(TakeProfit-10)*Point,RED);
Exit;
};
// all we need to check in the empty terminal
// we have checked already, now we exit
Exit;
};
// here is the code of checking of the positions opened earlier
// (the placed orders will be checked
// in the other block, now we check the already opened positions)
for cnt=1 to TotalTrades
{
mode=Ordervalue(cnt,VAL_TYPE);
If mode=OP_BUY then // if the already opened position were BUY
{
// lets check if EMA(16) has crossed EMA(60) downwards?
If iMA(MAFastPeriod,MODE_EMA,0) < iMA(MASlowPeriod,MODE_EMA,0) and
iMA(MAFastPeriod,MODE_EMA,2) > iMA(MASlowPeriod,MODE_EMA,2) and
iMA(MAFastPeriod,MODE_EMA,5) > iMA(MASlowPeriod,MODE_EMA,5) then
{
// try to close the position at current Bid price
CloseOrder(Ordervalue(cnt,VAL_TICKET),Ordervalue(cnt,VAL_LOTS),Bid,Slippage,RED);
Exit;
};
// Here we check the trailing stop at open position.
// Trailing stop ( Stop Loss) of the BUY position is being
// kept at level 20 points below the market.
// If the profit (current Bid-OpenPrice) more than TrailingStop (20) pips
If (Bid-Ordervalue(cnt,VAL_OPENPRICE))>(TrailingStop*Point) then
{
// we have won already not less than 'TrailingStop' pips!
If Ordervalue(cnt,VAL_STOPLOSS)<(Bid-TrailingStop*Point) then
{
// move the trailing stop (Stop Loss) to the level 'TrailingStop' from the market
ModifyOrder(Ordervalue(cnt,VAL_TICKET),Ordervalue(cnt,VAL_OPENPRICE),
Bid-Point*TrailingStop,Ordervalue(cnt,VAL_TAKEPROFIT),Red);
Exit;
};
};
};
If mode=OP_SELL then // if the already opened position were SELL
{
// check if EMA(16) has crossed already EMA(60) upwards?
If iMA(MAFastPeriod,MODE_EMA,0) > iMA(MASlowPeriod,MODE_EMA,0) and
iMA(MAFastPeriod,MODE_EMA,2) < iMA(MASlowPeriod,MODE_EMA,2) and
iMA(MAFastPeriod,MODE_EMA,5) < iMA(MASlowPeriod,MODE_EMA,5) then
{
// try to close the position at current Ask price
CloseOrder(Ordervalue(cnt,VAL_TICKET),Ordervalue(cnt,VAL_LOTS),Ask,Slippage,RED);
Exit;
};
// Here we check the trailing stop at open position.
// Trailing stop ( Stop Loss) of the BUY position is being
// kept at level 20 points below the market.
// If the profit (current Bid-OpenPrice) more than TrailingStop (20) pips
If (Ordervalue(cnt,VAL_OPENPRICE)-Ask)>(TrailingStop*Point) then
{
// we have won already not less than 'TrailingStop' pips!
If Ordervalue(cnt,VAL_STOPLOSS)>(Ask+TrailingStop*Point) or
Ordervalue(cnt,VAL_STOPLOSS)=0 then
{
// move the trailing stop (Stop Loss) to the level 'TrailingStop' from the market
ModifyOrder(Ordervalue(cnt,VAL_TICKET),Ordervalue(cnt,VAL_OPENPRICE),
Ask+Point*TrailingStop,Ordervalue(cnt,VAL_TAKEPROFIT),Red);
Exit;
};
};
};
// there is one very important point - the control
// over the waiting orders.An order cannot be valid more than 0.5 hour.
// After which It should be canceled
// For that purpose we compare current time
// and time the order is placed
If mode>OP_SELL then// this is a waiting order!
{
// check how long it exists in the trading terminal
// time is counted in seconds:
// 10 minutes = 600 seconds, 30 minutes = 1800, 1 hour = 3600, 1 day = 86400
If (CurTime-Ordervalue(cnt,VAL_OPENTIME))>1800 then
{
DeleteOrder(Ordervalue(cnt,VAL_TICKET),RED);
Exit;
};
};
};
// the end



韬客外汇论坛TALKFOREX.COM
发表于:2004-05-12 10:12只看该作者
4楼
另外我想问问象在setorder中设立了止损后又在程序开头stoploss中设置止损,以哪个为准呢

韬客外汇论坛TALKFOREX.COM
12楼
以setorder()为准!一般setorder()中的止损、止赢参数单位都是以具体价位price(比如1.1683等)值为准,而程序开头stop loss,Take Profit则是以points点作为单位,需要换算,你的程序不是已在换算了吗?
根据你提的问题,可能你还没彻底摸透你自己上面的代码,再仔细看一下!我有空也帮你瞧一瞧,这几天忙于公司系统打补丁,“震荡波”太厉害了,今天又出现了F变种! [ 此消息由 chj0525 在 2004-05-12.19:37:13 编辑过 ]
概率游戏的法则就是见好就收,别玩什么理论。
发表于:2004-05-13 03:57只看该作者
8楼
有个问题,就是max drawdown,必须注意的是它所标注的亏损比例是按照你从最高点(即开始最大亏损的地方)开始计算,所以以你的欧元为例,最大亏损2020,亏损比例为3.8%,但是如果你从3000圆的本金刚好从那个位置开始交易,那么实际的亏损就是2020/3000,大约65%,这一点很重要,因为你不能保证你开始交易的地方就是资金曲线的最低点。
发表于:2004-05-13 04:03只看该作者
5楼
我把zcz1955兄的代码拷到我的机器上测试,怎么没有结果呀。一次成交也没有,报告栏也是空的。
天下熙熙,皆为利来;天下攘攘,皆为利往。
发表于:2004-05-13 04:09只看该作者
6楼
你的交易系统全面性较好,我的只有欧元盈利很好,其余的都一般(chf 150%, JPY 90%gbp 60%),我的环境是,小时图,每次只作1 lot,不平仓就不作新单,时间是从2003年2月到今年5月初.我修改后的测试,欧元最大亏损在1500美金。
发表于:2004-05-13 10:07只看该作者
7楼
有啊你再试试 /*[[ Name := zcz1955 Author := Copyright ?2004, MetaQuotes Software Corp. Link := http://www.metaquotes.net/ Lots := 1.00 Stop Loss := 0 Take Profit := 80 Trailing Stop := 30 ]]*/ defines: Slippage(2),MAFastPeriod(16),MASlowPeriod(60); var: cnt(0),mode(0); var: FastMa(0),FastMa2(0),FastMa5(0); var: SlowMa(0),SlowMa2(0),SlowMa5(0); If Bars<200 or TakeProfit<10 or TrailingStop<10 then Exit; // setup values FastMa=iMA(MAFastPeriod,MODE_EMA,0); FastMa2=iMA(MAFastPeriod,MODE_EMA,2); FastMa5=iMA(MAFastPeriod,MODE_EMA,5); SlowMa=iMA(MASlowPeriod,MODE_EMA,0); SlowMa2=iMA(MASlowPeriod,MODE_EMA,2); SlowMa5=iMA(MASlowPeriod,MODE_EMA,5); // if there are no open positions and orders If TotalTrades<1 then { If FreeMargin<1000 then Exit;// not enough money // there are no open positions - check the BUY option // the opening condition: // if EMA(16) crosses EMA(60) upwards // and the current bar is bullish (Close>Open), we place // waiting order BUY LIMIT 15 pips below the execution // price for more optimal entering into the market // If FastMa>SlowMa and FastMa2<SlowMa2 and FastMa5<SlowMa5 and Close>Open then If (FastMa-SlowMa)>=Point and (SlowMa2-FastMa2)>=Point and (SlowMa5-FastMa5)>=Point and Close>Open then { // try to place a waiting order at the (Ask-15) points price // with maximum slippage 2 points, // while not settingStop Loss and setting Take Profit // 40 points above the opening price. // at the chart an upward green arrow appears SetOrder(OP_BUYLIMIT,Lots,Ask-15*Point,Slippage,0,Ask+(TakeProfit-10)*Point,RED); Exit; // now we exit as we are not allowed to operate the account in the nearest 10 sec }; // the opening SELL condition: // if EMA(16) crosses EMA(60) downwards // and the current bar is bearish (Close<Open), than we place // a waiting order SELL LIMIT 15 points above // the execution price for more optimal entering the market If (SlowMa-FastMa)>=Point and (FastMa2-SlowMa2)>=Point and (FastMa5-SlowMa5)>=Point and Close<Open then { // try to place 1 lot order at Bid+15 points price // with 2 points maximum slippage, // when not settingStop Loss and settingTake Profit // 40 points below opening price. // on the chart the downward red arrow will appear SetOrder(OP_SELLLIMIT,Lots,Bid+15*Point,Slippage,0,Bid-(TakeProfit-10)*Point,RED); Exit; }; // all we need to check in the empty terminal // we have checked already, now we exit Exit; }; // here is the code of checking of the positions opened earlier // (the placed orders will be checked // in the other block, now we check the already opened positions) for cnt=1 to TotalTrades { mode=Ordervalue(cnt,VAL_TYPE); If mode=OP_BUY then // if the already opened position were BUY { // lets check if EMA(16) has crossed EMA(60) downwards? If iMA(MAFastPeriod,MODE_EMA,0) < iMA(MASlowPeriod,MODE_EMA,0) and iMA(MAFastPeriod,MODE_EMA,2) > iMA(MASlowPeriod,MODE_EMA,2) and iMA(MAFastPeriod,MODE_EMA,5) > iMA(MASlowPeriod,MODE_EMA,5) then { // try to close the position at current Bid price CloseOrder(Ordervalue(cnt,VAL_TICKET),Ordervalue(cnt,VAL_LOTS),Bid,Slippage,RED); Exit; }; // Here we check the trailing stop at open position. // Trailing stop ( Stop Loss) of the BUY position is being // kept at level 20 points below the market. // If the profit (current Bid-OpenPrice) more than TrailingStop (20) pips If (Bid-Ordervalue(cnt,VAL_OPENPRICE))>(TrailingStop*Point) then { // we have won already not less than 'TrailingStop' pips! If Ordervalue(cnt,VAL_STOPLOSS)<(Bid-TrailingStop*Point) then { // move the trailing stop (Stop Loss) to the level 'TrailingStop' from the market ModifyOrder(Ordervalue(cnt,VAL_TICKET),Ordervalue(cnt,VAL_OPENPRICE), Bid-Point*TrailingStop,Ordervalue(cnt,VAL_TAKEPROFIT),Red); Exit; }; }; }; If mode=OP_SELL then // if the already opened position were SELL { // check if EMA(16) has crossed already EMA(60) upwards? If iMA(MAFastPeriod,MODE_EMA,0) > iMA(MASlowPeriod,MODE_EMA,0) and iMA(MAFastPeriod,MODE_EMA,2) < iMA(MASlowPeriod,MODE_EMA,2) and iMA(MAFastPeriod,MODE_EMA,5) < iMA(MASlowPeriod,MODE_EMA,5) then { // try to close the position at current Ask price CloseOrder(Ordervalue(cnt,VAL_TICKET),Ordervalue(cnt,VAL_LOTS),Ask,Slippage,RED); Exit; }; // Here we check the trailing stop at open position. // Trailing stop ( Stop Loss) of the BUY position is being // kept at level 20 points below the market. // If the profit (current Bid-OpenPrice) more than TrailingStop (20) pips If (Ordervalue(cnt,VAL_OPENPRICE)-Ask)>(TrailingStop*Point) then { // we have won already not less than 'TrailingStop' pips! If Ordervalue(cnt,VAL_STOPLOSS)>(Ask+TrailingStop*Point) or Ordervalue(cnt,VAL_STOPLOSS)=0 then { // move the trailing stop (Stop Loss) to the level 'TrailingStop' from the market ModifyOrder(Ordervalue(cnt,VAL_TICKET),Ordervalue(cnt,VAL_OPENPRICE), Ask+Point*TrailingStop,Ordervalue(cnt,VAL_TAKEPROFIT),Red); Exit; }; }; }; // there is one very important point - the control // over the waiting orders.An order cannot be valid more than 0.5 hour. // After which It should be canceled // For that purpose we compare current time // and time the order is placed If mode>OP_SELL then// this is a waiting order! { // check how long it exists in the trading terminal // time is counted in seconds: // 10 minutes = 600 seconds, 30 minutes = 1800, 1 hour = 3600, 1 day = 86400 If (CurTime-Ordervalue(cnt,VAL_OPENTIME))>1800 then { DeleteOrder(Ordervalue(cnt,VAL_TICKET),RED); Exit; }; }; }; // the end
原文由 SAXO 发表: 我把zcz1955兄的代码拷到我的机器上测试,怎么没有结果呀。一次成交也没有,报告栏也是空的。
发表于:2004-05-13 10:10只看该作者
2楼
那么高的赢利不错了,贴出来大家学习学习啊这也没什么好藏的啊
原文由 alan_txy 发表: 你的交易系统全面性较好,我的只有欧元盈利很好,其余的都一般(chf 150%, JPY 90%gbp 60%),我的环境是,小时图,每次只作1 lot,不平仓就不作新单,时间是从2003年2月到今年5月初.我修改后的测试,欧元最大亏损......


韬客外汇论坛TALKFOREX.COM
发表于:2004-05-13 14:09只看该作者
13楼
现在可以了,肯定是“]]*/”的问题,谢谢zcz1955兄。我现在也是有思路,编不成语言测试。
天下熙熙,皆为利来;天下攘攘,皆为利往。