编码帮助 - 页 513

 
mladen:
试试吧(它现在在我的终端上显示了我想要的许多蜡烛):candlebreaker_1.mq4

它现在对我来说工作得很好。

请注意。

 

大家好,我有一个问题,我的MT4不能显示在图表上了,MA,RSI,WPR蜡烛,它发生后,当我安装了一些天前的MT平台再次? 任何人都可以帮助

 
tfi_markets:
嗨,ProCoders。

我目前正在使用Autotrend Forecaster指标。

我写了下面的代码,但EA没有打开交易。

谁能看一下?

提前感谢您!

MT4在日志中只显示警报。

附加的文件:
journal.jpg  74 kb
 
tfi_markets:
MT4在日志中只显示警报。

那么问题就出在你写在EA中的条件上。

检查 这些条件是否评估为真

 

编码员们好。

我感到非常惭愧,因为这是我第三次询问警报功能。

我想在直方图的颜色发生变化时得到一个警报。

就像平时一样,我把指标缓冲区相互比较。但是这一次它不起作用了。

缓冲区工作得很好,我的比较函数也是正确的(在我看来)。

所以我认为这一定是个小问题,我希望有人能帮我解决。

提前感谢。

#property indicator_separate_window#property indicator_buffers 5

#property indicator_color1 clrGreen

#property indicator_width1 4

#property indicator_color2 clrRed

#property indicator_width2 4

#property indicator_color3 Teal

#property indicator_color4 Teal

#property indicator_color5 Black

#property indicator_minimum 0

#property indicator_maximum 0.1

extern int Amplitude = 2;

extern bool alertsOn = true;

extern bool alertsMessage = true;

extern bool alertsSound = true;

extern bool alertsNotify = true;

extern bool alertsEmail = true;

extern string soundfile = "alert2.wav";

bool nexttrend;

double minh, maxl, up[], down[], trend[], atrlo[], atrhi[];

int init () {

SetIndexBuffer(0, up);

SetIndexStyle(0,DRAW_HISTOGRAM);

SetIndexLabel(0, "up");

SetIndexBuffer(1, down);

SetIndexStyle(1,DRAW_HISTOGRAM);

SetIndexLabel(1, "down");

SetIndexBuffer (2, atrlo);

SetIndexStyle (2, DRAW_NONE);

SetIndexBuffer (3, atrhi);

SetIndexStyle (3, DRAW_NONE);

SetIndexBuffer (4, trend);

//---

SetIndexEmptyValue (0, 0.0);

SetIndexEmptyValue (1, 0.0);

SetIndexEmptyValue (4, 0.0);

nexttrend = 0;

minh = High;

maxl = Low;

return (0);

}

int start () {

double atr, ll, hh, lma, hma;

int workbar = 1;

int c = IndicatorCounted ();

if (c < 0) {

return (- 1);

}

for (int i = Bars - 1 - c; i >= workbar; i --) {

ll = iLow (Symbol (), Period (),

iLowest (Symbol (), Period (), MODE_LOW, Amplitude, i));

hh = iHigh (Symbol (), Period (),

iHighest (Symbol (), Period (), MODE_HIGH, Amplitude, i));

lma = iMA (NULL, 0, Amplitude, 0, MODE_SMA, PRICE_LOW, i);

hma = iMA (NULL, 0, Amplitude, 0, MODE_SMA, PRICE_HIGH, i);

trend = trend;

atr = iATR (Symbol (), 0, 100, i) / 2;

if (nexttrend == 1) {

maxl = MathMax (ll, maxl);

if (hma < maxl && Close < Low) {

trend = 1;

nexttrend = 0;

minh = hh;

}

}

if (nexttrend == 0) {

minh = MathMin (hh, minh);

if (lma > minh && Close > High) {

trend = 0;

nexttrend = 1;

maxl = ll;

}

}

if (trend == 0.0) { //-------------------------------------------------------------------------------------------

if (trend != 0.0) {

up = down;

up = up;

} else {

up = MathMax (maxl, up);

}

atrhi = up + atr;

atrlo = up - atr;

down = 0.0;

} else {

if (trend != 1.0) {

down = up;//-------------------------------------------------------------------------------------------

down = down;

} else {

down = MathMin (minh, down);

}

atrhi = down + atr;

atrlo = down - atr;

up = 0.0; //-------------------------------------------------------------------------------------------

}

if(alertsOn){

if((up[2]!=EMPTY_VALUE) && (down[2]!=EMPTY_VALUE) &&(up[1]!=EMPTY_VALUE)&&(down[1]==EMPTY_VALUE))lcheckalert();

if((up[2]!=EMPTY_VALUE) && (down[2]==EMPTY_VALUE) &&(up[1]!=EMPTY_VALUE)&&(down[1]!=EMPTY_VALUE))scheckalert();

}

}

return (0);

}

