エリート指標 :) - ページ 98

 

...

Doc,

全部で2つのバッファを使いました (なので、あと6つ残っています) どのようにヒストグラムを作成したいのか正確に分からないので、代わりにこちらを投稿します (ヒストグラムはありません。アラートは ある時点で追加され、名前に「短」と「長」は書きません) もしヒストグラムについてヘルプが必要なら、叫んでください。

よろしくお願いします。

mladen

dr.house7:
Hy mladenです。

このインディーをHistoバーで使えるようにするチャンスはあるのでしょうか?

すべてのバッファはビジー状態で、それを修正する方法がわかりません...。

どうか助けてください。

みんなに感謝します。

よろしくお願いします。

ドク
 

mladenさん、ありがとうございます。

あなたは素晴らしいです短時間で素晴らしいコードです。

私の標準的な知識とは全く違うので、どのように修正したらいいのか少し混乱しています。

エルゴードcciラインとトリガーラインのクロスに対してヒストバーが欲しいです。

よろしくお願いします。

ドク

ファイル:
bars.png  17 kb
 

...

2つのバージョン :

「クラシカルヒスト」 - 最初のサブウィンドウ

「Bars histo" -> 望みのもの - トリガーがエルゴードCCIより下にあるときは緑、エルゴードCCIより上にあるときは赤、それらが等しいときは(もし)灰色

よろしくお願いします。

mladen

dr.house7:
mladenさん、ありがとうございます。

あなたは素晴らしいです!短時間で素晴らしいコードです。

私の標準的な知識とは全く異なるので、どのように修正すればよいのか少し戸惑っています。

エルゴードcciラインとトリガーラインのクロスに対してヒストバーが欲しいです。

よろしくお願いします。

ドク
 
mladen:
2つのバージョン。

"Classical histo" - 最初のサブウィンドウ。

「Bars histo" -> お望みのもの - トリガーがエルゴードCCIより下なら緑、エルゴードCCIより上なら赤、それらが同じなら灰色。

よろしくお願いします。

mladen

まさに私が必要としていたものです。

mladenさん、あなたは天才です。

よろしくお願いします。

ドク

 

こんにちは、mladenです。

今日の午後、ちょっと寄ったのですが、挨拶する前に急いで帰らなければなりません。

新しいインジケーターとMcGinley自身の記事をありがとうございました。 まだ読んでいます。 そうですね、私も最初に9-EMAの横に御社の1stバージョンを置いたとき、そっくりで驚きました。そうですね、Metastockの計算式はMcGinleyの計算式とは似ていませんね。 誤報で申し訳ありませんが、ネットから得た情報です。

少なくとも、Investopediaの記事が少し誇張していたことは分かった。 しかし、それは本当にかなり知られていなかったので、それはいくつかの関心を呼び起こし、全体としてそれは楽しいです。

ありがとうございます&よろしくお願いします。

jsweiさん

 

mladenさん、ごめんなさい。

この最後の部分について助けていただけませんか?

写真のように、グレーと黄色の線がなく、バーがすべて同じ行にある色を持つことは可能でしょうか?

よろしくお願いします。

ドク

ファイル:
 

...

このように?

よろしくお願いします

mladen

dr.house7:
mladenさん、申し訳ありません。

この最後の部分で私を助けてもらえますか?

写真のように、グレーと黄色の線がなく、バーがすべて同じ行にある色を持つことは可能ですか?

よろしくお願いします。

ドク
 
mladen:
こんな感じ?

よろしくお願いします

mladen

まさに

mladenに感謝します。

よろしくお願いします。

ドク

 

linuxuserさんが投稿されたボリンジャー%bインジケータに(さらに)修正を加えようとしています。ストキャスティクスと同じようにシグナルラインを表示させ、1つのグラフに複数の期間を表示させることができるようにしたいと考えています。以前、linuxuserの助けを借りて、なんとかこれを実現し、現在では同じウィンドウに2つまたは3つの期間を表示するようにセットアップしています。

今、私は計算で標準偏差に 小数値を使用できるようにしようとしています。この場合、標準のiBands関数は使えないと考えていいのでしょうか?標準のBandsインジケータに付属しているコードを使ってみましたが、あまりうまくいきませんでした。どなたか助けていただけませんか?

また、他のタイムフレームからの計算を表示できるようにしたいと思っていますが、一歩ずつ進めていくしかないと思います。これは私が最初に考えていたよりも少し難しいかもしれないことに気づきました。

ありがとうございました。

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

//| Bollinger %b - Multi.mq4 |

//| based on Bollinger Bands %b.mq4 |

//| Original indicator by Alejandro Galindo |

//| Modified and Corrected by Linuxser for forex TSD |

//| Further modifications made by whitebloodcell |

//|

//| John Bollinger original formula is: |

//| (Last - Lower BB)/(Upper BB - Lower BB) |

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

#property copyright ""

#property link ""

#property indicator_separate_window

#property indicator_buffers 6

#property indicator_color1 LightSalmon

#property indicator_color2 LightSalmon

#property indicator_color3 SkyBlue

#property indicator_color4 SkyBlue

#property indicator_color5 Green

#property indicator_color6 Green

//---- input parameters

extern bool ShowBand1 = TRUE;

extern int Timeframe_1 = 15;

extern int BBPeriod_1=5;

extern double StdDeviation_1=1.9;

extern int MainLineMAPeriod_1=1;

extern int MainLineMAMethod_1=1;

extern int SignalMAPeriod_1=2;//corresponds to %D - the signal line

extern int SignalMAMethod_1=1;

extern bool ShowBand2 = TRUE;

extern int Timeframe_2 = 15;

extern int BBPeriod_2=10;

extern double StdDeviation_2=2;

extern int MainLineMAPeriod_2=2;

extern int MainLineMAMethod_2=1;

extern int SignalMAPeriod_2=3;

extern int SignalMAMethod_2=1;

extern bool ShowBand3 = TRUE;

extern int Timeframe_3 = 15;

extern int BBPeriod_3=20;

extern double StdDeviation_3=2.0;

extern int MainLineMAPeriod_3=2;

extern int MainLineMAMethod_3=1;

extern int SignalMAPeriod_3=3;

extern int SignalMAMethod_3=1;

extern int AppliedPrice=0;

extern string s2 = "0=SMA,1=EMA,2=Smoothed,4=LWMA";

extern string s1 = "0=Close,1=Open,2=High,3=Low,4=Median,5=Typical,6=Weighted";

//---- buffers

double BLG_Buffer_1[];

double MainLineBuffer_1[];

double SignalBuffer_1[];

double BLG_Buffer_2[];

double MainLineBuffer_2[];

double SignalBuffer_2[];

double BLG_Buffer_3[];

double MainLineBuffer_3[];

double SignalBuffer_3[];

//#include

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

//| Custom indicator initialization function |

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

int init() {

string short_name;

SetIndexStyle(0,DRAW_LINE,EMPTY,2);

SetIndexBuffer(0,MainLineBuffer_1);

SetIndexStyle(1,DRAW_LINE,STYLE_DOT);

SetIndexBuffer(1,SignalBuffer_1);

SetIndexStyle(2,DRAW_LINE,EMPTY,2);

SetIndexBuffer(2,MainLineBuffer_2);

SetIndexStyle(3,DRAW_LINE,STYLE_DOT);

SetIndexBuffer(3,SignalBuffer_2);

SetIndexStyle(4,DRAW_LINE,EMPTY,2);

SetIndexBuffer(4,MainLineBuffer_3);

SetIndexStyle(5,DRAW_LINE,STYLE_DOT);

SetIndexBuffer(5,SignalBuffer_3);

//SetLevelValue(1,10);

SetLevelValue(0,0);

SetLevelValue(1,20);

SetLevelValue(2,40);

SetLevelValue(3,60);

SetLevelValue(4,80);

SetLevelValue(5,100);

SetLevelStyle(STYLE_DOT,1,DimGray);

SetIndexDrawBegin(0,BBPeriod_1);

SetIndexDrawBegin(1,BBPeriod_1+SignalMAPeriod_1);

SetIndexDrawBegin(2,BBPeriod_2);

SetIndexDrawBegin(3,BBPeriod_2+SignalMAPeriod_2);

SetIndexDrawBegin(4,BBPeriod_3);

SetIndexDrawBegin(5,BBPeriod_3+SignalMAPeriod_3);

//name for DataWindow and indicator subwindow label

short_name="Bollinger Percent B (%b)("+BBPeriod_1+","+MainLineMAPeriod_1+") ("+BBPeriod_2+","+MainLineMAPeriod_2+") ("+BBPeriod_3+","+MainLineMAPeriod_3+")";

IndicatorShortName(short_name);

return(0);

}

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

//| Momentum |

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

int start() {

if(ShowBand1==TRUE) {

if(Bars<=BBPeriod_1) return(0);

MainFunction(BLG_Buffer_1, MainLineBuffer_1, SignalBuffer_1, Timeframe_1, BBPeriod_1, StdDeviation_1,

AppliedPrice, MainLineMAPeriod_1, MainLineMAMethod_1, SignalMAPeriod_1, SignalMAMethod_1);

}

if(ShowBand2==TRUE) {

if(Bars<=BBPeriod_2) return(0);

MainFunction(BLG_Buffer_2, MainLineBuffer_2, SignalBuffer_2, Timeframe_2, BBPeriod_2, StdDeviation_2,

AppliedPrice, MainLineMAPeriod_2, MainLineMAMethod_2, SignalMAPeriod_2, SignalMAMethod_2);

}

if(ShowBand3==TRUE) {

if(Bars<=BBPeriod_3) return(0);

MainFunction(BLG_Buffer_3, MainLineBuffer_3, SignalBuffer_3, Timeframe_3, BBPeriod_3, StdDeviation_3,

AppliedPrice, MainLineMAPeriod_3, MainLineMAMethod_3, SignalMAPeriod_3, SignalMAMethod_3);

}

return(0);

}

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

void MainFunction(double &BLGBuffer[], double &MainLineBuffer[], double &SignalBuffer[], int timefame, int BBPeriod, double StdDeviation,

int AppliedPrice, int MainLineMAPeriod, int MainLineMAMethod, int SignalMAPeriod, int SignalMAMethod) {

int i=0,limit=0;

double PriceArray[];

if (ArrayRange(BLGBuffer,0) != Bars) {

ArrayResize(BLGBuffer,Bars);

ArraySetAsSeries(BLGBuffer, TRUE);

}

//number of bars already processed by indicator

int counted_bars=IndicatorCounted();

//load empty values into array until enough elements for calculation

if(counted_bars<1) {

for(i=1;i<=BBPeriod;i++) {

BLGBuffer=EMPTY_VALUE;

}//end for(i=1;i<=BandsPeriod;i++)

}//end if(counted_bars<1)

if(counted_bars>0) counted_bars--;

limit = MathMin(Bars-counted_bars,Bars-BBPeriod);

for(i=limit;i>=0;i--) {

//(Last - Lower BB)/(Upper BB - Lower BB)

BLGBuffer=((Close - iBands(NULL,timefame,BBPeriod,StdDeviation,0,AppliedPrice,MODE_LOWER,i))/

(iBands(NULL,timefame,BBPeriod,StdDeviation,0,AppliedPrice,MODE_UPPER,i)-iBands(NULL,timefame,BBPeriod,StdDeviation,0,AppliedPrice,MODE_LOWER,i)))*100;

}//end for(i=limit;i>=0;i--)

//smooth the signal by applying a moving average

for (i = limit; i >= 0; i--) MainLineBuffer = iMAOnArray(BLGBuffer, 0, MainLineMAPeriod, 0, MainLineMAMethod, i);

//create a Signal line (akin to stochastics) by further smoothing the (already smoothed) signal line.

for (i = limit; i >= 0; i--) SignalBuffer = iMAOnArray(MainLineBuffer, 0, SignalMAPeriod, 0, SignalMAMethod, i);

}//end MainFunction()

//--------------------------------------------------------------------------------

//Function: BandCalculation - Not yet working

//Purpose: Calculate the value of either the upper or lower bollinger band depen-

// on input variables.

//Inputs: Mode (int) - Calculate either upper or lower band

// limit (int) - Number of bars to calculate

// timeframe (int)

// BandsPeriod (int)

// MAMethod (int)

// BandsDeviation (double)

// AppliedPrice (int)

//Returns:

//--------------------------------------------------------------------------------

/*

void BandCalculation(int Mode, int limit, int timeframe, int BandsPeriod, int MAMethod, double BandsDeviation, int AppliedPrice) {

int i,k;

double deviation;

double sum,oldval,newres;

//if(counted_bars>0) limit++;

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

MovingBuffer=iMA(NULL,0,BandsPeriod,BandsShift,MAMethod,AppliedPrice,i);

}//end for(i=0; i<limit; i++)

i=limit;

//i=Bars-BandsPeriod+1;

//if(counted_bars>BandsPeriod-1) i=Bars-counted_bars-1;

while(i>=0) {

sum=0.0;

k=i+BandsPeriod-1;

oldval=MovingBuffer;

while(k>=i) {

newres=Close[k]-oldval;

sum+=newres*newres;

k--;

}//end while(k>=i)

//calculate deviation

deviation=BandsDeviations*MathSqrt(sum/BandsPeriod);

//Upper/Lower bands are equal to the moving average +/- deviation.

if(Mode==0) {

UpperBuffer=oldval+deviation;

}

else {

LowerBuffer=oldval-deviation;

}

i--;

}//end while(i>=0)

}//end start()

*/
ファイル:
 

...

whitebloodcellです。

おっしゃるとおりです。内蔵のボリンジャーバンドインジケータは、標準偏差の 倍率が整数値の場合のみ動作します。分数倍率や複数乖離を使用できる簡単なものを紹介します。参考になると思います。

難しいのは、コーディングするのをあきらめないことです。自分がコーディングしたかったものが完成したら

よろしくお願いします。

mladen

whitebloodcell:
linuxuserさんが投稿されたボリンジャー%bインジケータに(さらに)手を加えようとしています。ストキャスティクスと同じようにシグナルラインを表示したり、複数の期間を1つのグラフに表示できるようにしようと思っています。以前、linuxuserの助けを借りてなんとかこれを実現し、現在では同じウィンドウに2つまたは3つの期間を表示するようにセットアップしています。

今、標準偏差の計算で分数を使えるようにしようとしています。これにはiBandsの標準関数は使えないと考えていいのでしょうか?標準のBandsインジケータに付属しているコードを使ってみましたが、あまりうまくいきません。どなたか助けていただけませんか?

また、他のタイムフレームからの計算を表示できるようにしたいと思っていますが、一歩ずつ進めていくしかないと思います。これは私が最初に考えていたよりも少し難しいかもしれないことに気づきました。

ありがとうございました。

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

//| Bollinger %b - Multi.mq4 |

//| based on Bollinger Bands %b.mq4 |

//| Original indicator by Alejandro Galindo |

//| Modified and Corrected by Linuxser for forex TSD |

//| Further modifications made by whitebloodcell |

//|

//| John Bollinger original formula is: |

//| (Last - Lower BB)/(Upper BB - Lower BB) |

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

#property copyright ""

#property link ""

#property indicator_separate_window

#property indicator_buffers 6

#property indicator_color1 LightSalmon

#property indicator_color2 LightSalmon

#property indicator_color3 SkyBlue

#property indicator_color4 SkyBlue

#property indicator_color5 Green

#property indicator_color6 Green

//---- input parameters

extern bool ShowBand1 = TRUE;

extern int Timeframe_1 = 15;

extern int BBPeriod_1=5;

extern double StdDeviation_1=1.9;

extern int MainLineMAPeriod_1=1;

extern int MainLineMAMethod_1=1;

extern int SignalMAPeriod_1=2;//corresponds to %D - the signal line

extern int SignalMAMethod_1=1;

extern bool ShowBand2 = TRUE;

extern int Timeframe_2 = 15;

