コーディングのヘルプ - ページ 320 1...313314315316317318319320321322323324325326327...786 新しいコメント 削除済み 2014.08.01 19:38 #3191 こんにちは。 お久しぶりです。 EAのアイデアを練っているのですが、インジケータを追加する必要があり、これをEAに組み込む方法がわかりません。 インジケータはSlope Directional Lineで、日足チャートで動作し、下位TFチャートで注文をトリガーするようにしたいのですが、インジケータのコードは以下の通りです。 //+------------------------------------------------------------------+ //| スロープ・ディレクショナル・ライン D.L.M.mq4 //| ダニエル・ルチンガー 2014 //|MQL5: MetaTraderによるFX自動売買、ストラテジーテスター、カスタム インディケータ //+------------------------------------------------------------------+ #property indicator_chart_window(インジケーターチャートウィンドウ #property indicator_buffers 2 (インジケーターバッファー2) #property indicator_color1 ブルー #プロパティ indicator_width1 3 #property indicator_color2 レッド #property indicator_width2 3 (インジケータ幅2) //---- 入力パラメータ extern int period=14; extern int method=3; // MODE_SMA extern int price=0; // PRICE_CLOSE //---- バッファ double Uptrend[]; double Dntrend[]; double ExtMapBuffer[]; //+------------------------------------------------------------------+ //| カスタムインジケータ初期化関数 //+------------------------------------------------------------------+ int init() { IndicatorBuffers(3); SetIndexBuffer(0, Uptrend); SetIndexBuffer(1, Dntrend); SetIndexBuffer(1, Dntrend); SetIndexBuffer(2, ExtMapBuffer); ArraySetAsSeries(ExtMapBuffer, true); SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,3) を設定します。 SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,3)。 IndicatorShortName("Slope Direction Line"); return(0); } //+------------------------------------------------------------------+ //|カスタムインジケータ初期化関数|||etc. //+------------------------------------------------------------------+ int deinit(){return(0);}のようになります。 double WMA(int x, int p) { return(iMA(NULL, 0, p, 0, method, price, x)); } //+------------------------------------------------------------------+ //| カスタムインジケーターイテレーション関数 //+------------------------------------------------------------------+ int start() { int counted_bars = IndicatorCounted(); if(counted_bars < 0) return(-1); int x = 0; int p = MathSqrt(period); int e = Bars - counted_bars + period + 1; double vect[], trend[]; if(e > Bars) e = Bars; ArrayResize(vect, e); ArraySetAsSeries(vect, true); ArrayResize(trend, e); ArraySetAsSeries(trend, true); for(x = 0; x < e; x++) { vect[x] = 2*WMA(x, period/2) - WMA(x, period); } for(x = 0; x < e-period; x++) ExtMapBuffer[x] = iMAOnArray(vect, 0, p, 0, method, x); for(x = e-period; x >= 0; x--) { trend[x] = trend[x+1]; if (ExtMapBuffer[x]> ExtMapBuffer[x+1]) trend[x] =1; if (ExtMapBuffer[x]<ExtMapBuffer[x+1])トレンド[x] =-1; if (trend[x]>0)の場合 { Uptrend[x] = ExtMapBuffer[x]; if (trend[x+1]<0).Uptrend[x+1]=ExtMapBuffer[x+1]。 Dntrend[x] = EMPTY_VALUE; } さもなくば if (トレンド[x]<0) { Dntrend[x] = ExtMapBuffer[x]; if (trend[x+1]>0) Dntrend[x+1]=ExtMapBuffer[x+1]; Uptrend[x] = EMPTY_VALUE; } } return(0); --------------- -------------- 私は以下のようにコーディングしました。 double UpTrend = iCustom(NULL,1440, "slope directional line D.L.M",20,3,0,1); // ここで、0 = UptrendBuffer。 double DnTrend = iCustom(NULL,1440, "slope directional line D.L.M",20,3,1,1); // ここで、1 = DntrendBuffer. double _sl = 0,_tp = 0; { if(haMode == 0 || haMode == 1) { if(UpTrend) {label("LONG Condition OK"); if(Close[0] >= srDown && Close[0] < srUp) //if(StopLoss > 0) _sl = Ask - StopLoss; _sl = srDownHT-StopLossShift; if(TakeProfit > 0) _tp = Ask + TakeProfit; if(tt && orders<MaxTrades) { openOrder(getLots(),MagicNumber,OP_BUY,_sl,_tp)。 } }} } } これは動作していないと思うので、誰か訂正してください。 ありがとうございます。 ダニエル1983 Coding help Please help translate this Loookimg for help to Jan Fouquaert 2014.08.01 20:05 #3192 Mistertoolsさんには大変お世話になりました。 しかし. 私がやりたいのは、#_FullSSA_normalize correct mtf nmcに移動平均を 適用することです。 これは、MT4のMAの力を借りて普通にM5でやると問題なく動きます。 MT4から使ってるのはこれだけなんですけどね. M1ではうまくいくときもあれば、いかないときもあります。設定に何か関係があるのかもしれません。 画像を見てください、SSAはOKですが、MAはダメです. 私は自分自身でそれをしようとしましたが、それは私にとってあまりにも複雑です、しかし、私は2つのエラーを得ただけでした、「私の仕事」の後に。 運が良かったのでしょう、それにしても、SSAは問題なく動きましたが、MAはどこにも見当たりません。 もちろん、SSAはエリートです. これは私が少し前に購入したもので、その価値はある. ファイル: ssa.png 72 kb Mladen Rakic 2014.08.01 20:21 #3193 daniel1983: こんにちは。お久しぶりです。 EAのアイデアを練っているのですが、インジケータを追加する必要があり、これをEAに組み込む方法がわかりません。 インジケータはSlope Directional Lineで、日足チャートで動作し、下位TFチャートで注文をトリガーするようにしたいのですが、インジケータのコードは以下の通りです。 //+------------------------------------------------------------------+ //| スロープ・ディレクショナル・ライン D.L.M.mq4 //| ダニエル・ルチンガー 2014 //|MQL5: MetaTraderによるFX自動売買、ストラテジーテスター、カスタム インディケータ //+------------------------------------------------------------------+ #property indicator_chart_window(インジケーターチャートウィンドウ #property indicator_buffers 2 (インジケーターバッファー2) #property indicator_color1 ブルー #プロパティ indicator_width1 3 #property indicator_color2 レッド #property indicator_width2 3 (インジケータ幅2) //---- 入力パラメータ extern int period=14; extern int method=3; // MODE_SMA extern int price=0; // PRICE_CLOSE //---- バッファ double Uptrend[]; double Dntrend[]; double ExtMapBuffer[]; //+------------------------------------------------------------------+ //| カスタムインジケータ初期化関数 //+------------------------------------------------------------------+ int init() { IndicatorBuffers(3); SetIndexBuffer(0, Uptrend); SetIndexBuffer(1, Dntrend); SetIndexBuffer(1, Dntrend); SetIndexBuffer(2, ExtMapBuffer); ArraySetAsSeries(ExtMapBuffer, true); SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,3) を設定します。 SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,3)。 IndicatorShortName("Slope Direction Line"); return(0); } //+------------------------------------------------------------------+ //|カスタムインジケータ初期化関数|||etc. //+------------------------------------------------------------------+ int deinit(){return(0);}のようになります。 double WMA(int x, int p) { return(iMA(NULL, 0, p, 0, method, price, x)); } //+------------------------------------------------------------------+ //| カスタムインジケーターイテレーション関数 //+------------------------------------------------------------------+ int start() { int counted_bars = IndicatorCounted(); if(counted_bars < 0) return(-1); int x = 0; int p = MathSqrt(period); int e = Bars - counted_bars + period + 1; double vect[], trend[]; if(e > Bars) e = Bars; ArrayResize(vect, e); ArraySetAsSeries(vect, true); ArrayResize(trend, e); ArraySetAsSeries(trend, true); for(x = 0; x < e; x++) { vect[x] = 2*WMA(x, period/2) - WMA(x, period); } for(x = 0; x < e-period; x++) ExtMapBuffer[x] = iMAOnArray(vect, 0, p, 0, method, x); for(x = e-period; x >= 0; x--) { trend[x] = trend[x+1]; if (ExtMapBuffer[x]> ExtMapBuffer[x+1]) trend[x] =1; if (ExtMapBuffer[x]<ExtMapBuffer[x+1])トレンド[x] =-1; if (trend[x]>0)の場合 { Uptrend[x] = ExtMapBuffer[x]; if (trend[x+1]<0).Uptrend[x+1]=ExtMapBuffer[x+1]。 Dntrend[x] = EMPTY_VALUE; } さもなくば if (トレンド[x]<0) { Dntrend[x] = ExtMapBuffer[x]; if (trend[x+1]>0) Dntrend[x+1]=ExtMapBuffer[x+1]; Uptrend[x] = EMPTY_VALUE; } } return(0); --------------- -------------- 私は以下のようにコーディングしました。 double UpTrend = iCustom(NULL,1440, "slope directional line D.L.M",20,3,0,1); // ここで、0 = UptrendBuffer。 double DnTrend = iCustom(NULL,1440, "slope directional line D.L.M",20,3,1,1); // ここで、1 = DntrendBuffer. double _sl = 0,_tp = 0; { if(haMode == 0 || haMode == 1) { if(UpTrend) {label("LONG Condition OK"); if(Close[0] >= srDown && Close[0] < srUp) //if(StopLoss > 0) _sl = Ask - StopLoss; _sl = srDownHT-StopLossShift; if(TakeProfit > 0) _tp = Ask + TakeProfit; if(tt && orders<MaxTrades) { openOrder(getLots(),MagicNumber,OP_BUY,_sl,_tp)。 } }} } } これは動作していないと思うので、誰か訂正してください。 ありがとうございます。 ダニエル1983 これは、勾配方向線が再描画のインジケータであるため、機能しないのです。通常のハル平均(傾斜方向線はハル平均)を使えば、簡単にできます。 削除済み 2014.08.01 22:12 #3194 Mladenさん、ありがとうございました。 HMAの投稿で、スピードコントロールができるものを見つけました。 スロープ・ディレクショナル・インディケーターと同じ発想でEAに組み込んでみたいと思います。 Hull Moving Averages 2.0 &SR lines "というHMAインジケーターを使いたいのですが これを私のEAで動作させるには、どのようなコードになるのでしょうか? 私は書きました。 input int IndicatorTF = 1440 //(日足時間枠のインジケーター) input int HMAPeriod = 35; //(このパラメータを変更することができます) input ENUM_HMAPrice = PRICE_CLOSE; //(このパラメータを変更することができます) input int HMASpeed = 2.0; //(このパラメータを変更することができます) double trendUp = iCustom(Symbol(),IndicatorTF, "Hull moving average 2.0 & sr lines",HMAPeriod,ENUM_HMAPrice,HMASpeed,0,0); double trendDn = iCustom(Symbol(),IndicatorTF, "Hull moving average 2.0 & sr lines",HMAPeriod,ENUM_HMAPrice,HMASpeed,1,0); if(trendUp > 0) { オープン 買い } インジケーターコードは //+------------------------------------------------------------------+ //| 船体移動平均 //| mladen //+------------------------------------------------------------------+ #property copyright"www.forex-tsd.com" #property link "www.forex-tsd.com" #property indicator_chart_window(インジケーターチャートウィンドウ #property indicator_buffers 3 #property indicator_color1 ライムグリーン #property indicator_color2 PaleVioletRed(ペールバイオレットレッド #property indicator_color3 PaleVioletRed (ペールバイオレットレッド) #property インジケータ_width1 2 #property indicator_width2 2(プロパティ インジケータ幅2 #property indicator_width3 2 (プロパティ インジケータ幅3) // // // // // extern string TimeFrame = "現在のタイムフレーム"; extern int HMAPeriod = 35; extern int HMAPrice = PRICE_CLOSE; extern double HMASpeed = 2.0; extern bool LinesVisible = false; extern int LinesNumber = 5; extern color ColorUp = LimeGreen; extern color ColorDown = PaleVioletRed; extern string UniqueID = "HullLines1"; extern bool alertsOn = false; extern bool alertsOnCurrent = true; extern bool alertsMessage = true; extern bool alertsSound = true; extern bool alertsSound = false; extern bool alertsEmail = false; extern bool alertsMessage = true; extern bool alertsSound = false; // // // // // double hma[]; double hmada[]; double hmadb[]; double work[]; double trend[]; int HalfPeriod; int HullPeriod; 文字列indicatorFileName; bool returnBars; bool calculateValue; int timeFrame; //------------------------------------------------------------------ // //------------------------------------------------------------------ // // // // // int init() { IndicatorBuffers(5); SetIndexBuffer(0,hma)を設定します。 SetIndexBuffer(1,hmada)。 SetIndexBuffer(2,hmadb)。 SetIndexBuffer(3,trend)を設定します。 SetIndexBuffer(4,work)を設定します。 // // // // // HMAPeriod = MathMax(2,HMAPeriod); HalfPeriod = MathFloor(HMAPeriod/HMASpeed); HullPeriod = MathFloor(HMAPeriod/HMASpeed); HullPeriod = MathFloor(MathSqrt(HMAPeriod)); indicatorFileName = WindowExpertName(); calculateValue = TimeFrame=="calculateValue"; if (calculateValue) { return(0); }. returnBars = TimeFrame=="returnBars"; if (returnBars) { return(0); }. timeFrame = stringToTimeFrame(TimeFrame); // // // // // IndicatorShortName(timeFrameToString(timeFrame)+" HMA ("+HMAPeriod+")"); return(0); void deinit() { deleteLines(); void deleteLines() { int lookForLength = StringLen(UniqueID); for (int i= ObjectsTotal()-1; i>=0; i--) { 文字列名 = ObjectName(i); if (StringSubstr(name,0,lookForLength)==UniqueID) ObjectDelete(name); } } //------------------------------------------------------------------ // //------------------------------------------------------------------ // // // // // int start() { int i,counted_bars = IndicatorCounted(); if(counted_bars<0)リターン(-1); if(counted_bars>0) counted_bars--; int limit=MathMin(Bars-counted_bars,Bars-1); if (returnBars) { hma[0] = MathMin(limit+1,Bars-1); return(0); }. // // // // // if (calculateValue || timeFrame == Period()) { if (trend[limit] == -1) クリーンポイント(limit,hmada,hmadb); for(i=limit; i>=0; i--) work = 2.0*iMA(NULL,0,HalfPeriod,0,MODE_LWMA,HMAPrice,i)-iMA(NULL,0,HMAPeriod,0,MODE_LWMA,HMAPrice,i); for(i=limit; i>=0; i--) { hma = iMAOnArray(work,0,HullPeriod,0,MODE_LWMA,i)。 hmada = EMPTY_VALUE; hmadb = EMPTY_VALUE; hmadb = EMPTY_VALUE; trend = trend; if (hma > hma) trend = 1; if (hma < hma) trend = -1; if (trend == -1) PlotPoint(i,hmada,hmadb,hma); deleteLines(); if (LinesVisible) { int k = 0; for (i=0; i<Bars && k<LinesNumber; i++) if (トレンド!=trend) { 文字列名 = UniqueID+(string)Time.ObjectCreate(name,OBJ_TREND) ObjectCreate(name,OBJ_TREND,0,Time,hma,Time+Period()*60,hma)。 if (トレンド==1) ObjectSet(name,OBJPROP_COLOR,ColorUp)。 else ObjectSet(name,OBJPROP_COLOR,ColorDown)。 k++; } manageAlerts(); return(0); // // // // // limit = MathMax(limit,MathMin(Bars-1,iCustom(NULL,timeFrame,indicatorFileName, "returnBars",0,0)*timeFrame/Period())); if (trend[limit]==-1) クリーンポイント(limit,hmada,hmadb); for (i=limit; i>=0; i--) { int y = iBarShift(NULL,timeFrame,Time).trend = iCustom(NULL); trend = iCustom(NULL,timeFrame,indicatorFileName, "calculateValue",HMAPeriod,HMAPrice,HMASpeed,LinesVisible,LinesNumber,ColorUp,ColorDown,UniqueID,alertsOn,alertsOnCurrent,alertsMessage,alertsSound,alertsEmail,3,y); hma = iCustom(NULL,timeFrame,indicatorFileName, "calculateValue",HMAPeriod,HMAPrice,HMASpeed,LinesVisible,LinesNumber,ColorUp,ColorDown,UniqueID,alertsOn,alertsOnCurrent,alertsMessage,alertsSound,alertsEmail,0,y); hma = iCustom(NULL,timeFrame,indicatorFileName).LinesVisible,LinesNumber,ColorUp,ColorDown, UniqueID,alertsOnCurrent, alertsSound,alertsEmail.0,y); hmada = EMPTY_VALUE; hmadb = EMPTY_VALUE です。 } for (i=limit;i>=0;i--) if (trend==-1) PlotPoint(i,hmada,hmadb,hma); return(0); } //+------------------------------------------------------------------- //| //+------------------------------------------------------------------- // // // // // void manageAlerts() { if (alertsOn) { if (alertsOnCurrent) int whichBar = 0; else whichBar = 1; if (トレンド[whichBar] != トレンド[whichBar+1]) { if (trend[whichBar] == 1) doAlert(whichBar, "up"); if (trend[whichBar] == -1) doAlert(whichBar, "down")。 } } } // // // // // void doAlert(int forBar, string doWhat) { 静的な文字列previousAlert="何もない"; static datetime previousTime; 文字列メッセージ if (previousAlert != doWhat || previousTime != Time[forBar]) { previousAlert = doWhat; previousTime = Time[forBar]です。 // // // // // message = Symbol()+" "+timeFrameToString(Period())+" at "+TimeToStr(TimeLocal(),TIME_SECONDS)+" HMA trend changed to "+doWhat.If (alerts)メッセージ: アラートメッセージを表示します。 if (alertsMessage) アラート(メッセージ)。 if (alertsEmail) SendMail(Symbol()+" HMA ",message)。 if (alertsSound) PlaySound("alert2.wav")。 } } //------------------------------------------------------------------- // //------------------------------------------------------------------- // // // // void CleanPoint(int i,double& first[],double& second[]) { if ((second != EMPTY_VALUE) && (second != EMPTY_VALUE)) second = EMPTY_VALUE とする。 さもなくば if ((first != EMPTY_VALUE) && (first != EMPTY_VALUE) && (first == EMPTY_VALUE)) first = EMPTY_VALUE; } // // // // // void PlotPoint(int i,double& first[],double& second[],double& from[]) { if (first == EMPTY_VALUE) { if (first == EMPTY_VALUE) { {. first = from; first = from; second = EMPTY_VALUE; } else { second = from; second = from; first = EMPTY_VALUE; } } さもなくば { first = from; second = EMPTY_VALUE; } } //------------------------------------------------------------------- // //------------------------------------------------------------------- // // // // string sTfTable[] = {"M1", "M5", "M15", "M30", "H1", "H4", "D1", "W1", "MN"}; int iTfTable[] = {1,5,15,30,60,240,1440,10080,43200}; int iTfTable[] = {1,5,15,30,60,240,1440,10080,43200}; // // // // int stringToTimeFrame(string tfs) { tfs = stringUpperCase(tfs); for (int i=ArraySize(iTfTable)-1; i>=0; i--) if (tfs==sTfTable || tfs==""+iTfTable) return(MathMax(iTfTable,Period())); return(Period())。 } 文字列 timeFrameToString(int tf) { for (int i=ArraySize(iTfTable)-1; i>=0; i--) if (tf==iTfTable) return(sTfTable); return(""); } // // // // // 文字列 stringUpperCase(string str) { 文字列 s = str; for (int length=StringLen(str)-1; length>=0; length--) { int tchar = StringGetChar(s, length); if((tchar > 96 && tchar 223 && tchar < 256)) s = StringSetChar(s, length, tchar - 32); else if(tchar > -33 && tchar < 0) s = StringSetChar(s, length, tchar + 224); return(s); } Coding help マルチタイムフレーム・インディケーター Multi Timeframe Indicators zigflip 2014.08.02 01:49 #3195 mladen: 他のインジケーターが干渉する問題ではありません(同じチャートで同じインジケーターを複数使っている場合は別)。その場合、そのインジケータは同じチャート上でマルチインスタンスインジケータとして使用するように書かれていないため、起こりえます。 MLadenさん、ありがとうございます。 もし、明らかでなければ、そのままにしておきますので、ご心配なく。 zigflip Mladen Rakic 2014.08.02 05:25 #3196 zigflip: こんにちは、MLaden 、どうもありがとうございます、しかし、私はチャート上の複数のインスタンスを使用している場合ではなく、1つだけです。もし、明らかでないのなら、心配しないで、そのままにしておきます。 zigflip 投稿したものを試してみましたが、ずれることはありませんでした。 試してみてください、多分役に立つと思います。 削除済み 2014.08.02 17:19 #3197 HMAインジケータをEAに呼び出すには? double (NULL,0, "HMA",??????) そして条件は if(trendUp) then buy, or if(trendUp =1) then buy or something like this? ありがとうございます Mladen Rakic 2014.08.02 17:46 #3198 daniel1983: HMAインジケータをEAに組み込むにはどうすればいいですか?double (NULL,0, "HMA",??????) で、条件としては if(trendUp) then buy, or if(trendUp =1) then buy or something like this? 感謝 指標のパラメータによりますが、iCustom()を使用する必要があります。 より詳細な情報、および多くの例は、こちらでご覧になれます :https://www.mql5.com/en/forum/173108 削除済み 2014.08.02 19:50 #3199 mladen: 指標パラメータに依存しますが、あなたはそのためにiCustom()を使用する必要があります。あなたはここで見つけることができる多くの例とより多くの情報:https://www.mql5.com/en/forum/173108 HMA_Russian_Color "という、スロープラインに似たHMAインジケータを見つけたのですが、買いトレンドと売りトレンドをフィルタリングするための条件に問題があります。 私は次のように書きました。 double Uptrend = iCustom(Symbol(),0, "HMA_Russian_Color",20,3,0,0); // ここで最後の0 = UptrendBuffer double Dntrend = iCustom(Symbol(),0, "HMA_Russian_Color",20,3,0,1); // 最後の1個 = DntrendBuffer //期間 = 20 / タイプ = 3 / 価格 = 0 でいいんですよね? if(Uptrend) //どう書けばいいんだろう? { 開く 買う } 注文はまだHMA下降トレンドまたは赤色の間に開かれた購入... どうか訂正してください、そして、または、これを修正するのを助けてください... ありがとうございます。 Coding help MQL4、MQL5に関する初心者からの質問、アルゴリズムやコードに関するヘルプ、ディスカッションなど。 EAを書くのに無償で協力してください。5種類のアイデア Mladen Rakic 2014.08.02 20:05 #3200 daniel1983: HMA_Russian_Color "という、スロープラインと似たようなコードを持つHMAインジケータを見つけたのですが、売りトレンドから買いトレンドをフィルタリングするための条件について、私はまだ問題を抱えています。iが書いた double Uptrend = iCustom(Symbol(),0, "HMA_Russian_Color",20,3,0,0); // 最終の 0 = UptrendBuffer. double Dntrend = iCustom(Symbol(),0, "HMA_Russian_Color",20,3,0,1); // 最後の1件 = DntrendBuffer //期間 = 20 / タイプ = 3 / 価格 = 0 でいいんですよね? if(Uptrend) //どう書けばいいんだろう? { 開く 買う } 注文はまだHMA下降トレンドまたは赤色の間に開かれた購入... ご指摘、またはご指導をお願いします。 感謝 スロープの変更は、このようなものを試してみてください。 double current = iCustom(Symbol(),0,"HMA_Russian_Color",20,3,0,0); double previous1 = iCustom(Symbol(),0,"HMA_Russian_Color",20,3,0,1); double previous2 = iCustom(Symbol(),0,"HMA_Russian_Color",20,3,0,2); if (current>previous1 && previous1<previous2) { // slope changed to up } if (currentprevious2) { // slope changed to down } 1...313314315316317318319320321322323324325326327...786 新しいコメント 取引の機会を逃しています。 無料取引アプリ 8千を超えるシグナルをコピー 金融ニュースで金融マーケットを探索 新規登録 ログイン スペースを含まないラテン文字 このメールにパスワードが送信されます エラーが発生しました Googleでログイン WebサイトポリシーおよびMQL5.COM利用規約に同意します。 新規登録 MQL5.com WebサイトへのログインにCookieの使用を許可します。 ログインするには、ブラウザで必要な設定を有効にしてください。 ログイン/パスワードをお忘れですか? Googleでログイン
こんにちは。
お久しぶりです。
EAのアイデアを練っているのですが、インジケータを追加する必要があり、これをEAに組み込む方法がわかりません。
インジケータはSlope Directional Lineで、日足チャートで動作し、下位TFチャートで注文をトリガーするようにしたいのですが、インジケータのコードは以下の通りです。
//+------------------------------------------------------------------+
//| スロープ・ディレクショナル・ライン D.L.M.mq4
//| ダニエル・ルチンガー 2014
//|MQL5: MetaTraderによるFX自動売買、ストラテジーテスター、カスタム インディケータ
//+------------------------------------------------------------------+
#property indicator_chart_window(インジケーターチャートウィンドウ
#property indicator_buffers 2 (インジケーターバッファー2)
#property indicator_color1 ブルー
#プロパティ indicator_width1 3
#property indicator_color2 レッド
#property indicator_width2 3 (インジケータ幅2)
//---- 入力パラメータ
extern int period=14;
extern int method=3; // MODE_SMA
extern int price=0; // PRICE_CLOSE
//---- バッファ
double Uptrend[];
double Dntrend[];
double ExtMapBuffer[];
//+------------------------------------------------------------------+
//| カスタムインジケータ初期化関数
//+------------------------------------------------------------------+
int init()
{
IndicatorBuffers(3);
SetIndexBuffer(0, Uptrend);
SetIndexBuffer(1, Dntrend); SetIndexBuffer(1, Dntrend);
SetIndexBuffer(2, ExtMapBuffer);
ArraySetAsSeries(ExtMapBuffer, true);
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,3) を設定します。
SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,3)。
IndicatorShortName("Slope Direction Line");
return(0);
}
//+------------------------------------------------------------------+
//|カスタムインジケータ初期化関数|||etc.
//+------------------------------------------------------------------+
int deinit(){return(0);}のようになります。
double WMA(int x, int p)
{
return(iMA(NULL, 0, p, 0, method, price, x));
}
//+------------------------------------------------------------------+
//| カスタムインジケーターイテレーション関数
//+------------------------------------------------------------------+
int start()
{
int counted_bars = IndicatorCounted();
if(counted_bars < 0)
return(-1);
int x = 0;
int p = MathSqrt(period);
int e = Bars - counted_bars + period + 1;
double vect[], trend[];
if(e > Bars)
e = Bars;
ArrayResize(vect, e);
ArraySetAsSeries(vect, true);
ArrayResize(trend, e);
ArraySetAsSeries(trend, true);
for(x = 0; x < e; x++)
{
vect[x] = 2*WMA(x, period/2) - WMA(x, period);
}
for(x = 0; x < e-period; x++)
ExtMapBuffer[x] = iMAOnArray(vect, 0, p, 0, method, x);
for(x = e-period; x >= 0; x--)
{
trend[x] = trend[x+1];
if (ExtMapBuffer[x]> ExtMapBuffer[x+1]) trend[x] =1;
if (ExtMapBuffer[x]<ExtMapBuffer[x+1])トレンド[x] =-1;
if (trend[x]>0)の場合
{ Uptrend[x] = ExtMapBuffer[x];
if (trend[x+1]<0).Uptrend[x+1]=ExtMapBuffer[x+1]。
Dntrend[x] = EMPTY_VALUE;
}
さもなくば
if (トレンド[x]<0)
{
Dntrend[x] = ExtMapBuffer[x];
if (trend[x+1]>0) Dntrend[x+1]=ExtMapBuffer[x+1];
Uptrend[x] = EMPTY_VALUE;
}
}
return(0);
---------------
--------------
私は以下のようにコーディングしました。
double UpTrend = iCustom(NULL,1440, "slope directional line D.L.M",20,3,0,1); // ここで、0 = UptrendBuffer。
double DnTrend = iCustom(NULL,1440, "slope directional line D.L.M",20,3,1,1); // ここで、1 = DntrendBuffer.
double _sl = 0,_tp = 0;
{
if(haMode == 0 || haMode == 1)
{
if(UpTrend)
{label("LONG Condition OK");
if(Close[0] >= srDown && Close[0] < srUp)
//if(StopLoss > 0) _sl = Ask - StopLoss;
_sl = srDownHT-StopLossShift;
if(TakeProfit > 0) _tp = Ask + TakeProfit;
if(tt && orders<MaxTrades)
{
openOrder(getLots(),MagicNumber,OP_BUY,_sl,_tp)。
}
}}
}
}
これは動作していないと思うので、誰か訂正してください。
ありがとうございます。
ダニエル1983
Mistertoolsさんには大変お世話になりました。
しかし.
私がやりたいのは、#_FullSSA_normalize correct mtf nmcに移動平均を 適用することです。
これは、MT4のMAの力を借りて普通にM5でやると問題なく動きます。
MT4から使ってるのはこれだけなんですけどね.
M1ではうまくいくときもあれば、いかないときもあります。設定に何か関係があるのかもしれません。
画像を見てください、SSAはOKですが、MAはダメです.
私は自分自身でそれをしようとしましたが、それは私にとってあまりにも複雑です、しかし、私は2つのエラーを得ただけでした、「私の仕事」の後に。
運が良かったのでしょう、それにしても、SSAは問題なく動きましたが、MAはどこにも見当たりません。
もちろん、SSAはエリートです.
これは私が少し前に購入したもので、その価値はある.
こんにちは。
お久しぶりです。
EAのアイデアを練っているのですが、インジケータを追加する必要があり、これをEAに組み込む方法がわかりません。
インジケータはSlope Directional Lineで、日足チャートで動作し、下位TFチャートで注文をトリガーするようにしたいのですが、インジケータのコードは以下の通りです。
//+------------------------------------------------------------------+
//| スロープ・ディレクショナル・ライン D.L.M.mq4
//| ダニエル・ルチンガー 2014
//|MQL5: MetaTraderによるFX自動売買、ストラテジーテスター、カスタム インディケータ
//+------------------------------------------------------------------+
#property indicator_chart_window(インジケーターチャートウィンドウ
#property indicator_buffers 2 (インジケーターバッファー2)
#property indicator_color1 ブルー
#プロパティ indicator_width1 3
#property indicator_color2 レッド
#property indicator_width2 3 (インジケータ幅2)
//---- 入力パラメータ
extern int period=14;
extern int method=3; // MODE_SMA
extern int price=0; // PRICE_CLOSE
//---- バッファ
double Uptrend[];
double Dntrend[];
double ExtMapBuffer[];
//+------------------------------------------------------------------+
//| カスタムインジケータ初期化関数
//+------------------------------------------------------------------+
int init()
{
IndicatorBuffers(3);
SetIndexBuffer(0, Uptrend);
SetIndexBuffer(1, Dntrend); SetIndexBuffer(1, Dntrend);
SetIndexBuffer(2, ExtMapBuffer);
ArraySetAsSeries(ExtMapBuffer, true);
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,3) を設定します。
SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,3)。
IndicatorShortName("Slope Direction Line");
return(0);
}
//+------------------------------------------------------------------+
//|カスタムインジケータ初期化関数|||etc.
//+------------------------------------------------------------------+
int deinit(){return(0);}のようになります。
double WMA(int x, int p)
{
return(iMA(NULL, 0, p, 0, method, price, x));
}
//+------------------------------------------------------------------+
//| カスタムインジケーターイテレーション関数
//+------------------------------------------------------------------+
int start()
{
int counted_bars = IndicatorCounted();
if(counted_bars < 0)
return(-1);
int x = 0;
int p = MathSqrt(period);
int e = Bars - counted_bars + period + 1;
double vect[], trend[];
if(e > Bars)
e = Bars;
ArrayResize(vect, e);
ArraySetAsSeries(vect, true);
ArrayResize(trend, e);
ArraySetAsSeries(trend, true);
for(x = 0; x < e; x++)
{
vect[x] = 2*WMA(x, period/2) - WMA(x, period);
}
for(x = 0; x < e-period; x++)
ExtMapBuffer[x] = iMAOnArray(vect, 0, p, 0, method, x);
for(x = e-period; x >= 0; x--)
{
trend[x] = trend[x+1];
if (ExtMapBuffer[x]> ExtMapBuffer[x+1]) trend[x] =1;
if (ExtMapBuffer[x]<ExtMapBuffer[x+1])トレンド[x] =-1;
if (trend[x]>0)の場合
{ Uptrend[x] = ExtMapBuffer[x];
if (trend[x+1]<0).Uptrend[x+1]=ExtMapBuffer[x+1]。
Dntrend[x] = EMPTY_VALUE;
}
さもなくば
if (トレンド[x]<0)
{
Dntrend[x] = ExtMapBuffer[x];
if (trend[x+1]>0) Dntrend[x+1]=ExtMapBuffer[x+1];
Uptrend[x] = EMPTY_VALUE;
}
}
return(0);
---------------
--------------
私は以下のようにコーディングしました。
double UpTrend = iCustom(NULL,1440, "slope directional line D.L.M",20,3,0,1); // ここで、0 = UptrendBuffer。
double DnTrend = iCustom(NULL,1440, "slope directional line D.L.M",20,3,1,1); // ここで、1 = DntrendBuffer.
double _sl = 0,_tp = 0;
{
if(haMode == 0 || haMode == 1)
{
if(UpTrend)
{label("LONG Condition OK");
if(Close[0] >= srDown && Close[0] < srUp)
//if(StopLoss > 0) _sl = Ask - StopLoss;
_sl = srDownHT-StopLossShift;
if(TakeProfit > 0) _tp = Ask + TakeProfit;
if(tt && orders<MaxTrades)
{
openOrder(getLots(),MagicNumber,OP_BUY,_sl,_tp)。
}
}}
}
}
これは動作していないと思うので、誰か訂正してください。
ありがとうございます。
ダニエル1983これは、勾配方向線が再描画のインジケータであるため、機能しないのです。通常のハル平均(傾斜方向線はハル平均)を使えば、簡単にできます。
Mladenさん、ありがとうございました。
HMAの投稿で、スピードコントロールができるものを見つけました。
スロープ・ディレクショナル・インディケーターと同じ発想でEAに組み込んでみたいと思います。
Hull Moving Averages 2.0 &SR lines "というHMAインジケーターを使いたいのですが
これを私のEAで動作させるには、どのようなコードになるのでしょうか?
私は書きました。
input int IndicatorTF = 1440 //(日足時間枠のインジケーター)
input int HMAPeriod = 35; //(このパラメータを変更することができます)
input ENUM_HMAPrice = PRICE_CLOSE; //(このパラメータを変更することができます)
input int HMASpeed = 2.0; //(このパラメータを変更することができます)
double trendUp = iCustom(Symbol(),IndicatorTF, "Hull moving average 2.0 & sr lines",HMAPeriod,ENUM_HMAPrice,HMASpeed,0,0);
double trendDn = iCustom(Symbol(),IndicatorTF, "Hull moving average 2.0 & sr lines",HMAPeriod,ENUM_HMAPrice,HMASpeed,1,0);
if(trendUp > 0)
{
オープン 買い
}
インジケーターコードは
//+------------------------------------------------------------------+
//| 船体移動平均
//| mladen
//+------------------------------------------------------------------+
#property copyright"www.forex-tsd.com"
#property link "www.forex-tsd.com"
#property indicator_chart_window(インジケーターチャートウィンドウ
#property indicator_buffers 3
#property indicator_color1 ライムグリーン
#property indicator_color2 PaleVioletRed(ペールバイオレットレッド
#property indicator_color3 PaleVioletRed (ペールバイオレットレッド)
#property インジケータ_width1 2
#property indicator_width2 2(プロパティ インジケータ幅2
#property indicator_width3 2 (プロパティ インジケータ幅3)
//
//
//
//
//
extern string TimeFrame = "現在のタイムフレーム";
extern int HMAPeriod = 35;
extern int HMAPrice = PRICE_CLOSE;
extern double HMASpeed = 2.0;
extern bool LinesVisible = false;
extern int LinesNumber = 5;
extern color ColorUp = LimeGreen;
extern color ColorDown = PaleVioletRed;
extern string UniqueID = "HullLines1";
extern bool alertsOn = false;
extern bool alertsOnCurrent = true;
extern bool alertsMessage = true; extern bool alertsSound = true;
extern bool alertsSound = false;
extern bool alertsEmail = false; extern bool alertsMessage = true; extern bool alertsSound = false;
//
//
//
//
//
double hma[];
double hmada[];
double hmadb[];
double work[];
double trend[];
int HalfPeriod;
int HullPeriod;
文字列indicatorFileName;
bool returnBars;
bool calculateValue;
int timeFrame;
//------------------------------------------------------------------
//
//------------------------------------------------------------------
//
//
//
//
//
int init()
{
IndicatorBuffers(5);
SetIndexBuffer(0,hma)を設定します。
SetIndexBuffer(1,hmada)。
SetIndexBuffer(2,hmadb)。
SetIndexBuffer(3,trend)を設定します。
SetIndexBuffer(4,work)を設定します。
//
//
//
//
//
HMAPeriod = MathMax(2,HMAPeriod);
HalfPeriod = MathFloor(HMAPeriod/HMASpeed); HullPeriod = MathFloor(HMAPeriod/HMASpeed);
HullPeriod = MathFloor(MathSqrt(HMAPeriod));
indicatorFileName = WindowExpertName();
calculateValue = TimeFrame=="calculateValue"; if (calculateValue) { return(0); }.
returnBars = TimeFrame=="returnBars"; if (returnBars) { return(0); }.
timeFrame = stringToTimeFrame(TimeFrame);
//
//
//
//
//
IndicatorShortName(timeFrameToString(timeFrame)+" HMA ("+HMAPeriod+")");
return(0);
void deinit()
{
deleteLines();
void deleteLines()
{
int lookForLength = StringLen(UniqueID);
for (int i= ObjectsTotal()-1; i>=0; i--)
{
文字列名 = ObjectName(i);
if (StringSubstr(name,0,lookForLength)==UniqueID) ObjectDelete(name);
}
}
//------------------------------------------------------------------
//
//------------------------------------------------------------------
//
//
//
//
//
int start()
{
int i,counted_bars = IndicatorCounted();
if(counted_bars<0)リターン(-1);
if(counted_bars>0) counted_bars--;
int limit=MathMin(Bars-counted_bars,Bars-1);
if (returnBars) { hma[0] = MathMin(limit+1,Bars-1); return(0); }.
//
//
//
//
//
if (calculateValue || timeFrame == Period())
{
if (trend[limit] == -1) クリーンポイント(limit,hmada,hmadb);
for(i=limit; i>=0; i--) work = 2.0*iMA(NULL,0,HalfPeriod,0,MODE_LWMA,HMAPrice,i)-iMA(NULL,0,HMAPeriod,0,MODE_LWMA,HMAPrice,i);
for(i=limit; i>=0; i--)
{
hma = iMAOnArray(work,0,HullPeriod,0,MODE_LWMA,i)。
hmada = EMPTY_VALUE;
hmadb = EMPTY_VALUE; hmadb = EMPTY_VALUE;
trend = trend;
if (hma > hma) trend = 1;
if (hma < hma) trend = -1;
if (trend == -1) PlotPoint(i,hmada,hmadb,hma);
deleteLines();
if (LinesVisible)
{
int k = 0;
for (i=0; i<Bars && k<LinesNumber; i++)
if (トレンド!=trend)
{
文字列名 = UniqueID+(string)Time.ObjectCreate(name,OBJ_TREND)
ObjectCreate(name,OBJ_TREND,0,Time,hma,Time+Period()*60,hma)。
if (トレンド==1)
ObjectSet(name,OBJPROP_COLOR,ColorUp)。
else ObjectSet(name,OBJPROP_COLOR,ColorDown)。
k++;
}
manageAlerts();
return(0);
//
//
//
//
//
limit = MathMax(limit,MathMin(Bars-1,iCustom(NULL,timeFrame,indicatorFileName, "returnBars",0,0)*timeFrame/Period()));
if (trend[limit]==-1) クリーンポイント(limit,hmada,hmadb);
for (i=limit; i>=0; i--)
{
int y = iBarShift(NULL,timeFrame,Time).trend = iCustom(NULL);
trend = iCustom(NULL,timeFrame,indicatorFileName, "calculateValue",HMAPeriod,HMAPrice,HMASpeed,LinesVisible,LinesNumber,ColorUp,ColorDown,UniqueID,alertsOn,alertsOnCurrent,alertsMessage,alertsSound,alertsEmail,3,y);
hma = iCustom(NULL,timeFrame,indicatorFileName, "calculateValue",HMAPeriod,HMAPrice,HMASpeed,LinesVisible,LinesNumber,ColorUp,ColorDown,UniqueID,alertsOn,alertsOnCurrent,alertsMessage,alertsSound,alertsEmail,0,y); hma = iCustom(NULL,timeFrame,indicatorFileName).LinesVisible,LinesNumber,ColorUp,ColorDown, UniqueID,alertsOnCurrent, alertsSound,alertsEmail.0,y);
hmada = EMPTY_VALUE;
hmadb = EMPTY_VALUE です。
}
for (i=limit;i>=0;i--) if (trend==-1) PlotPoint(i,hmada,hmadb,hma);
return(0);
}
//+-------------------------------------------------------------------
//|
//+-------------------------------------------------------------------
//
//
//
//
//
void manageAlerts()
{
if (alertsOn)
{
if (alertsOnCurrent)
int whichBar = 0;
else whichBar = 1;
if (トレンド[whichBar] != トレンド[whichBar+1])
{
if (trend[whichBar] == 1) doAlert(whichBar, "up");
if (trend[whichBar] == -1) doAlert(whichBar, "down")。
}
}
}
//
//
//
//
//
void doAlert(int forBar, string doWhat)
{
静的な文字列previousAlert="何もない";
static datetime previousTime;
文字列メッセージ
if (previousAlert != doWhat || previousTime != Time[forBar]) {
previousAlert = doWhat;
previousTime = Time[forBar]です。
//
//
//
//
//
message = Symbol()+" "+timeFrameToString(Period())+" at "+TimeToStr(TimeLocal(),TIME_SECONDS)+" HMA trend changed to "+doWhat.If (alerts)メッセージ: アラートメッセージを表示します。
if (alertsMessage) アラート(メッセージ)。
if (alertsEmail) SendMail(Symbol()+" HMA ",message)。
if (alertsSound) PlaySound("alert2.wav")。
}
}
//-------------------------------------------------------------------
//
//-------------------------------------------------------------------
//
//
//
//
void CleanPoint(int i,double& first[],double& second[])
{
if ((second != EMPTY_VALUE) && (second != EMPTY_VALUE))
second = EMPTY_VALUE とする。
さもなくば
if ((first != EMPTY_VALUE) && (first != EMPTY_VALUE) && (first == EMPTY_VALUE))
first = EMPTY_VALUE;
}
//
//
//
//
//
void PlotPoint(int i,double& first[],double& second[],double& from[])
{
if (first == EMPTY_VALUE)
{
if (first == EMPTY_VALUE) { {.
first = from;
first = from;
second = EMPTY_VALUE;
}
else {
second = from;
second = from;
first = EMPTY_VALUE;
}
}
さもなくば
{
first = from;
second = EMPTY_VALUE;
}
}
//-------------------------------------------------------------------
//
//-------------------------------------------------------------------
//
//
//
//
string sTfTable[] = {"M1", "M5", "M15", "M30", "H1", "H4", "D1", "W1", "MN"}; int iTfTable[] = {1,5,15,30,60,240,1440,10080,43200};
int iTfTable[] = {1,5,15,30,60,240,1440,10080,43200};
//
//
//
//
int stringToTimeFrame(string tfs)
{
tfs = stringUpperCase(tfs);
for (int i=ArraySize(iTfTable)-1; i>=0; i--)
if (tfs==sTfTable || tfs==""+iTfTable) return(MathMax(iTfTable,Period()));
return(Period())。
}
文字列 timeFrameToString(int tf)
{
for (int i=ArraySize(iTfTable)-1; i>=0; i--)
if (tf==iTfTable) return(sTfTable);
return("");
}
//
//
//
//
//
文字列 stringUpperCase(string str)
{
文字列 s = str;
for (int length=StringLen(str)-1; length>=0; length--)
{
int tchar = StringGetChar(s, length);
if((tchar > 96 && tchar 223 && tchar < 256))
s = StringSetChar(s, length, tchar - 32);
else if(tchar > -33 && tchar < 0)
s = StringSetChar(s, length, tchar + 224);
return(s);
}
他のインジケーターが干渉する問題ではありません(同じチャートで同じインジケーターを複数使っている場合は別)。その場合、そのインジケータは同じチャート上でマルチインスタンスインジケータとして使用するように書かれていないため、起こりえます。
MLadenさん、ありがとうございます。
もし、明らかでなければ、そのままにしておきますので、ご心配なく。
zigflip
こんにちは、MLaden 、どうもありがとうございます、しかし、私はチャート上の複数のインスタンスを使用している場合ではなく、1つだけです。
もし、明らかでないのなら、心配しないで、そのままにしておきます。
zigflip投稿したものを試してみましたが、ずれることはありませんでした。
試してみてください、多分役に立つと思います。
HMAインジケータをEAに呼び出すには?
double (NULL,0, "HMA",??????)
そして条件は
if(trendUp) then buy, or if(trendUp =1) then buy or something like this?
ありがとうございます
HMAインジケータをEAに組み込むにはどうすればいいですか?
double (NULL,0, "HMA",??????)
で、条件としては
if(trendUp) then buy, or if(trendUp =1) then buy or something like this?
感謝指標のパラメータによりますが、iCustom()を使用する必要があります。
より詳細な情報、および多くの例は、こちらでご覧になれます :https://www.mql5.com/en/forum/173108
指標パラメータに依存しますが、あなたはそのためにiCustom()を使用する必要があります。あなたはここで見つけることができる多くの例とより多くの情報:https://www.mql5.com/en/forum/173108
HMA_Russian_Color "という、スロープラインに似たHMAインジケータを見つけたのですが、買いトレンドと売りトレンドをフィルタリングするための条件に問題があります。
私は次のように書きました。
double Uptrend = iCustom(Symbol(),0, "HMA_Russian_Color",20,3,0,0); // ここで最後の0 = UptrendBuffer
double Dntrend = iCustom(Symbol(),0, "HMA_Russian_Color",20,3,0,1); // 最後の1個 = DntrendBuffer
//期間 = 20 / タイプ = 3 / 価格 = 0 でいいんですよね?
if(Uptrend) //どう書けばいいんだろう?
{
開く 買う
}
注文はまだHMA下降トレンドまたは赤色の間に開かれた購入...
どうか訂正してください、そして、または、これを修正するのを助けてください...
ありがとうございます。
HMA_Russian_Color "という、スロープラインと似たようなコードを持つHMAインジケータを見つけたのですが、売りトレンドから買いトレンドをフィルタリングするための条件について、私はまだ問題を抱えています。
iが書いた
double Uptrend = iCustom(Symbol(),0, "HMA_Russian_Color",20,3,0,0); // 最終の 0 = UptrendBuffer.
double Dntrend = iCustom(Symbol(),0, "HMA_Russian_Color",20,3,0,1); // 最後の1件 = DntrendBuffer
//期間 = 20 / タイプ = 3 / 価格 = 0 でいいんですよね?
if(Uptrend) //どう書けばいいんだろう?
{
開く 買う
}
注文はまだHMA下降トレンドまたは赤色の間に開かれた購入...
ご指摘、またはご指導をお願いします。
感謝スロープの変更は、このようなものを試してみてください。
double previous1 = iCustom(Symbol(),0,"HMA_Russian_Color",20,3,0,1);
double previous2 = iCustom(Symbol(),0,"HMA_Russian_Color",20,3,0,2);
if (current>previous1 && previous1<previous2)
{
// slope changed to up
}
if (currentprevious2)
{
// slope changed to down
}