void lcheckalert()

{

static datetime candletime=0;

if(candletime!=Time[0])

{

string lmessage = "ZOXY is green on, this means a buy signal! Pair:"+_Symbol +" Price: "+Ask;

if (alertsMessage) Alert(lmessage);

if (alertsNotify) SendNotification(lmessage);

if (alertsEmail) SendMail(StringConcatenate(Symbol()," Buy signal "),lmessage);

if (alertsSound) PlaySound("alert2.wav");

candletime=Time[0];

}

}

void scheckalert()

{

static datetime candletime=0;

if(candletime!=Time[0])

{

string smessage = "ZOXY is Red, this means a sell signal! Pair: "+_Symbol +" Price: "+Bid;

if (alertsMessage) Alert(smessage);

if (alertsNotify) SendNotification(smessage);

if (alertsEmail) SendMail(StringConcatenate(Symbol()," Sell signal "),smessage);

if (alertsSound) PlaySound("alert2.wav");

candletime=Time[0];

}

}

zoxy.mq4

附加的文件:
zoxy.mq4  5 kb
 
mladen:
那么问题就出在你写在EA中的条件上 检查条件是否曾经评估为真

嗨,Mladen。

谢谢你的建议。我重写了一下代码,将条件 "强制 "为真/假。现在它是卖出,但不是买入。请看下面的代码。

if(openOrders<=0)

{

// AutoTrendForecaster

double AutoTrendup=iCustom(Symbol(),0, "AutoTrendForecaster",TMperiod,Intensity,SL_distance_pips,0,bar) 。

double AutoTrendup_prev=iCustom(Symbol(),0, "AutoTrendForecaster",TMperiod,Intensity,SL_distance_pips,0,bar+1);

double AutoTrenddown=iCustom(Symbol(),0, "AutoTrendForecaster",TMperiod,Intensity,SL_distance_pips,1,bar);

double AutoTrenddown_prev=iCustom(Symbol(),0, "AutoTrendForecaster",TMperiod,Intensity,SL_distance_pips,1,bar+1);

//+------------------------------------------------------------------+

//|买入

//+------------------------------------------------------------------+

bool buyCondition = false;

如果(AutoTrendup>0 && AutoTrendup!=EMPTY_VALUE)

{

buyCondition = true;

}

如果 (buyCondition)

{

OpenBuy()。

return(0);

}

//+------------------------------------------------------------------+

//|卖出

//+------------------------------------------------------------------+

bool sellCondition = false;

如果(AutoTrenddown>0 && AutoTrenddown!=EMPTY_VALUE)

{

sellCondition = true;

}

如果 (sellCondition)

{

OpenSell()。

return(0);

}

}

谢谢你的帮助!

附加的文件:
buysell.jpg  65 kb
 
xtractalpha:
编码员你好。

我感到非常惭愧,因为这是我第三次询问警报功能了。

我想在直方图的颜色发生变化时得到一个警报。

就像平时一样,我把指标缓冲区相互比较。但是这一次它不起作用了。

缓冲区工作得很好,我的比较函数也是正确的(在我看来)。

所以我认为这一定是个小问题,我希望有人能帮我解决。

先谢谢了。

#property indicator_separate_window#property indicator_buffers 5

#property indicator_color1 clrGreen

#property indicator_width1 4

#property indicator_color2 clrRed

#property indicator_width2 4

#property indicator_color3 Teal

#property indicator_color4 Teal

#property indicator_color5 Black

#property indicator_minimum 0

#property indicator_maximum 0.1

extern int Amplitude = 2;

extern bool alertsOn = true;

extern bool alertsMessage = true;

extern bool alertsSound = true;

extern bool alertsNotify = true;

extern bool alertsEmail = true;

extern string soundfile = "alert2.wav";

bool nexttrend;

double minh, maxl, up[], down[], trend[], atrlo[], atrhi[];

