问题描述
因此,如果我想要一个在 MQL4
中的EA接受开盘价,并且当当前价格比开盘价低10个点时,它会下达买入订单,而当它比开盘价高10个点时,卖.一次只能下一个订单,并且每天都会更改开盘价.
So if I wanted an EA in MQL4
that took the open price and when current price was 10 pips below the open it places a buy order and when it was 10 pips above the open it sold. Only one order at a time and the open changed daily.
第一季度:如何持续运行?
第二季度:甚至还能盈利吗?
我知道这对于某些人来说很简单,但是对我来说却令人沮丧.
I know this is simple for some people to write but for me it's depressing.
推荐答案
A1:
MQL4
的代码执行基本上可以不间断地运行,假设执行引擎为 type-of-code's execution can be principally run unstopped, supposing the execution engine, the , is being run in a nonstop mode. While there still remain the weekends available for service & maintenance tasks, the EA code, per se can be operated infinitely long, state-fully with an automated re-entrant safe re-launch self-protection ( 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 )
...
..
.
}
A2:
这个问题可以定量地解决.您的交易想法可以在真实市场数据上进行测试和验证,以便提供合理数量的观察结果,以支持或限制预期的业绩预期.
A2:
This question can be addressed quantitatively. Your trading idea can be tested and validated on the real-market data, so as to provide a reasonable amount of observations that either support or limit the expected performance expectations.
如果没有足够的TimeDOMAIN市场季节性违规行为的定量数据,则该问题无法得到合理支持的定量答案 .
Without quantitative data from adequate TimeDOMAIN span of the market seasonality irregularities, the question cannot have a reasonably supported quantitative answer .
这远远超出了Q/A的StackOverflow格式,但原则上是回测(支持 double OnTester(){...}
后处理工具的内置机制)和正向测试(在有模拟账户远期运行的支持下)都可以在进行任何实际交易策略执行任何实际市场风险之前用于量化建模.
This goes far beyond a StackOverflow format of Q/A, but in principle back-testing ( with a support of an inbuilt mechanism of double OnTester(){...}
post-processing facility ) and forward-testing ( with a support of demo-account forward runs ) are both being used in quant modelling, before any real trading strategy is ever exposed to execute any real market-risk.
这篇关于在[MQL4]中编写专家顾问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!