I have a EA with indicators that I want to mix and optimize it in BackTest.
//some sample data for signal for In/Out states only for exemplification iT_InOut = IN_OUT; //Itrend usage => In & Out RSI_InOut = IN_; //RSI usage =>only IN MFI_InOut = OUT_; //MFI usage =>only OUT //
//this is the complete sequence IF I USE all signals in+out //only to show the completly sequence (I will not use it) m_buy=(m_it00[0]>m_it10[0] && m_it00[0]>m_it01[0] && m_rsi0[0]>m_rsi1[0] && m_mfi0[0]>m_mfi1[0]); // The green is growing and more than red, RSI is growing, MFI is growing m_sell=(m_it00[0]<m_it10[0] && m_it00[0]<m_it01[0] && m_rsi0[0]<m_rsi1[0] && m_mfi0[0]<m_mfi1[0]); // The green falls and less than red, RSI falls, MFI falls
//now the skeleton that I'm trying to make work (in future I will use much more indicators)
if(!PositionSelect(Symbol())) ///No opened it's first entrance {
if (!iT_InOut==OUT_) //Itrend (only options with IN) { m_buy= (m_buy && m_it00[0]>m_it10[0] && m_it00[0]>m_it01[0]); m_sell=(m_sell && m_it00[0]<m_it10[0] && m_it00[0]<m_it01[0]); }
if (!RSI_InOut==OUT_) //RSI (only options with IN) { m_buy =(m_buy && m_rsi0[0]>m_rsi1[0]); m_sell=(m_sell && m_rsi0[0]<m_rsi1[0]); }
if (!MFI_InOut==OUT_) //MFI (only options with IN) { m_buy =(m_buy && m_mfi0[0]>m_mfi1[0]); m_sell=(m_sell && m_mfi0[0]<m_mfi1[0]); } }
///We have opened order it's EXIT else { //Itrend (only options with EXIT) if (!iT_InOut==IN_) { m_buy =(m_buy && m_it00[0]>m_it10[0] && m_it00[0]>m_it01[0]); m_sell=(m_sell && m_it00[0]<m_it10[0] && m_it00[0]<m_it01[0]); } //RSI (only options with EXIT) if (!RSI_InOut==IN_) { m_buy =(m_buy && m_rsi0[0]>m_rsi1[0]); m_sell=(m_sell && m_rsi0[0]<m_rsi1[0]); } //MFI (only options with EXIT) if (!MFI_InOut==IN_) { m_buy =(m_buy && m_mfi0[0]>m_mfi1[0]); m_sell=(m_sell && m_mfi0[0]<m_mfi1[0]); } }
I have a EA with indicators that I want to mix and optimize it in BackTest.
//some sample data for signal for In/Out states only for exemplification iT_InOut = IN_OUT; //Itrend usage => In & Out RSI_InOut = IN_; //RSI usage =>only IN MFI_InOut = OUT_; //MFI usage =>only OUT //
//this is the complete sequence IF I USE all signals in+out //only to show the completly sequence (I will not use it) m_buy=(m_it00[0]>m_it10[0] && m_it00[0]>m_it01[0] && m_rsi0[0]>m_rsi1[0] && m_mfi0[0]>m_mfi1[0]); // The green is growing and more than red, RSI is growing, MFI is growing m_sell=(m_it00[0]<m_it10[0] && m_it00[0]<m_it01[0] && m_rsi0[0]<m_rsi1[0] && m_mfi0[0]<m_mfi1[0]); // The green falls and less than red, RSI falls, MFI falls
//now the skeleton that I'm trying to make work (in future I will use much more indicators)
if(!PositionSelect(Symbol())) ///No opened it's first entrance {
if (!iT_InOut==OUT_) //Itrend (only options with IN) { m_buy= (m_buy && m_it00[0]>m_it10[0] && m_it00[0]>m_it01[0]); m_sell=(m_sell && m_it00[0]<m_it10[0] && m_it00[0]<m_it01[0]); }
if (!RSI_InOut==OUT_) //RSI (only options with IN) { m_buy =(m_buy && m_rsi0[0]>m_rsi1[0]); m_sell=(m_sell && m_rsi0[0]<m_rsi1[0]); }
if (!MFI_InOut==OUT_) //MFI (only options with IN) { m_buy =(m_buy && m_mfi0[0]>m_mfi1[0]); m_sell=(m_sell && m_mfi0[0]<m_mfi1[0]); } }
///We have opened order it's EXIT else { //Itrend (only options with EXIT) if (!iT_InOut==IN_) { m_buy =(m_buy && m_it00[0]>m_it10[0] && m_it00[0]>m_it01[0]); m_sell=(m_sell && m_it00[0]<m_it10[0] && m_it00[0]<m_it01[0]); } //RSI (only options with EXIT) if (!RSI_InOut==IN_) { m_buy =(m_buy && m_rsi0[0]>m_rsi1[0]); m_sell=(m_sell && m_rsi0[0]<m_rsi1[0]); } //MFI (only options with EXIT) if (!MFI_InOut==IN_) { m_buy =(m_buy && m_mfi0[0]>m_mfi1[0]); m_sell=(m_sell && m_mfi0[0]<m_mfi1[0]); } }
//---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int limit, i, counter; double fasterEMA1now, slowerEMA1now, fasterEMA1previous, slowerEMA1previous, fasterEMA2now, slowerEMA2now, fasterEMA2previous, slowerEMA2previous; double RSInow; double Range, AvgRange;
int counted_bars=IndicatorCounted(); //---- check for possible errors if(counted_bars<0) return(-1); //---- last counted bar will be recounted if(counted_bars>0) counted_bars--;
limit=MathMin(Bars-counted_bars,barsBack);
for(i = limit; i>=0; i--) {
counter=i; Range=0; AvgRange=0; for (counter=i ;counter<=i+9;counter++) { AvgRange=AvgRange+MathAbs(High[counter]-Low[counter]); } Range=AvgRange/10;
嗨,Mladen。
我正在尝试在MT5中编写这个代码,但我认为我没有使用正确的实现方式。
我的想法是使用更多的指标,请给我一个提示...;-)
this is a sample to understand I'm trying to do..
in this sample:
I put only 3 indicadors.
//global variables
bool m_buy = true;
bool m_sell = true;
enum Signal{
IN_OUT=0, //in & out
IN=1, //in
OUT=2, //out
};
I have a EA with indicators that I want to mix and optimize it in BackTest.
//some sample data for signal for In/Out states only for exemplification
iT_InOut = IN_OUT; //Itrend usage => In & Out
RSI_InOut = IN_; //RSI usage =>only IN
MFI_InOut = OUT_; //MFI usage =>only OUT
//
//this is the complete sequence IF I USE all signals in+out
//only to show the completly sequence (I will not use it)
m_buy=(m_it00[0]>m_it10[0] && m_it00[0]>m_it01[0] && m_rsi0[0]>m_rsi1[0] && m_mfi0[0]>m_mfi1[0]);
// The green is growing and more than red, RSI is growing, MFI is growing
m_sell=(m_it00[0]<m_it10[0] && m_it00[0]<m_it01[0] && m_rsi0[0]<m_rsi1[0] && m_mfi0[0]<m_mfi1[0]);
// The green falls and less than red, RSI falls, MFI falls
//now the skeleton that I'm trying to make work (in future I will use much more indicators)
if(!PositionSelect(Symbol())) ///No opened it's first entrance
{
if (!iT_InOut==OUT_) //Itrend (only options with IN)
{
m_buy= (m_buy && m_it00[0]>m_it10[0] && m_it00[0]>m_it01[0]);
m_sell=(m_sell && m_it00[0]<m_it10[0] && m_it00[0]<m_it01[0]);
}
if (!RSI_InOut==OUT_) //RSI (only options with IN)
{
m_buy =(m_buy && m_rsi0[0]>m_rsi1[0]);
m_sell=(m_sell && m_rsi0[0]<m_rsi1[0]);
}
if (!MFI_InOut==OUT_) //MFI (only options with IN)
{
m_buy =(m_buy && m_mfi0[0]>m_mfi1[0]);
m_sell=(m_sell && m_mfi0[0]<m_mfi1[0]);
}
}
///We have opened order it's EXIT
else
{
//Itrend (only options with EXIT)
if (!iT_InOut==IN_)
{
m_buy =(m_buy && m_it00[0]>m_it10[0] && m_it00[0]>m_it01[0]);
m_sell=(m_sell && m_it00[0]<m_it10[0] && m_it00[0]<m_it01[0]);
}
//RSI (only options with EXIT)
if (!RSI_InOut==IN_)
{
m_buy =(m_buy && m_rsi0[0]>m_rsi1[0]);
m_sell=(m_sell && m_rsi0[0]<m_rsi1[0]);
}
//MFI (only options with EXIT)
if (!MFI_InOut==IN_)
{
m_buy =(m_buy && m_mfi0[0]>m_mfi1[0]);
m_sell=(m_sell && m_mfi0[0]<m_mfi1[0]);
}
}
嗨,Mladen。
我正在尝试在MT5中编写这个代码,但我认为我没有使用正确的实现方式。
我的想法是使用更多的指标,请给我一个提示...;-)
this is a sample to understand I'm trying to do..
in this sample:
I put only 3 indicadors.
//global variables
bool m_buy = true;
bool m_sell = true;
enum Signal{
IN_OUT=0, //in & out
IN=1, //in
OUT=2, //out
};
I have a EA with indicators that I want to mix and optimize it in BackTest.
//some sample data for signal for In/Out states only for exemplification
iT_InOut = IN_OUT; //Itrend usage => In & Out
RSI_InOut = IN_; //RSI usage =>only IN
MFI_InOut = OUT_; //MFI usage =>only OUT
//
//this is the complete sequence IF I USE all signals in+out
//only to show the completly sequence (I will not use it)
m_buy=(m_it00[0]>m_it10[0] && m_it00[0]>m_it01[0] && m_rsi0[0]>m_rsi1[0] && m_mfi0[0]>m_mfi1[0]);
// The green is growing and more than red, RSI is growing, MFI is growing
m_sell=(m_it00[0]<m_it10[0] && m_it00[0]<m_it01[0] && m_rsi0[0]<m_rsi1[0] && m_mfi0[0]<m_mfi1[0]);
// The green falls and less than red, RSI falls, MFI falls
//now the skeleton that I'm trying to make work (in future I will use much more indicators)
if(!PositionSelect(Symbol())) ///No opened it's first entrance
{
if (!iT_InOut==OUT_) //Itrend (only options with IN)
{
m_buy= (m_buy && m_it00[0]>m_it10[0] && m_it00[0]>m_it01[0]);
m_sell=(m_sell && m_it00[0]<m_it10[0] && m_it00[0]<m_it01[0]);
}
if (!RSI_InOut==OUT_) //RSI (only options with IN)
{
m_buy =(m_buy && m_rsi0[0]>m_rsi1[0]);
m_sell=(m_sell && m_rsi0[0]<m_rsi1[0]);
}
if (!MFI_InOut==OUT_) //MFI (only options with IN)
{
m_buy =(m_buy && m_mfi0[0]>m_mfi1[0]);
m_sell=(m_sell && m_mfi0[0]<m_mfi1[0]);
}
}
///We have opened order it's EXIT
else
{
//Itrend (only options with EXIT)
if (!iT_InOut==IN_)
{
m_buy =(m_buy && m_it00[0]>m_it10[0] && m_it00[0]>m_it01[0]);
m_sell=(m_sell && m_it00[0]<m_it10[0] && m_it00[0]<m_it01[0]);
}
//RSI (only options with EXIT)
if (!RSI_InOut==IN_)
{
m_buy =(m_buy && m_rsi0[0]>m_rsi1[0]);
m_sell=(m_sell && m_rsi0[0]<m_rsi1[0]);
}
//MFI (only options with EXIT)
if (!MFI_InOut==IN_)
{
m_buy =(m_buy && m_mfi0[0]>m_mfi1[0]);
m_sell=(m_sell && m_mfi0[0]<m_mfi1[0]);
}
}
大家好。
我真的需要帮助,我正在用waddah attar scalping指标建立一个专家,逻辑是有效的,一切都很好。
除了一件事,正如你在回测截图中看到的,在每个绿柱子上,专家都会开出一个买盘,红柱子也一样。我希望每个颜色变化只有一个交易。
我想要的是:
我希望每个颜色变化只有一个交易。
以下是我的代码。(做空也是如此)
bool SendLong = false, SendShort = false;
double clnowsell = iCustom(Symbol(),WAScalpingTimeFrame,"Waddah_Attar_Scalping",IPeriod,P1,P2,1,clbar);
double clpresell = iCustom(Symbol(),WAScalpingTimeFrame,"Waddah_Attar_Scalping",IPeriod,P1,P2,1,clbar+1);
double clnowbuy = iCustom(Symbol(),WAScalpingTimeFrame,"Waddah_Attar_Scalping",IPeriod,P1,P2,0,clbar);
double clprebuy = iCustom(Symbol(),WAScalpingTimeFrame,"Waddah_Attar_Scalping",IPeriod,P1,P2,0,clbar+1);
//Long trade
//Specific system filters
//if (some condition) SendLong = true;
if (clnowbuy > 0) SendLong = true;
谁能提供一个简单的解决方案,请看第1265行,逻辑来自这里。
非常感谢!
大家好。
我真的需要帮助,我正在用waddah attar scalping指标建立一个专家,逻辑是有效的,一切都很好。
除了一件事,正如你在回测截图中看到的,在每个绿柱子上,专家都会开出一个买盘,红柱子也一样。我希望每个颜色变化只有一个交易。
我想要的是:
我希望每个颜色变化只有一个交易。
以下是我的代码。(做空也是如此)
bool SendLong = false, SendShort = false;
double clnowsell = iCustom(Symbol(),WAScalpingTimeFrame,"Waddah_Attar_Scalping",IPeriod,P1,P2,1,clbar);
double clpresell = iCustom(Symbol(),WAScalpingTimeFrame,"Waddah_Attar_Scalping",IPeriod,P1,P2,1,clbar+1);
double clnowbuy = iCustom(Symbol(),WAScalpingTimeFrame,"Waddah_Attar_Scalping",IPeriod,P1,P2,0,clbar);
double clprebuy = iCustom(Symbol(),WAScalpingTimeFrame,"Waddah_Attar_Scalping",IPeriod,P1,P2,0,clbar+1);
//Long trade
//Specific system filters
//if (some condition) SendLong = true;
if (clnowbuy > 0) SendLong = true;
谁能提供一个简单的解决方案,请看第1265行,逻辑来自这里。
非常感谢!
将条件改为
短裤的情况也一样
谢谢你 Mladen !
有时我们会被卡住,我们需要对我们的工作有一个新的看法。
再次感谢 !
谢谢你 Mladen !
有时我们会被卡住,我们需要对我们的工作有一个新的看法。
再次感谢 !
Bonjour,
Ravi de voir une Française, tiens moi au courant des tes résultats avec waddah attar;)
绿色的点子
大家好,我想编辑一个EMA-RSI指标,当4个EMA交叉发生且RSI>或<50时,可以显示一个向上或向下的箭头。
我的问题是,这些箭头一旦出现就 不会刷新,如果我想检查条件是否仍然良好以显示箭头,我需要改变时间框架。你能告诉我哪里有问题吗?我把代码贴出来了。
谢谢你
#property indicator_buffers 2
#property indicator_color1 Green
#property indicator_color2 Red
#property indicator_width1 4
#property indicator_width2 4
double CrossUp[];
double CrossDown[];
extern int FasterEMA1 = 6;
extern int SlowerEMA1 = 12;
extern int FasterEMA2 = 7;
extern int SlowerEMA2 = 14;
extern int RSInowPeriod = 6;
extern int barsBack = 2000;
extern bool AlertsMessage = true;
extern bool AlertsSound = true;
extern bool debug = false;
extern double K = 1.0 ;
bool EMACrossedUp = false;
bool RSICrossedUp = false;
bool EMACrossedDown = false;
bool RSICrossedDown = false;
int SignalLabeled = 0; // 0: initial state; 1: up; 2: down.
int upalert=false,downalert=false;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0, DRAW_ARROW, EMPTY);
SetIndexArrow(0, 241);
SetIndexBuffer(0, CrossUp);
SetIndexStyle(1, DRAW_ARROW, EMPTY);
SetIndexArrow(1, 242);
SetIndexBuffer(1, CrossDown);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start() {
int limit, i, counter;
double fasterEMA1now, slowerEMA1now, fasterEMA1previous, slowerEMA1previous, fasterEMA2now, slowerEMA2now, fasterEMA2previous, slowerEMA2previous;
double RSInow;
double Range, AvgRange;
int counted_bars=IndicatorCounted();
//---- check for possible errors
if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
limit=MathMin(Bars-counted_bars,barsBack);
for(i = limit; i>=0; i--) {
counter=i;
Range=0;
AvgRange=0;
for (counter=i ;counter<=i+9;counter++)
{
AvgRange=AvgRange+MathAbs(High[counter]-Low[counter]);
}
Range=AvgRange/10;
fasterEMA1now = iMA(NULL, 0, FasterEMA1, 0, MODE_EMA, PRICE_CLOSE, i);
fasterEMA1previous = iMA(NULL, 0, FasterEMA1, 0, MODE_EMA, PRICE_CLOSE, i+1);
fasterEMA2now = iMA(NULL, 0, FasterEMA2, 0, MODE_EMA, PRICE_CLOSE, i);
fasterEMA2previous = iMA(NULL, 0, FasterEMA2, 0, MODE_EMA, PRICE_CLOSE, i+1);
slowerEMA1now = iMA(NULL, 0, SlowerEMA1, 0, MODE_EMA, PRICE_CLOSE, i);
slowerEMA1previous = iMA(NULL, 0, SlowerEMA1, 0, MODE_EMA, PRICE_CLOSE, i+1);
slowerEMA2now = iMA(NULL, 0, SlowerEMA2, 0, MODE_EMA, PRICE_CLOSE, i);
slowerEMA2previous = iMA(NULL, 0, SlowerEMA2, 0, MODE_EMA, PRICE_CLOSE, i+1);
RSInow=iRSI(NULL,0,RSInowPeriod,PRICE_CLOSE,i);
if (RSInow > 50) {
if (debug)Print(TimeToStr(Time[i],TIME_DATE)+TimeToStr(Time[i],TIME_SECONDS)+" RSI UP ");
RSICrossedUp = true;
RSICrossedDown = false;
}
if (RSInow < 50) {
if (debug)Print(TimeToStr(Time[i],TIME_DATE)+TimeToStr(Time[i],TIME_SECONDS)+" RSI DOWN ");
RSICrossedUp = false;
RSICrossedDown = true;
}
if ((fasterEMA1now >= slowerEMA1now) && (fasterEMA1previous < slowerEMA1previous) && (fasterEMA2now >= slowerEMA2now) && (fasterEMA2previous < slowerEMA2previous) ) {
if (debug)Print(TimeToStr(Time[i],TIME_DATE)+TimeToStr(Time[i],TIME_SECONDS)+" EMA UP ");
EMACrossedUp = true;
EMACrossedDown = false;
}
if ((fasterEMA1now <= slowerEMA1now) && (fasterEMA1previous > slowerEMA1previous) && (fasterEMA2now <= slowerEMA2now) && (fasterEMA2previous > slowerEMA2previous)) {
if (debug)Print(TimeToStr(Time[i],TIME_DATE)+TimeToStr(Time[i],TIME_SECONDS)+" EMA DOWN ");
EMACrossedUp = false;
EMACrossedDown = true;
}
if ((EMACrossedUp == true) && (RSICrossedUp == true) && (SignalLabeled != 1)) {
CrossUp[i] = Low[i] - K*Range;
if (debug)Print(TimeToStr(Time[i],TIME_DATE)+TimeToStr(Time[i],TIME_SECONDS)+" SIGNAL UP ");
if(i<=2 && AlertsMessage && !upalert)
{
Alert (Symbol()," ",Period(),"M BUY SIGNAL ");
//SendMail("EMA Cross Up on "+Symbol(),"");
upalert=true;
downalert=false;
}
if(i<=2 && AlertsSound && !upalert)
{
PlaySound("alert.wav");
upalert=true;
downalert=false;
}
SignalLabeled = 1;
}
else if ((EMACrossedDown == true) && (RSICrossedDown == true) && (SignalLabeled != 2)) {
CrossDown[i] = High[i] + K*Range;
if (debug)Print(TimeToStr(Time[i],TIME_DATE)+TimeToStr(Time[i],TIME_SECONDS)+" SIGNAL DOWN ");
if(i<=2 && AlertsMessage && !downalert)
{
Alert (Symbol()," ",Period(),"M SELL SIGNAL ");
//SendMail("EMA Cross Down on "+Symbol(),"");
downalert=true;
upalert=false;
}
if(i<=2 && AlertsSound && !downalert)
{
PlaySound("alert.wav");
downalert=true;
upalert=false;
}
SignalLabeled = 2;
}
}
return(0);
}
//end
在那段代码中,我完全没有看到指标的使用(以及如何将数值复制到相应的数组中)。
嗨,姆拉登。
这是 "sample-ea-modular.mq5",里面有一些代码......还有我想要的界面。
我想把它做成模块化,我的想法是分别优化每个指标的输入/输出。
如果我能够用 "sample-ea-modular.mq5 "来实现,我将改变真正的EA。
真正的基础是Ea-sample.mq5。(我发这个帖子只是为了让你看到所有的指标)
亲爱的@mladen,
如果你能解决下面提到的错误,请你非常高兴。
谢谢你...
"问题:当我连接到图表并使用自动调校时间时,有一个警告。
oguz
像往常一样(你已经知道了),我不对反编译的代码进行评论,但我看到你在一个正确的轨道上:如果它能工作(选项),就使用它。如果不能用,就不要用。在我看来,这只是一个信息(而不是一个错误),所以...
亲爱的@mladen,
如果你能解决下面提到的错误,请你非常高兴。
谢谢你...
"问题:当我连接到图表并使用自动调校时间时,有一个警告。