extern int BBPeriod_2=10;

extern double StdDeviation_2=2;

extern int MainLineMAPeriod_2=2;

extern int MainLineMAMethod_2=1;

extern int SignalMAPeriod_2=3;

extern int SignalMAMethod_2=1;

extern bool ShowBand3 = TRUE;

extern int Timeframe_3 = 15;

extern int BBPeriod_3=20;

extern double StdDeviation_3=2.0;

extern int MainLineMAPeriod_3=2;

extern int MainLineMAMethod_3=1;

extern int SignalMAPeriod_3=3;

extern int SignalMAMethod_3=1;

extern int AppliedPrice=0;

extern string s2 = "0=SMA,1=EMA,2=Smoothed,4=LWMA";

extern string s1 = "0=Close,1=Open,2=High,3=Low,4=Median,5=Typical,6=Weighted";

//---- buffers

double BLG_Buffer_1[];

double MainLineBuffer_1[];

double SignalBuffer_1[];

double BLG_Buffer_2[];

double MainLineBuffer_2[];

double SignalBuffer_2[];

double BLG_Buffer_3[];

double MainLineBuffer_3[];

double SignalBuffer_3[];

//#include

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

//| Custom indicator initialization function |

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

int init() {

string short_name;

SetIndexStyle(0,DRAW_LINE,EMPTY,2);

SetIndexBuffer(0,MainLineBuffer_1);

SetIndexStyle(1,DRAW_LINE,STYLE_DOT);

SetIndexBuffer(1,SignalBuffer_1);

SetIndexStyle(2,DRAW_LINE,EMPTY,2);

SetIndexBuffer(2,MainLineBuffer_2);

SetIndexStyle(3,DRAW_LINE,STYLE_DOT);

SetIndexBuffer(3,SignalBuffer_2);

SetIndexStyle(4,DRAW_LINE,EMPTY,2);

SetIndexBuffer(4,MainLineBuffer_3);

SetIndexStyle(5,DRAW_LINE,STYLE_DOT);

SetIndexBuffer(5,SignalBuffer_3);

//SetLevelValue(1,10);

SetLevelValue(0,0);

SetLevelValue(1,20);

SetLevelValue(2,40);

SetLevelValue(3,60);

SetLevelValue(4,80);

SetLevelValue(5,100);

SetLevelStyle(STYLE_DOT,1,DimGray);

SetIndexDrawBegin(0,BBPeriod_1);

SetIndexDrawBegin(1,BBPeriod_1+SignalMAPeriod_1);

SetIndexDrawBegin(2,BBPeriod_2);

SetIndexDrawBegin(3,BBPeriod_2+SignalMAPeriod_2);

SetIndexDrawBegin(4,BBPeriod_3);

SetIndexDrawBegin(5,BBPeriod_3+SignalMAPeriod_3);

//name for DataWindow and indicator subwindow label

short_name="Bollinger Percent B (%b)("+BBPeriod_1+","+MainLineMAPeriod_1+") ("+BBPeriod_2+","+MainLineMAPeriod_2+") ("+BBPeriod_3+","+MainLineMAPeriod_3+")";

IndicatorShortName(short_name);

return(0);

}

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

//| Momentum |

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

int start() {

if(ShowBand1==TRUE) {

if(Bars<=BBPeriod_1) return(0);

MainFunction(BLG_Buffer_1, MainLineBuffer_1, SignalBuffer_1, Timeframe_1, BBPeriod_1, StdDeviation_1,

AppliedPrice, MainLineMAPeriod_1, MainLineMAMethod_1, SignalMAPeriod_1, SignalMAMethod_1);

}

if(ShowBand2==TRUE) {

if(Bars<=BBPeriod_2) return(0);

MainFunction(BLG_Buffer_2, MainLineBuffer_2, SignalBuffer_2, Timeframe_2, BBPeriod_2, StdDeviation_2,

AppliedPrice, MainLineMAPeriod_2, MainLineMAMethod_2, SignalMAPeriod_2, SignalMAMethod_2);

}

if(ShowBand3==TRUE) {

if(Bars<=BBPeriod_3) return(0);

MainFunction(BLG_Buffer_3, MainLineBuffer_3, SignalBuffer_3, Timeframe_3, BBPeriod_3, StdDeviation_3,

AppliedPrice, MainLineMAPeriod_3, MainLineMAMethod_3, SignalMAPeriod_3, SignalMAMethod_3);

}

return(0);

}

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

void MainFunction(double &BLGBuffer[], double &MainLineBuffer[], double &SignalBuffer[], int timefame, int BBPeriod, double StdDeviation,

int AppliedPrice, int MainLineMAPeriod, int MainLineMAMethod, int SignalMAPeriod, int SignalMAMethod) {

int i=0,limit=0;

double PriceArray[];

if (ArrayRange(BLGBuffer,0) != Bars) {

ArrayResize(BLGBuffer,Bars);

ArraySetAsSeries(BLGBuffer, TRUE);

}

//number of bars already processed by indicator

int counted_bars=IndicatorCounted();

//load empty values into array until enough elements for calculation

if(counted_bars<1) {

for(i=1;i<=BBPeriod;i++) {

BLGBuffer=EMPTY_VALUE;

}//end for(i=1;i<=BandsPeriod;i++)

}//end if(counted_bars<1)

if(counted_bars>0) counted_bars--;

limit = MathMin(Bars-counted_bars,Bars-BBPeriod);

for(i=limit;i>=0;i--) {

//(Last - Lower BB)/(Upper BB - Lower BB)

BLGBuffer=((Close - iBands(NULL,timefame,BBPeriod,StdDeviation,0,AppliedPrice,MODE_LOWER,i))/

(iBands(NULL,timefame,BBPeriod,StdDeviation,0,AppliedPrice,MODE_UPPER,i)-iBands(NULL,timefame,BBPeriod,StdDeviation,0,AppliedPrice,MODE_LOWER,i)))*100;

}//end for(i=limit;i>=0;i--)

//smooth the signal by applying a moving average

for (i = limit; i >= 0; i--) MainLineBuffer = iMAOnArray(BLGBuffer, 0, MainLineMAPeriod, 0, MainLineMAMethod, i);

//create a Signal line (akin to stochastics) by further smoothing the (already smoothed) signal line.

for (i = limit; i >= 0; i--) SignalBuffer = iMAOnArray(MainLineBuffer, 0, SignalMAPeriod, 0, SignalMAMethod, i);

}//end MainFunction()

//--------------------------------------------------------------------------------

//Function: BandCalculation - Not yet working

//Purpose: Calculate the value of either the upper or lower bollinger band depen-

// on input variables.

//Inputs: Mode (int) - Calculate either upper or lower band

// limit (int) - Number of bars to calculate

// timeframe (int)

// BandsPeriod (int)

// MAMethod (int)

// BandsDeviation (double)

// AppliedPrice (int)

//Returns:

//--------------------------------------------------------------------------------

/*

void BandCalculation(int Mode, int limit, int timeframe, int BandsPeriod, int MAMethod, double BandsDeviation, int AppliedPrice) {

int i,k;

double deviation;

double sum,oldval,newres;

//if(counted_bars>0) limit++;

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

MovingBuffer=iMA(NULL,0,BandsPeriod,BandsShift,MAMethod,AppliedPrice,i);

}//end for(i=0; i<limit; i++)

i=limit;

//i=Bars-BandsPeriod+1;

//if(counted_bars>BandsPeriod-1) i=Bars-counted_bars-1;

while(i>=0) {

sum=0.0;

k=i+BandsPeriod-1;

oldval=MovingBuffer;

while(k>=i) {

newres=Close[k]-oldval;

sum+=newres*newres;

k--;

}//end while(k>=i)

//calculate deviation

deviation=BandsDeviations*MathSqrt(sum/BandsPeriod);

//Upper/Lower bands are equal to the moving average +/- deviation.

if(Mode==0) {

UpperBuffer=oldval+deviation;

}

else {

LowerBuffer=oldval-deviation;

}

i--;

}//end while(i>=0)

}//end start()

*/