水平線 - ページ 7

 

プロットライン(15)/価格/色/幅/スタイル 私はこれを自分で書いた。

こんにちは、私はこれを完了し、唯一の行のために削除を追加することにより、以前に作られた、プログラムは一度だけ、チャートに適用され、開いて変更した場合、すなわち...価格色スタイルなど、実行するようにコードを助けてください...私はスクリプトがうまく動作すると思いますが、私はまた、スクリプトを投稿している、私は今まで私がこれをcoplet助けることができる人に感謝し、それが今までそれを必要とするか、そこにニーズに合わせてそれを変更する必要がある誰のために働くことを願って、私は私の仲間のトレーダーが私の学習のスタイルからそれを記述する方法を学んだ後に個人的に書いた私の非常に最初の指標から利益を得られることを願っています。本当にありがとうございました。

プロット_ラインズ.mq4

プロット_ラインズ_1.mq4

ファイル:
 

こんにちは。

このインジケータ(MT_breakout.mq4)を、新しいティックでラインを削除しないように修正できる方はいらっしゃいますか?ありがとうございます。

(インジケータはこの投稿にあります :https://www.mql5.com/en/forum/172989/page3)

 

xピップス距離の価格水準

また、基準価格からx pipsの距離の水準に何本かの線を引くインジケータを探したのですが、なかなか見つかりませんでした。そこで、上に掲載した「Plot Lines」をベースにインジケーターを作ってみました。

上下7段階を選択し、プロットするラインの距離を選択します。距離は基準価格からのポイント数で計算されます。

デフォルトでは、30、70、100、130pipsの4つのレベルが設定されています。

このように利益確定値をpips単位で設定することで、利益 確定の目安になります。

お役に立てれば幸いです。ありがとうございました。

ファイル:
 

Air questさんへ。

x Pipsインジケーターを教えていただき、ありがとうございます。私はちょうどそれをmt4チャートにドラッグしましたが、それは出てきません、私は任意の線が表示されるのを見ません、それは何が間違っているのでしょうか。何が問題なのでしょうか?

ありがとうございます。

 

こんにちは。

このような横線を 引く方法を教えてください。 通常、ホールチャートでは、左から右へ水平線が引かれます。私が欲しいのは、指定した価格から実線を引き、同じ価格レベルにタッチしたところで終了させることです。そして、同じ長さの点線をもう一本引きます。例:マゼンタの実線は価格1.2324で引かれ、価格は下降する。価格が上昇し、そのレベルに達した後、マゼンタ色の実線は終了しなければならない。このマゼンタの実線は例えば100本のローソク足があるので、次の100本のローソク足のために同じレベルで白い点の線を引かなければなりません。

これを作るために私を助けてください、またはこれを作る方法の例のリンクを教えてください。

ありがとうございます。

ファイル:
 
pedma:
こんにちは。

このような横線を引くにはどうしたらよいのでしょうか? 通常、ホールチャートでは左から右へ水平線が引かれます。私が欲しいのは、指定した価格から実線を引き、同じ価格レベルにタッチしたところで終了させることです。そして、同じ長さの点線をもう一本引きます。例:マゼンタの実線は価格1.2324で引かれ、価格は下降する。価格が上昇し、そのレベルに達した後、マゼンタ色の実線は終了しなければならない。このマゼンタの実線は例えば100本のローソク足があるので、次の100本のローソク足のために同じレベルで白い点の線を引かなければなりません。

これを作るのを手伝ってください、またはこれを作る方法の例のリンクを教えてください。

ありがとうございます。

OBJECT_HLINEの代わりにOBJECT_TRENDLINEを使用すると、それができるようになります。

 
mladen:
OBJECT_HLINEの代わりにOBJECT_TRENDLINEを使用すると、それができるようになります。

mladenさん、こんにちは。

どうもありがとうございます。以下のコードで水平線を引くことができます。

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

//| myHorizontalLine.mq4 |

//| Copyright 2013, MetaQuotes Software Corp. |

//| MetaTrader 5 Trading Platform / MetaQuotes Software Corp. |

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

#property copyright "Copyright 2013, MetaQuotes Software Corp."

#property link "http://www.metaquotes.net"

#property indicator_chart_window

extern int getClosePrcOfCandleNr = 8;

extern color lineColor = Lime;

extern int lineWidth = 2;

extern int lineBeginOfCandleNr = 40;

extern int lineEndOfCandleNr = 1;

string label = "_myHorLine_";

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

//| Custom indicator initialization function |

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

int init()

{

return(0);

}

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

//| Custom indicator deinitialization function |

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

int deinit()

{

ObjectDelete(label);

return(0);

}

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

//| Custom indicator iteration function |

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

int start(){

Trend_Line(Time[lineBeginOfCandleNr],Time[lineEndOfCandleNr],Close[getClosePrcOfCandleNr],Close[getClosePrcOfCandleNr],lineColor,STYLE_SOLID,lineWidth);

return(0);

}

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

void Trend_Line(

datetime x1, datetime x2, double y1,

double y2, color lineColor, int lineStyle, int lineWidth)

{

//~~~~~~~~~~

ObjectDelete(label);

ObjectCreate(label, OBJ_TREND, 0, x1, y1, x2, y2, 0, 0);

ObjectSet(label, OBJPROP_RAY, 0);

ObjectSet(label, OBJPROP_COLOR, lineColor);

ObjectSet(label, OBJPROP_STYLE, lineStyle);

ObjectSet(label, OBJPROP_WIDTH, lineWidth);

//~~~~~~~~~~

}

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

[/PHP]

This line is still moving / redraw every new candle appear (see picture).

It's still not what i need. For example: I want to get the TIME and PRICE the EMA3 cross EMA21 at TimeFrame H1. At that point, I will draw a line. This line must end if the price goes back to the same price level. But i must can see the line from smaller timeframe like M1, M5, M15, M30 (not only on H1).

I tried to make it like this, but i did not get any line ....

[PHP]

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

//| myHorizontalLine2.mq4 |

//| Copyright 2013, MetaQuotes Software Corp. |

//| http://www.metaquotes.net |

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

#property copyright "Copyright 2013, MetaQuotes Software Corp."

#property link "http://www.metaquotes.net"

#property indicator_chart_window

extern int smallEMAperiod = 3;

extern int bigEMAperiod = 21;

extern color lineColorUp = Lime;

extern int lineWidthUp = 2;

extern color lineColorDn = Red;

extern int lineWidthDn = 2;

//---

double getUpPrice=0, getDnPrice=0, prcBefore=0, prcAfter=0;

datetime getUpTime=0, endUpTime=0, getDnTime=0, endDnTime=0;

bool goingUp=false, goingDown=false;

string upLabel = "_myHorLineUp_";

string dnLabel = "_myHorLineDn_";

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

//| Custom indicator initialization function |

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

int init()

{

return(0);

}

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

//| Custom indicator deinitialization function |

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

int deinit()

{

ObjectDelete(upLabel);

ObjectDelete(dnLabel);

return(0);

}

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

//| Custom indicator iteration function |

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

int start(){

int limit,i;

int counted_bars=IndicatorCounted();

//---- last counted bar will be recounted

if(counted_bars>0) counted_bars--;

limit=Bars-counted_bars;

//---

for(i=0; i<limit; i++) {

double prevSmallEMA = iMA(NULL,60,smallEMAperiod,0,MODE_EMA,PRICE_CLOSE,i+1);

double curSmallEMA = iMA(NULL,60,smallEMAperiod,0,MODE_EMA,PRICE_CLOSE,i);

double prevBigEMA = iMA(NULL,60,bigEMAperiod,0,MODE_EMA,PRICE_CLOSE,i+1);

double curBigEMA = iMA(NULL,60,bigEMAperiod,0,MODE_EMA,PRICE_CLOSE,i);

if ((prevSmallEMA curBigEMA)) { // going up

getUpPrice = iClose(NULL,60,i);

getUpTime = Time;

goingUp = true;

goingDown = false;

}

else if ((prevSmallEMA >= prevBigEMA)&&(curSmallEMA < curBigEMA)) { // going down

getDnPrice = iClose(NULL,60,i);

getDnTime = Time;

goingDown = true;

goingUp = false;

}

}

//---

if (goingUp == true) {

for(i=0; i<limit; i++) {

prcBefore = iClose(NULL,60,i+1);

prcAfter = iClose(NULL,60,i);

if ((prcBefore >= getUpPrice)&&(prcAfter < 0)) {

endUpTime = Time;

}

else {

endUpTime = 0;

}

}

if (endUpTime != 0) {

Trend_LineUp(getUpTime,endUpTime,getUpPrice,getUpPrice,lineColorUp,STYLE_SOLID,lineWidthUp);

}

}

//---

if (goingDown == true) {

for(i=0; i<limit; i++) {

prcBefore = iClose(NULL,60,i+1);

prcAfter = iClose(NULL,60,i);

if ((prcBefore 0)) {

endDnTime = Time;

}

else {

endDnTime = 0;

}

}

if (endDnTime != 0) {

Trend_LineDn(getDnTime,endDnTime,getDnPrice,getDnPrice,lineColorDn,STYLE_SOLID,lineWidthDn);

}

}

//---

return(0);

}

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

void Trend_LineUp(

datetime x1, datetime x2, double y1,

double y2, color lineColor, int lineStyle, int lineWidth)

{

//~~~~~~~~~~

ObjectDelete(upLabel);

ObjectCreate(upLabel, OBJ_TREND, 0, x1, y1, x2, y2, 0, 0);

ObjectSet(upLabel, OBJPROP_RAY, 0);

ObjectSet(upLabel, OBJPROP_COLOR, lineColor);

ObjectSet(upLabel, OBJPROP_STYLE, lineStyle);

ObjectSet(upLabel, OBJPROP_WIDTH, lineWidth);

//~~~~~~~~~~

}

void Trend_LineDn(

datetime x1, datetime x2, double y1,

double y2, color lineColor, int lineStyle, int lineWidth)

{

//~~~~~~~~~~

ObjectDelete(dnLabel);

ObjectCreate(dnLabel, OBJ_TREND, 0, x1, y1, x2, y2, 0, 0);

ObjectSet(dnLabel, OBJPROP_RAY, 0);

ObjectSet(dnLabel, OBJPROP_COLOR, lineColor);

ObjectSet(dnLabel, OBJPROP_STYLE, lineStyle);

ObjectSet(dnLabel, OBJPROP_WIDTH, lineWidth);

//~~~~~~~~~~

}

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

何かアイデアがあれば教えてください。

ありがとうございます。

ファイル:
 

申し訳ありません。

最後のコードにいくつかのタイプミスがあります。この1つが正しいものです。

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

//| myHorizontalLine2.mq4 |

//| Copyright 2013, MetaQuotes Software Corp. |

//| http://www.metaquotes.net |

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

#property copyright "Copyright 2013, MetaQuotes Software Corp."

#property link "http://www.metaquotes.net"

#property indicator_chart_window

extern int smallEMAperiod = 3;

extern int bigEMAperiod = 21;

extern color lineColorUp = Lime;

extern int lineWidthUp = 2;

extern color lineColorDn = Red;

extern int lineWidthDn = 2;

//---

double getUpPrice=0, getDnPrice=0, prcBefore=0, prcAfter=0;

datetime getUpTime=0, endUpTime=0, getDnTime=0, endDnTime=0;

bool goingUp=false, goingDown=false;

string upLabel = "_myHorLineUp_";

string dnLabel = "_myHorLineDn_";

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

//| Custom indicator initialization function |

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

int init()

{

return(0);

}

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

//| Custom indicator deinitialization function |

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

int deinit()

{

ObjectDelete(upLabel);

ObjectDelete(dnLabel);

return(0);

}

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

//| Custom indicator iteration function |

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

int start(){

int limit,i;

int counted_bars=IndicatorCounted();

//---- last counted bar will be recounted

if(counted_bars>0) counted_bars--;

limit=Bars-counted_bars;

//---

for(i=0; i<limit; i++) {

double prevSmallEMA = iMA(NULL,60,smallEMAperiod,0,MODE_EMA,PRICE_CLOSE,i+1);

double curSmallEMA = iMA(NULL,60,smallEMAperiod,0,MODE_EMA,PRICE_CLOSE,i);

double prevBigEMA = iMA(NULL,60,bigEMAperiod,0,MODE_EMA,PRICE_CLOSE,i+1);

double curBigEMA = iMA(NULL,60,bigEMAperiod,0,MODE_EMA,PRICE_CLOSE,i);

if ((prevSmallEMA curBigEMA)) { // going up

getUpPrice = iClose(NULL,60,i);

getUpTime = Time;

goingUp = true;

goingDown = false;

}

else if ((prevSmallEMA >= prevBigEMA)&&(curSmallEMA < curBigEMA)) { // going down

getDnPrice = iClose(NULL,60,i);

getDnTime = Time;

goingDown = true;

goingUp = false;

}

}

//---

if (goingUp == true) {

for(i=0; i<limit; i++) {

prcBefore = iClose(NULL,60,i+1);

prcAfter = iClose(NULL,60,i);

if ((prcBefore >= getUpPrice)&&(prcAfter < getUpPrice)) {

endUpTime = Time;

}

else {

endUpTime = 0;

}

}

if (endUpTime != 0) {

Trend_LineUp(getUpTime,endUpTime,getUpPrice,getUpPrice,lineColorUp,STYLE_SOLID,lineWidthUp);

}

}

//---

if (goingDown == true) {

for(i=0; i<limit; i++) {

prcBefore = iClose(NULL,60,i+1);

prcAfter = iClose(NULL,60,i);

if ((prcBefore getDnPrice)) {

endDnTime = Time;

}

else {

endDnTime = 0;

}

}

if (endDnTime != 0) {

Trend_LineDn(getDnTime,endDnTime,getDnPrice,getDnPrice,lineColorDn,STYLE_SOLID,lineWidthDn);

}

}

//---

return(0);

}

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

void Trend_LineUp(

datetime x1, datetime x2, double y1,

double y2, color lineColor, int lineStyle, int lineWidth)

{

//~~~~~~~~~~

ObjectDelete(upLabel);

ObjectCreate(upLabel, OBJ_TREND, 0, x1, y1, x2, y2, 0, 0);

ObjectSet(upLabel, OBJPROP_RAY, 0);

ObjectSet(upLabel, OBJPROP_COLOR, lineColor);

ObjectSet(upLabel, OBJPROP_STYLE, lineStyle);

ObjectSet(upLabel, OBJPROP_WIDTH, lineWidth);

//~~~~~~~~~~

}

void Trend_LineDn(

datetime x1, datetime x2, double y1,

double y2, color lineColor, int lineStyle, int lineWidth)

{

//~~~~~~~~~~

ObjectDelete(dnLabel);

ObjectCreate(dnLabel, OBJ_TREND, 0, x1, y1, x2, y2, 0, 0);

ObjectSet(dnLabel, OBJPROP_RAY, 0);

ObjectSet(dnLabel, OBJPROP_COLOR, lineColor);

ObjectSet(dnLabel, OBJPROP_STYLE, lineStyle);

ObjectSet(dnLabel, OBJPROP_WIDTH, lineWidth);

//~~~~~~~~~~

}

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

 

ムラデンさん、こんにちは。

どうもありがとうございます。私はそれを得た、それは今より良い(それはまだ多くのことをしなければならないが......私は今幸せだ......)。

*) 非常にシンプルなものです。

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

//| myHorizontalLine1.mq4 |

//| Copyright 2013, MetaQuotes Software Corp. |

//| http://www.metaquotes.net |

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

#property copyright "Copyright 2013, MetaQuotes Software Corp."

#property link "http://www.metaquotes.net"

#property indicator_chart_window

extern int getClosePrcOfCandleNr = 9;

extern color lineColorMain = Magenta;

extern int lineWidthMain = 2;

extern color lineColorNext = White;

int lineWidthNext = 1; // style dot muss max=1 width

extern int lineBeginOfCandleNr = 45;

extern int lineEndOfCandleNr = 21;

datetime curTimeStamp=0;

int beginOfDotLine, endOfDotLine;

string labelMain = "_HorLine5_";

string labelNext = "_HorLine5Next_";

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

//| Custom indicator initialization function |

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

int init()

{

curTimeStamp = Time[0];

return(0);

}

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

//| Custom indicator deinitialization function |

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

int deinit()

{

ObjectDelete(labelMain);

ObjectDelete(labelNext);

return(0);

}

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

//| Custom indicator iteration function |

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

int start(){

if (curTimeStamp != Time[0]) {

curTimeStamp = Time[0];

lineBeginOfCandleNr++;

lineEndOfCandleNr++;

getClosePrcOfCandleNr++;

beginOfDotLine = lineEndOfCandleNr;

int beginMainCandle = iBarShift(NULL,0,Time[lineBeginOfCandleNr]);

int endMainCandle = iBarShift(NULL,0,Time[lineEndOfCandleNr]);

endOfDotLine = beginOfDotLine - (beginMainCandle - endMainCandle);

}

Trend_LineMain(Time[lineBeginOfCandleNr],Time[lineEndOfCandleNr],Close[getClosePrcOfCandleNr],Close[getClosePrcOfCandleNr],lineColorMain,STYLE_SOLID,lineWidthMain);

if (endOfDotLine > 0) { // muss positive

Trend_LineNext(Time,Time[endOfDotLine],Close[getClosePrcOfCandleNr],Close[getClosePrcOfCandleNr],lineColorNext,STYLE_DOT,lineWidthNext);

}

else {

Trend_LineNext(Time,Time[1],Close[getClosePrcOfCandleNr],Close[getClosePrcOfCandleNr],lineColorNext,STYLE_DOT,lineWidthNext);

}

return(0);

}

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

