//---- indicator line SetIndexStyle(0,DRAW_LINE); //---- //---- name for DataWindow and indicator subwindow label // short_name="RSI("+IntegerToString(RSIPeriod)+")"; short_name="RSI("+RSIPeriod+")"; IndicatorShortName(short_name); SetIndexLabel(0,short_name);
return(0); } //+------------------------------------------------------------------+ //| Relative Strength Index | //+------------------------------------------------------------------+ int start() { int i,counted_bars=IndicatorCounted(); double rel,negative,positive,sma,x,y,Pos,Neg; //---- if(Bars<=RSIPeriod) return(0); if(TF!=0) { string name=WindowExpertName(); for(i=0; i<Bars-counted_bars+1; i++) { int barIndex=iBarShift(NULL,TF,Time[i],false); MABuffer[i]=iCustom(Symbol(),TF,name,RSIPeriod,Levl,0,0,barIndex); } return(0); }
//---- indicator line SetIndexStyle(0,DRAW_LINE); //---- //---- name for DataWindow and indicator subwindow label // short_name="RSI("+IntegerToString(RSIPeriod)+")"; short_name="RSI("+RSIPeriod+")"; IndicatorShortName(short_name); SetIndexLabel(0,short_name);
return(0); } //+------------------------------------------------------------------+ //| Relative Strength Index | //+------------------------------------------------------------------+ int start() { int i,counted_bars=IndicatorCounted(); double rel,negative,positive,sma,x,y,Pos,Neg; //---- if(Bars<=RSIPeriod) return(0); if(TF!=0) { string name=WindowExpertName(); for(i=0; i<Bars-counted_bars+1; i++) { int barIndex=iBarShift(NULL,TF,Time[i],false); MABuffer[i]=iCustom(Symbol(),TF,name,RSIPeriod,Levl,0,0,barIndex); } return(0); }
mql4を使って、このようなアルゴリズムを実装してみたいという思いが強いです。
異なるブローカーによる2つのMT4端末があります。そのうちの1つには「排他的」インジケータがあり、(「マーケット」のように)他の端末に移動することはできません。
それがどうした!?専用」インジケーターバッファの読み取り値を、自分の端末のインジケーターに実装することは可能でしょうか?
リソースがどうにもこうにも動かない。
選択肢その1=ミハイロクに口座を開く(でよかったのか?)
選択肢その2=インジケーターの データをファイルに保存するインジケーターを書いて 保存し、このファイルを別の端末の別のインジケーターで読み込んでラインを作成する。
助けてください - RSIから変換したインジケータ-を軽くしようとしているのですが、なぜインジケータの値が違うのか理解できないのですが?
//| SVA_02.mq4 |
//| Copyright © 2006, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net/"
#property strict
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Yellow
//---- input parameters
extern int RSIPeriod=14;
extern int Levl=50;
extern int TF=0;
//---- buffers
double MABuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
string short_name;
IndicatorBuffers(1);
SetIndexBuffer(0,MABuffer);
//---- indicator line
SetIndexStyle(0,DRAW_LINE);
//----
//---- name for DataWindow and indicator subwindow label
// short_name="RSI("+IntegerToString(RSIPeriod)+")";
short_name="RSI("+RSIPeriod+")";
IndicatorShortName(short_name);
SetIndexLabel(0,short_name);
return(0);
}
//+------------------------------------------------------------------+
//| Relative Strength Index |
//+------------------------------------------------------------------+
int start()
{
int i,counted_bars=IndicatorCounted();
double rel,negative,positive,sma,x,y,Pos,Neg;
//----
if(Bars<=RSIPeriod) return(0);
if(TF!=0)
{
string name=WindowExpertName();
for(i=0; i<Bars-counted_bars+1; i++)
{
int barIndex=iBarShift(NULL,TF,Time[i],false);
MABuffer[i]=iCustom(Symbol(),TF,name,RSIPeriod,Levl,0,0,barIndex);
}
return(0);
}
i=Bars-RSIPeriod-1;
if(counted_bars>=RSIPeriod) i=Bars-counted_bars-1;
while(i>=0)
{
double sumn=0.0,sump=0.0;
if(i==Bars-RSIPeriod-1)
{
int k=Bars-2;
//---- initial accumulation
while(k>=i)
{
rel=Close[k]-Close[k+1];
if(rel>0) sump+=rel;
else sumn-=rel;
k--;
}
positive=sump/RSIPeriod;
negative=sumn/RSIPeriod;
}
else
{
//---- smoothed moving average
rel=Close[i]-Close[i+1];
if(rel>0) sump=rel;
else sumn=-rel;
positive=(Pos*(RSIPeriod-1)+sump)/RSIPeriod;
negative=(Neg*(RSIPeriod-1)+sumn)/RSIPeriod;
}
Pos=positive;
Neg=negative;
i--;
}
i=Bars-RSIPeriod-1;
if(counted_bars>=RSIPeriod) i=Bars-counted_bars-1;
while(i>=0)
{
x=positive;
y=negative;
if(x>0)sma=Close[i+1]+x;
else sma=Close[i+1]-y;
MABuffer[i]=sma;
i--;
}
//----
return(0);
}
//+------------------------------------------------------------------+
и
//| SVA_03.mq4 |
//| Copyright © 2006, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net/"
#property strict
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Yellow
//---- input parameters
extern int RSIPeriod=14;
extern int Levl=50;
extern int TF=0;
//---- buffers
double MABuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
string short_name;
IndicatorBuffers(1);
SetIndexBuffer(0,MABuffer);
//---- indicator line
SetIndexStyle(0,DRAW_LINE);
//----
//---- name for DataWindow and indicator subwindow label
// short_name="RSI("+IntegerToString(RSIPeriod)+")";
short_name="RSI("+RSIPeriod+")";
IndicatorShortName(short_name);
SetIndexLabel(0,short_name);
return(0);
}
//+------------------------------------------------------------------+
//| Relative Strength Index |
//+------------------------------------------------------------------+
int start()
{
int i,counted_bars=IndicatorCounted();
double rel,negative,positive,sma,x,y,Pos,Neg;
//----
if(Bars<=RSIPeriod) return(0);
if(TF!=0)
{
string name=WindowExpertName();
for(i=0; i<Bars-counted_bars+1; i++)
{
int barIndex=iBarShift(NULL,TF,Time[i],false);
MABuffer[i]=iCustom(Symbol(),TF,name,RSIPeriod,Levl,0,0,barIndex);
}
return(0);
}
i=Bars-RSIPeriod-1;
if(counted_bars>=RSIPeriod) i=Bars-counted_bars-1;
while(i>=0)
{
double sumn=0.0,sump=0.0;
if(i==Bars-RSIPeriod-1)
{
int k=Bars-2;
//---- initial accumulation
while(k>=i)
{
rel=Close[k]-Close[k+1];
if(rel>0) sump+=rel;
else sumn-=rel;
k--;
}
positive=sump/RSIPeriod;
negative=sumn/RSIPeriod;
}
else
{
//---- smoothed moving average
rel=Close[i]-Close[i+1];
if(rel>0) sump=rel;
else sumn=-rel;
positive=(Pos*(RSIPeriod-1)+sump)/RSIPeriod;
negative=(Neg*(RSIPeriod-1)+sumn)/RSIPeriod;
}
x=positive;
y=negative;
Pos=positive;
Neg=negative;
if(x>0)sma=Close[i+1]+x;
else sma=Close[i+1]-y;
MABuffer[i]=sma;
i--;
}
//----
return(0);
}
//+------------------------------------------------------------------+
助けてください - RSIからの変換 - インジケータを軽くしようとしているのですが、なぜインジケータの値が違うのか理解できません?
...
и
...
助けてください - RSIから変換したインジケータ-を軽くしようとしているのですが、なぜインジケータの値が違うのか理解できないのですが?
ただ、何をしようとして、何を間違えて、最終的に何を手に入れたかったのかが、まったくわからないんです。
当初は、RSIの計算時に理論上不要なバッファを削除しようとしていました。
if(counted_bars>=RSIPeriod) i=Bars-counted_bars-1;
while(i>=0)
{
double sumn=0.0,sump=0.0;
if(i==Bars-RSIPeriod-1)
{
int k=Bars-2;
//---- initial accumulation
while(k>=i)
{
rel=Close[k]-Close[k+1];
if(rel>0) sump+=rel;
else sumn-=rel;
k--;
}
positive=sump/RSIPeriod;
negative=sumn/RSIPeriod;
}
else
{
//---- smoothed moving average
rel=Close[i]-Close[i+1];
if(rel>0) sump=rel;
else sumn=-rel;
positive=(PosBuffer[i+1]*(RSIPeriod-1)+sump)/RSIPeriod;
negative=(NegBuffer[i+1]*(RSIPeriod-1)+sumn)/RSIPeriod;
}
PosBuffer[i]=positive;
NegBuffer[i]=negative;
i--;
}
PosBuffer[i]とNegBuffer[i]は実際には過去のプラスとマイナスの値で、1本より深いバーは使用されず、メモリを消費 するようになったのです。
if(counted_bars>=RSIPeriod) i=Bars-counted_bars-1;
while(i>=0)
{
double sumn=0.0,sump=0.0;
if(i==Bars-RSIPeriod-1)
{
int k=Bars-2;
//---- initial accumulation
while(k>=i)
{
rel=Close[k]-Close[k+1];
if(rel>0) sump+=rel;
else sumn-=rel;
k--;
}
positive=sump/RSIPeriod;
negative=sumn/RSIPeriod;
}
else
{
//---- smoothed moving average
rel=Close[i]-Close[i+1];
if(rel>0) sump=rel;
else sumn=-rel;
positive=(Pos*(RSIPeriod-1)+sump)/RSIPeriod;
negative=(Neg*(RSIPeriod-1)+sumn)/RSIPeriod;
}
Pos=positive;
Neg=negative;
i--;
}
さらに、私のインジケータ(コードの問題のある部分を提供)の部分をトリミングし、同一のループでさらにSVA_02を計算する。
if(counted_bars>=RSIPeriod) i=Bars-counted_bars-1;
while(i>=0)
{
x=positive;
y=negative;
if(x>0)sma=Close[i+1]+x;
else sma=Close[i+1]-y;
MABuffer[i]=sma;
i--;
}
そして、ループが同じなので、最初のループに計算を入れればいいのではと思い、SVA_03を 取得しました。
if(counted_bars>=RSIPeriod) i=Bars-counted_bars-1;
while(i>=0)
{
double sumn=0.0,sump=0.0;
if(i==Bars-RSIPeriod-1)
{
int k=Bars-2;
//---- initial accumulation
while(k>=i)
{
rel=Close[k]-Close[k+1];
if(rel>0) sump+=rel;
else sumn-=rel;
k--;
}
positive=sump/RSIPeriod;
negative=sumn/RSIPeriod;
}
else
{
//---- smoothed moving average
rel=Close[i]-Close[i+1];
if(rel>0) sump=rel;
else sumn=-rel;
positive=(Pos*(RSIPeriod-1)+sump)/RSIPeriod;
negative=(Neg*(RSIPeriod-1)+sumn)/RSIPeriod;
}
x=positive;
y=negative;
Pos=positive;
Neg=negative;
if(x>0)sma=Close[i+1]+x;
else sma=Close[i+1]-y;
MABuffer[i]=sma;
i--;
}
//----
return(0);
}
ここで最後のステップですが、MABuffer[i]の結果がSVA_02とSVA_03で異なることが判明しました。何がエラーなのか論理的に 理解できません。
03では、バーに対してプラスとマイナスを計算し、すぐに平均値を算出するために使用した。02では、平均値の計算は、プラスとマイナスで、別々のサイクルになっている?あるにはあるが、計算中のバーにはない。
確かにそうですが、実際のところはどうなのでしょうか?サイクルは同じです。論理的な間違いが何であるかを理解するためにご指導ください。
何をどう説明したらいいんだ?それはすでにここで 説明したとおりです。この説明のどこが不明確なのでしょうか?バカになってバカをやるのが生き方なのか?この後、どう説明するんだ?頭をハンマーで殴られながら?じゃあ、ヘルメットを脱げよ。
そう、「何かはあるが、数えられているバーにはない」というフレーズがあるからです。" は、前回のサイクルからプラスとマイナスの 値を持っているので、変に聞こえます。
ある最後の小節のための最後のサイクルから、何かが残っていて、それを各小節に適用するのです。正しい方法では、変数には何も残りませんが、各バーについて計算され、すぐに平均を計算するために使用されます。
意味を理解しようとしている。つまり、あなたの考えでは、正しい選択肢はSVA_03なのですね?