因此,如果我希望 MQL4
中的EA采用开盘价并且当前价格比开盘价低10个点,则会下一个买入订单,当它高出10个点时把它卖掉了。每次只有一个订单,每天更改一次。
Q1:这怎么可能不受阻碍?
Q2:这甚至会盈利吗?
我知道有些人写这个很简单,但对我来说这很令人沮丧。
答案 0 :(得分:0)
MQL4
EA交易代码类型的执行主要可以不受限制地运行,假设执行引擎 MetaTrader Terminal 4 正在以不间断模式运行。虽然仍然有周末可用于服务和维护任务,EA代码本身可以无限长时间运行,具有自动重入安全重新启动自我保护(OnInit(){...} + OnDeinit(){...}
)。
#property copyright "Copyright © 1987-2016 [MS]"
#property link "nowhere.no"
#property version "0.00"
#property strict
extern int minDist2XTO = 10; // A minimum Distance To XTO
bool aGlobalMUTEX_LOCKED = False; // LOCK "only one order at a time"
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{ // on-launch intialisation tasks go here:
return( INIT_SUCCEEDED );
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit( const int reason )
{ // pre-exit sanitisation tasks go here:
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{ // MAIN: this is being executed upon each anFxMarketEVENT's arrival
// GoLONG();
// GoSHORT();
}
//+------------------------------------------------------------------+
//| Tester function |
//+------------------------------------------------------------------+
double OnTester()
{ // back-testing utility calculation functions go here:
double retVal = 0.0;
return( retVal );
}
//+------------------------------------------------------------------+
void GoLONG()
{ // SELF-CONTROLLABLE ( might even get concurrently run in parallel to GoSHORT on dual resources )
// -------------------------------------------------------------------------------------------------------
static bool aNewBarEVENT = FALSE;
static int aLastBAR = EMPTY,
aCurrBAR = EMPTY;
static double GoLONG_LEVEL = EMPTY;
// -------------------------------------------------------------------------------------------------------
// TEST A STATE-SHIFT
RefreshRates();
aCurrBAR = iBars(_Symbol, PERIOD_D1 );
if ( aLastBAR != aCurrBAR )
{ aLastBAR = aCurrBAR; // .SET
aNewBarEVENT = TRUE; // .FLAG
// ----------------------- // .RESET in-BAR-registers
GoLONG_LEVEL = NormalizeDouble( iOpen( _Symbol, PERIOD_D1, 0 )
- minDist2XTO * _Point
);
// ----------------------
}
else
{ aNewBarEVENT = FALSE; // !FLAG
}
if ( !aGlobalMUTEX_LOCKED
&& Ask <= GoLONG_LEVEL
)
{
// XTO ... // .XTO
if ( success ) aGlobalMUTEX_LOCK = True;
}
}
//+------------------------------------------------------------------+
void GoSHORT()
{ // SELF-CONTROLLABLE ( might even get concurrently run in parallel to GoLONG on dual resources )
...
..
.
}
这个问题可以定量解决。您的交易想法可以在实际市场数据上进行测试和验证,以便提供合理数量的观察,支持或限制预期的业绩预期。
如果没有来自市场季节性不规范的足够TimeDOMAIN范围的定量数据,问题就无法得到合理支持的定量答案 (除了意见)< /子>
这远远超出了Q / A的StackOverflow格式,但原则上是回溯测试(支持 double OnTester(){...}
后处理设施的内置机制)并转发 - 在任何实际交易策略暴露于执行任何实际市场风险之前,测试(在模拟账户前向运行的支持下)都被用于量化建模。