void Trend_LineMain(

datetime x1, datetime x2, double y1,

double y2, color lineColorMain, int lineStyle, int lineWidthMain)

{

//~~~~~~~~~~

ObjectDelete(labelMain);

ObjectCreate(labelMain, OBJ_TREND, 0, x1, y1, x2, y2, 0, 0);

ObjectSet(labelMain, OBJPROP_RAY, 0);

ObjectSet(labelMain, OBJPROP_COLOR, lineColorMain);

ObjectSet(labelMain, OBJPROP_STYLE, lineStyle);

ObjectSet(labelMain, OBJPROP_WIDTH, lineWidthMain);

//~~~~~~~~~~

}

void Trend_LineNext(

datetime x1, datetime x2, double y1,

double y2, color lineColorNext, int lineStyle, int lineWidthNext)

{

//~~~~~~~~~~

ObjectDelete(labelNext);

ObjectCreate(labelNext, OBJ_TREND, 0, x1, y1, x2, y2, 0, 0);

ObjectSet(labelNext, OBJPROP_RAY, 0);

ObjectSet(labelNext, OBJPROP_COLOR, lineColorNext);

ObjectSet(labelNext, OBJPROP_STYLE, lineStyle);

ObjectSet(labelNext, OBJPROP_WIDTH, lineWidthNext);

//~~~~~~~~~~

}

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

[/PHP]

And this is better ... :

[PHP]

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

//| myHorizontalLine3.mq4 |

//| Copyright 2013, MetaQuotes Software Corp. |

//| http://www.metaquotes.net |

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

#property copyright "Copyright 2013, MetaQuotes Software Corp."

#property link "http://www.metaquotes.net"

#property indicator_chart_window

extern int getClosePrcOfCandleNr = 9;

extern color lineColorMain = Magenta;

extern int lineWidthMain = 2;

extern color lineColorNext = White;

int lineWidthNext = 1; // style dot muss max=1 width

extern int smallEMAperiod = 30;

extern int bigEMAperiod = 150;

extern int bars_limit = 1000;

datetime curTimeStamp=0;

int beginOfDotLine, endOfDotLine;

double getUpPrice=0, getDnPrice=0, prcBefore=0, prcAfter=0;

datetime getUpTime=0, endUpTime=0, getDnTime=0, endDnTime=0;

bool goingUp=false, goingDown=false;

string labelMain = "_HorLine8_";

string labelNext = "_HorLine8Next_";

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

//| Custom indicator initialization function |

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

int init()

{

curTimeStamp = Time[0];

return(0);

}

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

//| Custom indicator deinitialization function |

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

int deinit()

{

ObjectDelete(labelMain);

ObjectDelete(labelNext);

return(0);

}

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

//| Custom indicator iteration function |

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

int start(){

int limit,i;

int counted_bars=IndicatorCounted();

if(counted_bars>0) counted_bars--;

limit=Bars-counted_bars;

if (limit>bars_limit-1 && bars_limit!=0) limit=bars_limit-1;

//---

for(i=limit; i>0; i--) { // decrement here ....

double prevSmallEMA = iMA(NULL,0,smallEMAperiod,0,MODE_EMA,PRICE_CLOSE,i+1);

double curSmallEMA = iMA(NULL,0,smallEMAperiod,0,MODE_EMA,PRICE_CLOSE,i);

double prevBigEMA = iMA(NULL,0,bigEMAperiod,0,MODE_EMA,PRICE_CLOSE,i+1);

double curBigEMA = iMA(NULL,0,bigEMAperiod,0,MODE_EMA,PRICE_CLOSE,i);

if ((prevSmallEMA curBigEMA)) { // going up

///// getUpPrice = iClose(NULL,0,i);

getUpPrice = (prevSmallEMA + curSmallEMA)/2;

getUpTime = Time;

goingUp = true;

goingDown = false;

int getUpCandle = iBarShift(NULL,0,getUpTime);

prcBefore = iClose(NULL,0,i+1);

prcAfter = iClose(NULL,0,i);

if ((prcBefore >= getUpPrice)&&(prcAfter < getUpPrice)) {

if (Time > getUpTime) {

endUpTime = Time;

int endUpCandle = iBarShift(NULL,0,endUpTime);

}

}

else {

endUpTime = Time[0];

endUpCandle = 0;

}

//---

if (curTimeStamp != Time[0]) {

curTimeStamp = Time[0];

getUpCandle++;

endUpCandle++;

beginOfDotLine = endUpCandle;

int beginMainCandle = iBarShift(NULL,0,Time[getUpCandle]);

int endMainCandle = iBarShift(NULL,0,Time[endUpCandle]);

endOfDotLine = beginOfDotLine - (beginMainCandle - endMainCandle);

}

Trend_LineMain(Time[getUpCandle],Time[endUpCandle],getUpPrice,getUpPrice,lineColorMain,STYLE_SOLID,lineWidthMain);

if (endOfDotLine > 0) { // muss positive

Trend_LineNext(Time,Time[endOfDotLine],getUpPrice,getUpPrice,lineColorNext,STYLE_DOT,lineWidthNext);

}

else {

Trend_LineNext(Time,Time[1],getUpPrice,getUpPrice,lineColorNext,STYLE_DOT,lineWidthNext);

}

//---

goingUp = false;

}

else if ((prevSmallEMA >= prevBigEMA)&&(curSmallEMA < curBigEMA)) { // going down

getDnPrice = iClose(NULL,0,i);

getDnTime = Time;

goingDown = true;

goingUp = false;

int getDnCandle = iBarShift(NULL,0,getDnTime);

//-- to do .....

goingDown = false;

}

} // ende for

//---

return(0);

}

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

void Trend_LineMain(

datetime x1, datetime x2, double y1,

double y2, color lineColorMain, int lineStyle, int lineWidthMain)

{

//~~~~~~~~~~

ObjectDelete(labelMain);

ObjectCreate(labelMain, OBJ_TREND, 0, x1, y1, x2, y2, 0, 0);

ObjectSet(labelMain, OBJPROP_RAY, 0);

ObjectSet(labelMain, OBJPROP_COLOR, lineColorMain);

ObjectSet(labelMain, OBJPROP_STYLE, lineStyle);

ObjectSet(labelMain, OBJPROP_WIDTH, lineWidthMain);

//~~~~~~~~~~

}

void Trend_LineNext(

datetime x1, datetime x2, double y1,

double y2, color lineColorNext, int lineStyle, int lineWidthNext)

{

//~~~~~~~~~~

ObjectDelete(labelNext);

ObjectCreate(labelNext, OBJ_TREND, 0, x1, y1, x2, y2, 0, 0);

ObjectSet(labelNext, OBJPROP_RAY, 0);

ObjectSet(labelNext, OBJPROP_COLOR, lineColorNext);

ObjectSet(labelNext, OBJPROP_STYLE, lineStyle);

ObjectSet(labelNext, OBJPROP_WIDTH, lineWidthNext);

//~~~~~~~~~~

}

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

 
pedma:
こんにちは、Mladen。

ありがとうございました。私はそれを得た、それは今よりよいです(それはまだ多くのことをしなければならないが......私は今幸せです......)

*)非常にシンプルなもの。

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

//| myHorizontalLine1.mq4 |

//| Copyright 2013, MetaQuotes Software Corp. |

//| http://www.metaquotes.net |

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

#property copyright "Copyright 2013, MetaQuotes Software Corp."

#property link "http://www.metaquotes.net"

#property indicator_chart_window

extern int getClosePrcOfCandleNr = 9;

extern color lineColorMain = Magenta;

extern int lineWidthMain = 2;

extern color lineColorNext = White;

int lineWidthNext = 1; // style dot muss max=1 width

extern int lineBeginOfCandleNr = 45;

extern int lineEndOfCandleNr = 21;

datetime curTimeStamp=0;

int beginOfDotLine, endOfDotLine;

string labelMain = "_HorLine5_";