int init () {

SetIndexBuffer(0, up);

SetIndexStyle(0,DRAW_HISTOGRAM);

SetIndexLabel(0, "up");

SetIndexBuffer(1, down);

SetIndexStyle(1,DRAW_HISTOGRAM);

SetIndexLabel(1, "down");

SetIndexBuffer (2, atrlo);

SetIndexStyle (2, DRAW_NONE);

SetIndexBuffer (3, atrhi);

SetIndexStyle (3, DRAW_NONE);

SetIndexBuffer (4, trend);

//---

SetIndexEmptyValue (0, 0.0);

SetIndexEmptyValue (1, 0.0);

SetIndexEmptyValue (4, 0.0);

nexttrend = 0;

minh = High;

maxl = Low;

return (0);

}

int start () {

double atr, ll, hh, lma, hma;

int workbar = 1;

int c = IndicatorCounted ();

if (c < 0) {

return (- 1);

}

for (int i = Bars - 1 - c; i >= workbar; i --) {

ll = iLow (Symbol (), Period (),

iLowest (Symbol (), Period (), MODE_LOW, Amplitude, i));

hh = iHigh (Symbol (), Period (),

iHighest (Symbol (), Period (), MODE_HIGH, Amplitude, i));

lma = iMA (NULL, 0, Amplitude, 0, MODE_SMA, PRICE_LOW, i);

hma = iMA (NULL, 0, Amplitude, 0, MODE_SMA, PRICE_HIGH, i);

trend = trend;

atr = iATR (Symbol (), 0, 100, i) / 2;

if (nexttrend == 1) {

maxl = MathMax (ll, maxl);

if (hma < maxl && Close < Low) {

trend = 1;

nexttrend = 0;

minh = hh;

}

}

if (nexttrend == 0) {

minh = MathMin (hh, minh);

if (lma > minh && Close > High) {

trend = 0;

nexttrend = 1;

maxl = ll;

}

}

if (trend == 0.0) { //-------------------------------------------------------------------------------------------

if (trend != 0.0) {

up = down;

up = up;

} else {

up = MathMax (maxl, up);

}

atrhi = up + atr;

atrlo = up - atr;

down = 0.0;

} else {

if (trend != 1.0) {

down = up;//-------------------------------------------------------------------------------------------

down = down;

} else {

down = MathMin (minh, down);

}

atrhi = down + atr;

atrlo = down - atr;

up = 0.0; //-------------------------------------------------------------------------------------------

}

if(alertsOn){

if((up[2]!=EMPTY_VALUE) && (down[2]!=EMPTY_VALUE) &&(up[1]!=EMPTY_VALUE)&&(down[1]==EMPTY_VALUE))lcheckalert();

if((up[2]!=EMPTY_VALUE) && (down[2]==EMPTY_VALUE) &&(up[1]!=EMPTY_VALUE)&&(down[1]!=EMPTY_VALUE))scheckalert();

}

}

return (0);

}

void lcheckalert()

{

static datetime candletime=0;

if(candletime!=Time[0])

{

string lmessage = "ZOXY is green on, this means a buy signal! Pair:"+_Symbol +" Price: "+Ask;

if (alertsMessage) Alert(lmessage);

if (alertsNotify) SendNotification(lmessage);

if (alertsEmail) SendMail(StringConcatenate(Symbol()," Buy signal "),lmessage);

if (alertsSound) PlaySound("alert2.wav");

candletime=Time[0];

}

}

void scheckalert()

{

static datetime candletime=0;

if(candletime!=Time[0])

{

string smessage = "ZOXY is Red, this means a sell signal! Pair: "+_Symbol +" Price: "+Bid;

if (alertsMessage) Alert(smessage);

if (alertsNotify) SendNotification(smessage);

if (alertsEmail) SendMail(StringConcatenate(Symbol()," Sell signal "),smessage);

if (alertsSound) PlaySound("alert2.wav");

candletime=Time[0];

}

}

zoxy.mq4

xtractalpha

不管SetIndexEmptyValue() EMPTY_VALUE不是==0,而是2147483647。另外,你在那段代码中有重绘的问题,你必须先把它清理掉

 

拜托,谁能修复这个指标,让它在图表上显示警报(已经在)箭头,而且它应该只在第一根蜡烛收盘高于/低于EMA时发出警报。

candle_close_cross_ma_alert1.mq4

附加的文件:
 
triip:
拜托,谁能修复这个指标,使它在图表上显示警报(已经在)箭头,而且它应该只在第一个蜡烛收盘时警报,即收盘价高于/低于EMA。candle_close_cross_ma_alert1.mq4

三联单

请看这个:https://www.mql5.com/en/forum/general

将快速平均线周期设置为1,然后它将与价格越过移动平均线(slo ma)的情况相同。

 

非常感谢你,没有你的帮助我无法解决这个问题。

(ps.代码正在工作)。

祝你有个愉快的一天

原因: