コーディングのヘルプ - ページ 513

 
mladen:
それを試してみてください(それは私のターミナルで私が望むように多くのローソクを表示するようになりました):キャンドルブレーカ_1.mq4

今はうまくいっています。

ありがとうございます。

 

こんにちは、皆さん、私は問題がある私のmt4はもうチャート上に表示することができませんma、rsi、wprのキャンドルは、私はいくつかの日前にmtプラットフォームを再度インストールしたときに、その後に起こった? 誰か助けてください

 
tfi_markets:
こんにちは、ProCodersです。

現在、Autotrend Forecasterというインジケータを使用しています。

下記のコードを書きましたが、EAがトレードを開始しません。

どなたか見ていただけませんか?

事前にありがとうございます

MT4では、ジャーナルにアラートが表示されるだけです。

ファイル:
journal.jpg  74 kb
 
tfi_markets:
MT4では、ジャーナルにアラートが表示されるだけです。

では、EAに書かれている条件に問題があるのでしょう。

条件がtrueと評価されるかどうか確認して ください。

 

こんにちは、コーダーです。

アラート機能についての質問はこれで3回目なので、本当に恥ずかしいです。

ヒストグラムの色が色から変わった時にアラートを出したいのです。

通常と同じようにインジケータバッファを比較しています。しかし、今回はうまくいきません。

バッファは完全に動作しており、私の比較関数も(私の目には)正しく映っています。

だから、私はそれが何か小さなものでなければならないと思う、私は誰かが私を助けることができることを願っています。

よろしくお願いします。

#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さん、こんにちは。

ご指摘ありがとうございます。条件をtrue/falseに「強制」するためにコードを少し書き直しました。現在では、売られていますが、買われていません。以下のコードをご覧ください。

if(openedOrders<=0)

{

// オートトレンドフォーキャスター

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);

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

//| BUY

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

bool buyCondition = false;

if(AutoTrendup>0 && AutoTrendup!=EMPTY_VALUE)

{

buyCondition = true;

if (buyCondition)

{

OpenBuy();

return(0);

}

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

//| 売りの場合

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

bool sellCondition = false;

if (AutoTrenddown>0 && AutoTrenddown!=EMPTY_VALUE)

{

sellCondition = true;

}

if (sellCondition)

{

OpenSell();

return(0);

}

}

よろしくお願いします。

ファイル:
buysell.jpg  65 kb
 
xtractalpha:
こんにちは、コーダー。

アラート機能についての質問はこれで3回目なので、本当に恥ずかしいです。

ヒストグラムの色が色から変わった時にアラートを出したいのです。

通常と同じようにインジケーターバッファ同士を比較しています。しかし、今回はうまくいきません。

バッファは完全に動作しており、私の比較関数も(私の目には)正しく映っています。

だから、私はそれが何か小さなものでなければならないと思う、私は誰かが私を助けてくれることを願っています。

よろしくお願いします。

#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 です。また、そのコードには再描画の問題があり、最初にそれをクリーンアップする必要があります。

 

また、絵馬の上下にある最初のローソク足に対してのみアラートするようにしてください。

キャンドル_クローズ_クロス_マ_アラート1.mq4

ファイル:
 
triip:
このインジケータは、チャート上にアラート(すでにある)を表示し、また、絵馬の上または下にある最初のローソク足に対してのみアラートするように、どなたか修正してください。

トリプ

これを見てください :https://www.mql5.com/en/forum/general

fast maの期間を1に設定すると、価格が移動平均線(slo ma)を超えた場合と同じになります。

 

ありがとうございます。

(ps. code is working).

良い一日をお過ごしください。