string labelNext = "_HorLine5Next_";

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

//| Custom indicator initialization function |

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

int init()

{

curTimeStamp = Time[0];

return(0);

}

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

//| Custom indicator deinitialization function |

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

int deinit()

{

ObjectDelete(labelMain);

ObjectDelete(labelNext);

return(0);

}

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

//| Custom indicator iteration function |

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

int start(){

if (curTimeStamp != Time[0]) {

curTimeStamp = Time[0];

lineBeginOfCandleNr++;

lineEndOfCandleNr++;

getClosePrcOfCandleNr++;

beginOfDotLine = lineEndOfCandleNr;

int beginMainCandle = iBarShift(NULL,0,Time[lineBeginOfCandleNr]);

int endMainCandle = iBarShift(NULL,0,Time[lineEndOfCandleNr]);

endOfDotLine = beginOfDotLine - (beginMainCandle - endMainCandle);

}

Trend_LineMain(Time[lineBeginOfCandleNr],Time[lineEndOfCandleNr],Close[getClosePrcOfCandleNr],Close[getClosePrcOfCandleNr],lineColorMain,STYLE_SOLID,lineWidthMain);

if (endOfDotLine > 0) { // muss positive

Trend_LineNext(Time,Time[endOfDotLine],Close[getClosePrcOfCandleNr],Close[getClosePrcOfCandleNr],lineColorNext,STYLE_DOT,lineWidthNext);

}

else {

Trend_LineNext(Time,Time[1],Close[getClosePrcOfCandleNr],Close[getClosePrcOfCandleNr],lineColorNext,STYLE_DOT,lineWidthNext);

}

return(0);

}

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

void Trend_LineMain(

datetime x1, datetime x2, double y1,

double y2, color lineColorMain, int lineStyle, int lineWidthMain)

{

//~~~~~~~~~~

ObjectDelete(labelMain);

ObjectCreate(labelMain, OBJ_TREND, 0, x1, y1, x2, y2, 0, 0);

ObjectSet(labelMain, OBJPROP_RAY, 0);

ObjectSet(labelMain, OBJPROP_COLOR, lineColorMain);

ObjectSet(labelMain, OBJPROP_STYLE, lineStyle);

ObjectSet(labelMain, OBJPROP_WIDTH, lineWidthMain);

//~~~~~~~~~~

}

void Trend_LineNext(

datetime x1, datetime x2, double y1,

double y2, color lineColorNext, int lineStyle, int lineWidthNext)

{

//~~~~~~~~~~

ObjectDelete(labelNext);

ObjectCreate(labelNext, OBJ_TREND, 0, x1, y1, x2, y2, 0, 0);

ObjectSet(labelNext, OBJPROP_RAY, 0);

ObjectSet(labelNext, OBJPROP_COLOR, lineColorNext);

ObjectSet(labelNext, OBJPROP_STYLE, lineStyle);

ObjectSet(labelNext, OBJPROP_WIDTH, lineWidthNext);

//~~~~~~~~~~

}

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

[/PHP]

And this is better ... :

[PHP]

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

//| myHorizontalLine3.mq4 |

//| Copyright 2013, MetaQuotes Software Corp. |

//| http://www.metaquotes.net |

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

#property copyright "Copyright 2013, MetaQuotes Software Corp."

#property link "http://www.metaquotes.net"

#property indicator_chart_window

extern int getClosePrcOfCandleNr = 9;

extern color lineColorMain = Magenta;

extern int lineWidthMain = 2;

extern color lineColorNext = White;

int lineWidthNext = 1; // style dot muss max=1 width

extern int smallEMAperiod = 30;

extern int bigEMAperiod = 150;

extern int bars_limit = 1000;

datetime curTimeStamp=0;

int beginOfDotLine, endOfDotLine;

double getUpPrice=0, getDnPrice=0, prcBefore=0, prcAfter=0;

datetime getUpTime=0, endUpTime=0, getDnTime=0, endDnTime=0;

bool goingUp=false, goingDown=false;

string labelMain = "_HorLine8_";

string labelNext = "_HorLine8Next_";

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

//| Custom indicator initialization function |

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

int init()

{

curTimeStamp = Time[0];

return(0);

}

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

//| Custom indicator deinitialization function |

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

int deinit()

{

ObjectDelete(labelMain);

ObjectDelete(labelNext);

return(0);

}

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

//| Custom indicator iteration function |

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

