MQL4、MQL5に関する初心者からの質問、アルゴリズムやコードに関するヘルプ、ディスカッションなど。 - ページ 564 1...557558559560561562563564565566567568569570571...1953 新しいコメント PolarSeaman 2018.06.08 20:23 #5631 Ihor Herasko:上記のコードでは、shift 変数と iy 変数の値が配列の 外れ値であるかどうかをチェックしていません。だから、すべてが論理的なのです。使用する前にその値を確認すると、エラーは解消されます。 また、より具体的には、CountBarsとTimeFrameの変数がどのように生成されるかを知っておく必要があります。CountBars =400、TimeFrame =30は、externalで静的に設定されています。 M30では問題なく、M15では飛んでしまう。 シフトとiyが外れ 値でないことを確認するには? if(TimeFrame>Period()) { ArrayCopySeries(santa1,5,Symbol(),TimeFrame); summ=CountBars+TimeFrame/Period(); shift=0; for(int iy=0; shift<summ; shift++) { if(iy>ArraySize(santa1))continue; if(shift>ArraySize(santa1))continue; if(Time[shift]<santa1[iy]) iy++;//вот эта santa1[iy] "array out of range" list[shift]=bufbuy[iy]; } } PolarSeaman 2018.06.08 22:27 #5632 もしかしたら、誰かが時間をかけてエラーの場所を調べてくれるかもしれません。 #property strict #property indicator_separate_window #property indicator_buffers 5 #property indicator_color1 Yellow #property indicator_color2 Green #property indicator_color3 Red #property indicator_color4 Yellow #property indicator_color5 Aqua extern bool Crash=FALSE; extern int TimeFrame=30; extern int Length = 7; extern int Method = 3; extern int Smoothing=2; extern int Filter=2; extern bool RealTime=TRUE; extern bool Steady= FALSE; extern bool Color = TRUE; extern bool Alerts= TRUE; extern int CountBars=400; double sik[]; double list[]; double bufbuy[]; double par6[]; double par1[]; double par2[]; double par3[]; double nugni[]; bool flag2 = TRUE; bool flag1 = TRUE; datetime time1 = 0; datetime time2 = 0; int stad=0; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int init() { string lex; IndicatorBuffers(8); SetIndexStyle(0,DRAW_LINE,STYLE_SOLID); SetIndexBuffer(0,list); SetIndexStyle(1,DRAW_LINE,STYLE_SOLID); SetIndexBuffer(1,par1); SetIndexStyle(2,DRAW_LINE,STYLE_SOLID); SetIndexBuffer(2,par2); SetIndexStyle(3,DRAW_ARROW); SetIndexArrow(3,233); SetIndexBuffer(3,par3); SetIndexStyle(4,DRAW_ARROW); SetIndexArrow(4,234); SetIndexBuffer(4,nugni); SetIndexBuffer(5,sik); SetIndexBuffer(6,par6); SetIndexBuffer(7,bufbuy); if(Length<2) Length=2; if(Method < MODE_SMA) Method = 0; if(Method> MODE_LWMA) Method = 3; if(Smoothing<0) Smoothing=0; if(Filter<0) Filter=0; if(TimeFrame<Period() && TimeFrame!=0) TimeFrame=Period(); switch(TimeFrame) { case 1: lex="M1"; break; case 5: lex="M5"; break; case 15: lex="M15"; break; case 30: lex="M30"; break; case 60: lex="H1"; break; case 240: lex="H4"; break; case 1440: lex="D1"; break; case 10080: lex="W1"; break; case 43200: lex="MN1"; break; default: lex=""; } string str_lol="trend "+lex+" | "+Length+" , "+Method+" , "+Smoothing+" , "+Filter+" | "; IndicatorShortName(str_lol); return (0); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int start() { int santa1[]; int summ; string str_lol; if(Bars<100) { IndicatorShortName("Bars less than 100"); return (0); } if(time1<iTime(NULL,TimeFrame,0)) { flag1 = FALSE; flag2 = FALSE; time1=iTime(NULL,TimeFrame,0); } if(!RealTime) { if(time2 == iTime(NULL, TimeFrame, 0)) return (0); time2=iTime(NULL,TimeFrame,0); stad=TimeFrame/Period()+1; if(stad==0) stad=1; } double MA1 = 0; double MA2 = 0; double MA3 = 0; double MA4 = 0; double MA5 = 0; if(CountBars>iBars(NULL,TimeFrame) || CountBars>Bars-Length-1) CountBars=MathMin(Bars-Length-1,iBars(NULL,TimeFrame)-Length-1); if(Crash && CountBars>0) { CountBars-=10; IndicatorShortName("Crash: "+CountBars+" "); } if(Crash && CountBars<0) IndicatorShortName("Crash"); int shift=CountBars; list[shift+1]=Close[shift+1]; bufbuy[shift+1]=Close[shift+1]; while(shift>=0) { MA1 = iMA(NULL, TimeFrame, Length, 0, Method, PRICE_HIGH, shift); MA2 = iMA(NULL, TimeFrame, Length, 0, Method, PRICE_LOW, shift); MA3 = iMA(NULL, TimeFrame, Length, 0, Method, PRICE_OPEN, shift); MA4 = iMA(NULL, TimeFrame, Length, 0, Method, PRICE_CLOSE, shift); MA5 = iMA(NULL, TimeFrame, Length, 0, Method, PRICE_CLOSE, shift + Smoothing); if(Steady==TRUE) { MA4 = iMA(NULL, TimeFrame, Length, 0, Method, PRICE_MEDIAN, shift); MA5 = iMA(NULL, TimeFrame, Length, 0, Method, PRICE_MEDIAN, shift + Smoothing); } sik[shift]=MathAbs(((MA4-MA5)/MathMax(MA1-MA2,MathMax(MA1-MA5,MA5-MA2))+(MA4-MA3)/(MA1-MA2))/2.0) *((MA4-MA5+ (MA4-MA3))/2.0); list[shift]=list[shift+1]+sik[shift]; if(Filter>0) if(MathAbs(list[shift]-(list[shift+1]))<Filter*Point) list[shift]=list[shift+1]; if(TimeFrame>Period()) bufbuy[shift]=list[shift]; shift--; } if(TimeFrame>Period()) { ArrayCopySeries(santa1,5,Symbol(),TimeFrame); summ=CountBars+TimeFrame/Period(); shift=0; for(int iy=0; shift<summ; shift++) { if(iy>ArraySize(santa1))continue; if(shift>ArraySize(santa1))continue; if(Time[shift]<santa1[iy]) iy++;//вот эта list[shift]=bufbuy[iy]; } } for(shift=CountBars; shift>=0; shift--) { par6[shift]=par6[shift+1]; if(list[shift] -(list[shift + 1])> 0.0) par6[shift] = 1; if(list[shift + 1] - list[shift] > 0.0) par6[shift] = -1; if(Color==TRUE) { if(par6[shift]>0.0) { par1[shift]=list[shift]; if(par6[shift+1]<0.0) par1[shift+1]=list[shift+1]; par2[shift]=EMPTY_VALUE; } else { if(par6[shift]<0.0) { par2[shift]=list[shift]; if(par6[shift+1]>0.0) par2[shift+1]=list[shift+1]; par1[shift]=EMPTY_VALUE; } } } if(Alerts==TRUE) { par3[shift] = EMPTY_VALUE; nugni[shift] = EMPTY_VALUE; if(par6[shift] == 1.0 && par6[shift + 1] == -1.0) par3[shift] = list[shift + 1] - (Ask - Bid); if(par6[shift] == -1.0 && par6[shift + 1] == 1.0) nugni[shift] = list[shift + 1] + (Ask - Bid); } } return (0); } //+------------------------------------------------------------------+ 削除済み 2018.06.08 23:30 #5633 PolarSeaman:もしかしたら、誰かが時間をかけてエラーの場所を調べてくれるかもしれません。 #property strict #property indicator_separate_window #property indicator_buffers 5 #property indicator_color1 Yellow #property indicator_color2 Green #property indicator_color3 Red #property indicator_color4 Yellow #property indicator_color5 Aqua extern bool Crash=FALSE; extern int TimeFrame=30; extern int Length = 7; extern int Method = 3; extern int Smoothing=2; extern int Filter=2; extern bool RealTime=TRUE; extern bool Steady= FALSE; extern bool Color = TRUE; extern bool Alerts= TRUE; extern int CountBars=400; double sik[]; double list[]; double bufbuy[]; double par6[]; double par1[]; double par2[]; double par3[]; double nugni[]; bool flag2 = TRUE; bool flag1 = TRUE; datetime time1 = 0; datetime time2 = 0; int stad=0; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int init() { string lex; IndicatorBuffers(8); SetIndexStyle(0,DRAW_LINE,STYLE_SOLID); SetIndexBuffer(0,list); SetIndexStyle(1,DRAW_LINE,STYLE_SOLID); SetIndexBuffer(1,par1); SetIndexStyle(2,DRAW_LINE,STYLE_SOLID); SetIndexBuffer(2,par2); SetIndexStyle(3,DRAW_ARROW); SetIndexArrow(3,233); SetIndexBuffer(3,par3); SetIndexStyle(4,DRAW_ARROW); SetIndexArrow(4,234); SetIndexBuffer(4,nugni); SetIndexBuffer(5,sik); SetIndexBuffer(6,par6); SetIndexBuffer(7,bufbuy); if(Length<2) Length=2; if(Method < MODE_SMA) Method = 0; if(Method> MODE_LWMA) Method = 3; if(Smoothing<0) Smoothing=0; if(Filter<0) Filter=0; if(TimeFrame<Period() && TimeFrame!=0) TimeFrame=Period(); switch(TimeFrame) { case 1: lex="M1"; break; case 5: lex="M5"; break; case 15: lex="M15"; break; case 30: lex="M30"; break; case 60: lex="H1"; break; case 240: lex="H4"; break; case 1440: lex="D1"; break; case 10080: lex="W1"; break; case 43200: lex="MN1"; break; default: lex=""; } string str_lol="trend "+lex+" | "+string(Length)+" , "+string(Method)+" , "+string(Smoothing)+" , "+string(Filter)+" | "; IndicatorShortName(str_lol); return (0); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int start() { int santa1[]; int summ; string str_lol; if(Bars<100) { IndicatorShortName("Bars less than 100"); return (0); } if(time1<iTime(NULL,TimeFrame,0)) { flag1 = FALSE; flag2 = FALSE; time1=iTime(NULL,TimeFrame,0); } if(!RealTime) { if(time2 == iTime(NULL, TimeFrame, 0)) return (0); time2=iTime(NULL,TimeFrame,0); stad=TimeFrame/Period()+1; if(stad==0) stad=1; } double MA1 = 0; double MA2 = 0; double MA3 = 0; double MA4 = 0; double MA5 = 0; if(CountBars>iBars(NULL,TimeFrame) || CountBars>Bars-Length-1) CountBars=MathMin(Bars-Length-1,iBars(NULL,TimeFrame)-Length-1); if(Crash && CountBars>0) { CountBars-=10; IndicatorShortName("Crash: "+string(CountBars)+" "); } if(Crash && CountBars<0) IndicatorShortName("Crash"); int shift=CountBars; list[shift+1]=Close[shift+1]; bufbuy[shift+1]=Close[shift+1]; while(shift>=0) { MA1 = iMA(NULL, TimeFrame, Length, 0, Method, PRICE_HIGH, shift); MA2 = iMA(NULL, TimeFrame, Length, 0, Method, PRICE_LOW, shift); MA3 = iMA(NULL, TimeFrame, Length, 0, Method, PRICE_OPEN, shift); MA4 = iMA(NULL, TimeFrame, Length, 0, Method, PRICE_CLOSE, shift); MA5 = iMA(NULL, TimeFrame, Length, 0, Method, PRICE_CLOSE, shift + Smoothing); if(Steady==TRUE) { MA4 = iMA(NULL, TimeFrame, Length, 0, Method, PRICE_MEDIAN, shift); MA5 = iMA(NULL, TimeFrame, Length, 0, Method, PRICE_MEDIAN, shift + Smoothing); } sik[shift]=MathAbs(((MA4-MA5)/MathMax(MA1-MA2,MathMax(MA1-MA5,MA5-MA2))+(MA4-MA3)/(MA1-MA2))/2.0) *((MA4-MA5+ (MA4-MA3))/2.0); list[shift]=list[shift+1]+sik[shift]; if(Filter>0) if(MathAbs(list[shift]-(list[shift+1]))<Filter*Point) list[shift]=list[shift+1]; if(TimeFrame>Period()) bufbuy[shift]=list[shift]; shift--; } if(TimeFrame>Period()) { ArrayCopySeries(santa1,5,Symbol(),TimeFrame); summ=CountBars+TimeFrame/Period(); shift=0; for(int iy=0; shift<summ; shift++) { if(iy>ArraySize(santa1))continue; if(shift>ArraySize(santa1))continue; if(Time[shift]<santa1[iy]) iy++;//вот эта list[shift]=bufbuy[iy]; } } for(shift=CountBars; shift>=0; shift--) { par6[shift]=par6[shift+1]; if(list[shift] -(list[shift + 1])> 0.0) par6[shift] = 1; if(list[shift + 1] - list[shift] > 0.0) par6[shift] = -1; if(Color==TRUE) { if(par6[shift]>0.0) { par1[shift]=list[shift]; if(par6[shift+1]<0.0) par1[shift+1]=list[shift+1]; par2[shift]=EMPTY_VALUE; } else { if(par6[shift]<0.0) { par2[shift]=list[shift]; if(par6[shift+1]>0.0) par2[shift+1]=list[shift+1]; par1[shift]=EMPTY_VALUE; } } } if(Alerts==TRUE) { par3[shift] = EMPTY_VALUE; nugni[shift] = EMPTY_VALUE; if(par6[shift] == 1.0 && par6[shift + 1] == -1.0) par3[shift] = list[shift + 1] - (Ask - Bid); if(par6[shift] == -1.0 && par6[shift + 1] == 1.0) nugni[shift] = list[shift + 1] + (Ask - Bid); } } return (0); } //+ 削除済み 2018.06.08 23:36 #5634 ファイルにデータを改行で 追加する方法を教えてください。 私の書き込み機能 void Write(string file,string text,bool print) { filehandle=FileOpen(file,FILE_WRITE|FILE_CSV,'|'); FileWriteString(filehandle,text); FileClose(filehandle); } これが私が送ったものです。 Write(subfolder+"\\"+string(TF)+"\\TS"+string(ts)+"\\"+string(st)+"_"+string(st2)+".txt", string(mv)+"|"+ string(b)+"|"+ string(rs)+"|"+ string(m1)+"|"+ string(m2)+"|" ,NoPrint); その下にさらに行を追加する必要がありますね。 Write(subfolder+"\\"+string(TF)+"\\TS"+string(ts)+"\\"+string(st)+"_"+string(st2)+".txt", string(mv)+"|"+ string(b)+"|"+ string(rs)+"|"+ string(m1)+"|"+ string(m2)+"|" ,NoPrint); Alekseu Fedotov 2018.06.09 01:46 #5635 Nikolay Gaylis:ファイルにデータを改行で 追加する方法を教えてください。 私の書き込み機能 これが私が送ったものです。 線の下にデータを追加したい。 FileSeek()にSEEK_ENDフラグを付けると、より効果的です。< PolarSeaman 2018.06.09 01:58 #5636 Nikolay Gaylis: コードで代用したのは //+------------------------------------------------------------------+まで //+ が、どうにもならない) Yuri Tikhonov 2018.06.09 06:25 #5637 Alpariのアドバイザーが、23-45から1-00まで取引して、ロットサイズは最大を超えないのに、[Invalid volume]でよく失敗するのはなぜか、皆さん教えてください。 ログを添付しましたが、他のブローカーではこのようなエラーはありません。 ファイル: Alpari_Logs.txt 35 kb Roman Sharanov 2018.06.09 09:04 #5638 こちらの例からコードを引用して、対処しています メソッドを定義しました。 bool CControlsDialog::OnEvent(const int id,const long &lparam,const double &dparam,const string &sparam){ //.... } すでに定義されており、ボディがあると文句を言われる。 質問:どこに定義されているのですか? Документация по MQL5: Стандартная библиотека / Панели и диалоги / CButton www.mql5.com //| ControlsButton.mq5 | //| Copyright 2017, MetaQuotes Software Corp. | //| https://www.mql5.com | //| defines | INDENT_LEFT (11) ... e33 2018.06.09 14:50 #5639 Roman Sharanov:こちらの例からコードを引用して、対処しています メソッドを定義しました。 すでに定義されており、ボディがあると文句を言われる。 質問:どこに定義されているのですか?ターミナルフォルダを 検索してみてください。ControlsDialog.mqhというファイルがあり、その中にOnEvent()があります。 YanSay 2018.06.09 20:19 #5640 こんばんは!(^o^) 保証金の割合に基づいて取引のロットを計算するための普遍的な(異なる商品用の)コードを追加する方法に困惑しています。 こんな感じで作りました。 input double MaximumRisk=0.02; //Риск в сделке от депозита {Lots = NormalizeDouble(((AccountBalance()*MaximumRisk)/((MathAbs(Price-SL))/Point)/((MarketInfo(Symbol(),MODE_LOTSIZE)*(MarketInfo(Symbol(),MODE_ASK)+Point)) -(MarketInfo(Symbol(),MODE_LOTSIZE)*MarketInfo(Symbol(),MODE_ASK)))),Digits);} プライス(始 値)とSL(ストップロス)は別々に計算されます。 クォート通貨がドルであるペア(例:EURUSD)、インデックスSPX500および金については、すべて正しく計算されますが、ドルがクォートの最初のペア(例:USDJPY)については動作しません。 お願いです、何が足りないのでしょうか? 1...557558559560561562563564565566567568569570571...1953 新しいコメント 取引の機会を逃しています。 無料取引アプリ 8千を超えるシグナルをコピー 金融ニュースで金融マーケットを探索 新規登録 ログイン スペースを含まないラテン文字 このメールにパスワードが送信されます エラーが発生しました Googleでログイン WebサイトポリシーおよびMQL5.COM利用規約に同意します。 新規登録 MQL5.com WebサイトへのログインにCookieの使用を許可します。 ログインするには、ブラウザで必要な設定を有効にしてください。 ログイン/パスワードをお忘れですか? Googleでログイン
上記のコードでは、shift 変数と iy 変数の値が配列の 外れ値であるかどうかをチェックしていません。だから、すべてが論理的なのです。使用する前にその値を確認すると、エラーは解消されます。
また、より具体的には、CountBarsとTimeFrameの変数がどのように生成されるかを知っておく必要があります。
CountBars =400、TimeFrame =30は、externalで静的に設定されています。
M30では問題なく、M15では飛んでしまう。
シフトとiyが外れ 値でないことを確認するには?
もしかしたら、誰かが時間をかけてエラーの場所を調べてくれるかもしれません。
もしかしたら、誰かが時間をかけてエラーの場所を調べてくれるかもしれません。
ファイルにデータを改行で 追加する方法を教えてください。
私の書き込み機能
これが私が送ったものです。
その下にさらに行を追加する必要がありますね。
ファイルにデータを改行で 追加する方法を教えてください。
私の書き込み機能
これが私が送ったものです。
線の下にデータを追加したい。
FileSeek()にSEEK_ENDフラグを付けると、より効果的です。
<コードで代用したのは
//+------------------------------------------------------------------+
まで
//+
が、どうにもならない)
Alpariのアドバイザーが、23-45から1-00まで取引して、ロットサイズは最大を超えないのに、[Invalid volume]でよく失敗するのはなぜか、皆さん教えてください。
ログを添付しましたが、他のブローカーではこのようなエラーはありません。
こちらの例からコードを引用して、対処しています
メソッドを定義しました。
すでに定義されており、ボディがあると文句を言われる。
質問:どこに定義されているのですか?
こちらの例からコードを引用して、対処しています
メソッドを定義しました。
すでに定義されており、ボディがあると文句を言われる。
質問:どこに定義されているのですか?
こんばんは!(^o^)
保証金の割合に基づいて取引のロットを計算するための普遍的な(異なる商品用の)コードを追加する方法に困惑しています。
こんな感じで作りました。
プライス(始 値)とSL(ストップロス)は別々に計算されます。
クォート通貨がドルであるペア(例:EURUSD)、インデックスSPX500および金については、すべて正しく計算されますが、ドルがクォートの最初のペア(例:USDJPY)については動作しません。
お願いです、何が足りないのでしょうか?