int start(){

int limit,i;

int counted_bars=IndicatorCounted();

if(counted_bars>0) counted_bars--;

limit=Bars-counted_bars;

if (limit>bars_limit-1 && bars_limit!=0) limit=bars_limit-1;

//---

for(i=limit; i>0; i--) { // decrement here ....

double prevSmallEMA = iMA(NULL,0,smallEMAperiod,0,MODE_EMA,PRICE_CLOSE,i+1);

double curSmallEMA = iMA(NULL,0,smallEMAperiod,0,MODE_EMA,PRICE_CLOSE,i);

double prevBigEMA = iMA(NULL,0,bigEMAperiod,0,MODE_EMA,PRICE_CLOSE,i+1);

double curBigEMA = iMA(NULL,0,bigEMAperiod,0,MODE_EMA,PRICE_CLOSE,i);

if ((prevSmallEMA curBigEMA)) { // going up

///// getUpPrice = iClose(NULL,0,i);

getUpPrice = (prevSmallEMA + curSmallEMA)/2;

getUpTime = Time;

goingUp = true;

goingDown = false;

int getUpCandle = iBarShift(NULL,0,getUpTime);

prcBefore = iClose(NULL,0,i+1);

prcAfter = iClose(NULL,0,i);

if ((prcBefore >= getUpPrice)&&(prcAfter < getUpPrice)) {

if (Time > getUpTime) {

endUpTime = Time;

int endUpCandle = iBarShift(NULL,0,endUpTime);

}

}

else {

endUpTime = Time[0];

endUpCandle = 0;

}

//---

if (curTimeStamp != Time[0]) {

curTimeStamp = Time[0];

getUpCandle++;

endUpCandle++;

beginOfDotLine = endUpCandle;

int beginMainCandle = iBarShift(NULL,0,Time[getUpCandle]);

int endMainCandle = iBarShift(NULL,0,Time[endUpCandle]);

endOfDotLine = beginOfDotLine - (beginMainCandle - endMainCandle);

}

Trend_LineMain(Time[getUpCandle],Time[endUpCandle],getUpPrice,getUpPrice,lineColorMain,STYLE_SOLID,lineWidthMain);

if (endOfDotLine > 0) { // muss positive

Trend_LineNext(Time,Time[endOfDotLine],getUpPrice,getUpPrice,lineColorNext,STYLE_DOT,lineWidthNext);

}

else {

Trend_LineNext(Time,Time[1],getUpPrice,getUpPrice,lineColorNext,STYLE_DOT,lineWidthNext);

}

//---

goingUp = false;

}

else if ((prevSmallEMA >= prevBigEMA)&&(curSmallEMA < curBigEMA)) { // going down

getDnPrice = iClose(NULL,0,i);

getDnTime = Time;

goingDown = true;

goingUp = false;

int getDnCandle = iBarShift(NULL,0,getDnTime);

//-- to do .....

goingDown = false;

}

} // ende for

//---

return(0);

}

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

void Trend_LineMain(

datetime x1, datetime x2, double y1,

double y2, color lineColorMain, int lineStyle, int lineWidthMain)

{

//~~~~~~~~~~

ObjectDelete(labelMain);

ObjectCreate(labelMain, OBJ_TREND, 0, x1, y1, x2, y2, 0, 0);

ObjectSet(labelMain, OBJPROP_RAY, 0);

ObjectSet(labelMain, OBJPROP_COLOR, lineColorMain);

ObjectSet(labelMain, OBJPROP_STYLE, lineStyle);

ObjectSet(labelMain, OBJPROP_WIDTH, lineWidthMain);

//~~~~~~~~~~

}

void Trend_LineNext(

datetime x1, datetime x2, double y1,

double y2, color lineColorNext, int lineStyle, int lineWidthNext)

{

//~~~~~~~~~~

ObjectDelete(labelNext);

ObjectCreate(labelNext, OBJ_TREND, 0, x1, y1, x2, y2, 0, 0);

ObjectSet(labelNext, OBJPROP_RAY, 0);

ObjectSet(labelNext, OBJPROP_COLOR, lineColorNext);

ObjectSet(labelNext, OBJPROP_STYLE, lineStyle);

ObjectSet(labelNext, OBJPROP_WIDTH, lineWidthNext);

//~~~~~~~~~~

}

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

良い さらなるコーディングとトレードをお楽しみください。