"ダミー "からの質問 - ページ 186 1...179180181182183184185186187188189190191192193...277 新しいコメント 削除済み 2012.09.17 08:16 #1851 Yedelkin: まだ、for文では、変数iの型を指定する必要があります。ポジションを選択するには、まずPositionGetSymbol(i)を使用し、次に選択したポジションのプロパティに目を通します。ありがとうございます、 でしょ?int TotalBullPositions() { int Counter=0; for(int i = 0; i < PositionsTotal(); i++) { if(PositionSelect(Symbol())) { if(PositionGetInteger(POSITION_MAGIC)==Magic && PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_BUY) Counter++;}} return(Counter); } Yedelkin 2012.09.17 08:32 #1852 G001: ありがとうございます、 でしょ? ええ、だいたいそのパターンですね。この行はここです。PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_BUY を指定した場合、コンパイラは警告を出す可能性が高いです。PositionGetInteger(POSITION_TYPE) を明示的に必要な enum 型にキャストすることで修正可能です。 このライン for(int i = 0; i < PositionsTotal(); i++) プログラマーによっては、昇順ではなく、降順で実行することを好む人もいます。 追記正しい行を if(PositionSelect(Symbol())) に変更したのはなぜですか? 削除済み 2012.09.17 08:46 #1853 Yedelkin: はい、だいたいそのようなパターンです。この行はここです。 を指定すると、ほとんどの場合、コンパイラは警告メッセージを生成します。PositionGetInteger(POSITION_TYPE) を明示的に必要な enum 型にキャストすることで対処できる。 このライン 昇順ではなく、降順で実行することを好むプログラマーもいます。 追記正しい行を if(PositionSelect(Symbol())) に変更したのはなぜですか?ありがとうございました。if(PositionSelect(Symbol()))に変更しました。PositionGetSymbol(i)==Symbol()もしくはこちらに変更します。PositionSelect(PositionGetSymbol(i))どのオプションが有効か確認してみます。ありがとうございます。 Yedelkin 2012.09.17 08:48 #1854 G001: に交換した。 もしくはこちらに交換します。どれが効くか試してみるPositionGetSymbol() 関数の説明を読むだけです。:) 削除済み 2012.09.17 10:17 #1855 ありがとう ございました。すでにすべてが動いている。あとは、インジケータから信号を取ること。//+------------------------------------------------------------------+ //| MACDATR.mq5 | //| Copyright © 2011, Svinozavr | //+------------------------------------------------------------------+ //---- Indicator settings #property indicator_separate_window #property indicator_buffers 4 #property indicator_plots 4 #property indicator_level1 +0.0005 #property indicator_level2 -0.0005 #property indicator_levelcolor DimGray #define RESET 0 //----- #property indicator_type1 DRAW_HISTOGRAM #property indicator_color1 Gray #property indicator_style1 STYLE_SOLID #property indicator_width1 1 #property indicator_label1 "MACD" //----- #property indicator_type2 DRAW_HISTOGRAM #property indicator_color2 Green #property indicator_style2 STYLE_SOLID #property indicator_width2 1 #property indicator_label2 "Bull" //----- #property indicator_type3 DRAW_HISTOGRAM #property indicator_color3 Red #property indicator_style3 STYLE_SOLID #property indicator_width3 1 #property indicator_label3 "Bear" //----- #property indicator_type4 DRAW_LINE #property indicator_color4 Olive #property indicator_style4 STYLE_SOLID #property indicator_width4 1 #property indicator_label4 "ATR" //----- //----- Indicator parameters //+------------------------------------------------------------------+ input uint FastEMA = 12; input uint SlowEMA = 26; input uint SignalEMA = 9; input int ATRG = 0; input ENUM_APPLIED_PRICE AppliedPrice=PRICE_CLOSE; //+------------------------------------------------------------------+ //----- double ATRmin=0; double kATR=1; int min_rates_total; int ATRHandle,MACDHandle; double MACDBuffer[],ATRBuffer[],Bull[],Bear[]; //+------------------------------------------------------------------+ //| MACD indicator initialization function | //+------------------------------------------------------------------+ void OnInit() { //----- if(ATRG) min_rates_total=int(MathMax(FastEMA,SlowEMA)+ATRG); else min_rates_total=2*int(MathMax(FastEMA,SlowEMA)); //----- int ATR; if(!ATRG) ATR=int(SlowEMA); else ATR=ATRG; ATRmin*=_Point; //----- ATRHandle=iATR(NULL,0,ATR); if(ATRHandle==INVALID_HANDLE)Print(" Íå óäàëîñü ïîëó÷èòü õåíäë èíäèêàòîðà ATR"); //----- MACDHandle=iMACD(NULL,0,FastEMA,SlowEMA,SignalEMA,AppliedPrice); if(MACDHandle==INVALID_HANDLE)Print(" Íå óäàëîñü ïîëó÷èòü õåíäë èíäèêàòîðà MACD"); //----- SetIndexBuffer(0,MACDBuffer,INDICATOR_DATA); PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,min_rates_total); ArraySetAsSeries(MACDBuffer,true); //----- SetIndexBuffer(1,Bull,INDICATOR_DATA); PlotIndexSetInteger(1,PLOT_DRAW_BEGIN,min_rates_total); ArraySetAsSeries(Bull,true); //----- SetIndexBuffer(2,Bear,INDICATOR_DATA); PlotIndexSetInteger(2,PLOT_DRAW_BEGIN,min_rates_total); ArraySetAsSeries(Bear,true); //----- SetIndexBuffer(3,ATRBuffer,INDICATOR_DATA); PlotIndexSetInteger(3,PLOT_DRAW_BEGIN,min_rates_total); ArraySetAsSeries(ATRBuffer,true); //----- string shortname; StringConcatenate(shortname,"MACDATR (",FastEMA,", ",SlowEMA,", ",SignalEMA,", ",EnumToString(AppliedPrice),")"); //----- IndicatorSetString(INDICATOR_SHORTNAME,shortname); //----- IndicatorSetInteger(INDICATOR_DIGITS,_Digits+1); //----- } //+------------------------------------------------------------------+ //| MACD iteration function | //+------------------------------------------------------------------+ int OnCalculate( const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[] ) { //----- Check for data if(rates_total<min_rates_total) return(0); //----- int to_copy,limit,i; double atr,Atr[]; datetime Time[1]; //----- if(prev_calculated>rates_total || prev_calculated<=0) { limit=rates_total-min_rates_total; } else limit=rates_total-prev_calculated; //----- ArraySetAsSeries(Atr,true); //----- to_copy=limit+1; //----- if(CopyBuffer(ATRHandle,0,0,to_copy,Atr)<=0) return(RESET); if(CopyBuffer(MACDHandle,MAIN_LINE,0,to_copy,MACDBuffer)<=0) return(RESET); //----- for(i=limit; i>=0 && !IsStopped(); i--) { atr=kATR*Atr[i]; // ATR atr=MathMax(atr,ATRmin); //----- if(MACDBuffer[i]>0) {ATRBuffer[i]=MACDBuffer[i]-atr;} if(MACDBuffer[i]<0) {ATRBuffer[i]=MACDBuffer[i]+atr;} } //----- for(i=limit; i>=0 && !IsStopped(); i--) { //----- Bear[i]=0; Bull[i]=0; //----- if(MACDBuffer[i]>0 && MACDBuffer[i+1]<MACDBuffer[i] && ATRBuffer[i]>=0) {Bull[i]=MACDBuffer[i];} if(MACDBuffer[i]<0 && MACDBuffer[i+1]>MACDBuffer[i] && ATRBuffer[i]<=0) {Bear[i]=MACDBuffer[i];} } //+------------------------------------------------------------------+ //----- Done return(rates_total); } //+------------------------------------------------------------------+これをやってもうまくいかない。double Bull[3]; double Bear[3];Indicator=iCustom(NULL,IndiTF,"MACDATR",FastEMA,SlowEMA,SignalEMA,ATRG,AppliedPrice); return(0);}.................. CopyBuffer(Indicator,1,0,3,Bull); ArraySetAsSeries(Bull,true); CopyBuffer(Indicator,2,0,3,Bear); ArraySetAsSeries(Bear,true);.....................if(Bull[1] > 0.0 && Bull[2] <= 0.0) ........................ if(Baer[1] < 0.0 && Bear[2] >= 0.0) ........................ Yedelkin 2012.09.17 10:39 #1856 G001: あとは、インジケーターからシグナルを取ること:これをやってもうまくいかない。 ハンドホイールの無効を確認していますか?Indicator=iCustom(NULL,IndiTF,"MACDATR",FastEMA,SlowEMA,SignalEMA,ATRG,AppliedPrice); 削除済み 2012.09.17 10:45 #1857 Yedelkin: ハンドルの無効性をチェックするのですか?いいえ、その内容や方法を教えてください。お忙しい中、ありがとうございました。 Yedelkin 2012.09.17 11:01 #1858 G001: いいえ、その内容や方法を教えてください。 お忙しい中、ありがとうございました。 そうですね、すでに同じようなチェックが、別のところでありますね。MACDHandle=iMACD(NULL,0,FastEMA,SlowEMA,SignalEMA,AppliedPrice); if(MACDHandle==INVALID_HANDLE)Print(" Íå óäàëîñü ïîëó÷èòü õåíäë èíäèêàòîðà MACD"); INVALID_HANDLE の場合、エラーを表示する。ResetLastError(); Indicator=iCustom(....); if(Indicator==INVALID_HANDLE) Print("_LastError=",_LastError); 削除済み 2012.09.17 11:06 #1859 Yedelkin: そうですね......同じようなチェックは、すでに別のところでしていますね。 INVALID_HANDLEが ある場合は、エラーを表示します。ありがとうございました。今更ながら理解しました、インジケーターを書いていないので、EAでも行うべきとは知りませんでした。改めてありがとうございました。 削除済み 2012.09.17 17:52 #1860 完全に疲れました。うまく開けない。インジケーターの信号を正しく読み取らない。よろしくお願いします。どこにエラーがあるのか?//+------------------------------------------------------------------+ //| Expert.mq5 | //+------------------------------------------------------------------+ // Input Parameters //+------------------------------------------------------------------+ input int TakeProfit = 550; input int StopLoss = 550; input int OrderDrive = 20; input double LotSize = 0.01; //+------------------------------------------------------------------+ input ENUM_TIMEFRAMES IndiTF=PERIOD_CURRENT; input int FastEMA = 12; input int SlowEMA = 26; input int SignalEMA = 9; input int ATRG = 0; input ENUM_APPLIED_PRICE AppliedPrice=PRICE_CLOSE; //+------------------------------------------------------------------+ MqlTradeRequest request; MqlTradeResult result; MqlTradeCheckResult check; int Indicator; double Bull[]; double Bear[]; double Ask,Bid; int i,pos,Spread; ulong StopLevel; //+------------------------------------------------------------------+ int OnInit() { ResetLastError(); Indicator=iCustom(Symbol(),IndiTF,"MACDATR",FastEMA,SlowEMA,SignalEMA,ATRG,AppliedPrice); if(Indicator==INVALID_HANDLE) Print("HandleError = ",_LastError); return(0); } //+------------------------------------------------------------------+ void OnDeinit(const int reason){} //+------------------------------------------------------------------+ void OnTick() { //----- CopyBuffer(Indicator,1,0,3,Bull); ArraySetAsSeries(Bull,true); //----- CopyBuffer(Indicator,2,0,3,Bear); ArraySetAsSeries(Bear,true); //----- Ask = NormalizeDouble(SymbolInfoDouble(Symbol(),SYMBOL_ASK),_Digits); Bid = NormalizeDouble(SymbolInfoDouble(Symbol(),SYMBOL_BID),_Digits); Spread=int(SymbolInfoInteger(Symbol(),SYMBOL_SPREAD)); StopLevel=SymbolInfoInteger(Symbol(),SYMBOL_TRADE_STOPS_LEVEL); //+------------------------------------------------------------------+ if(OrdersTotal() < 1 && PositionsTotal() < 1) { //----- Open BUY_STOP if(Bear[1] >= 0.0 && Bear[2] < 0.0) { request.action = TRADE_ACTION_PENDING; request.symbol = _Symbol; request.volume = LotSize; request.price=NormalizeDouble(Ask+StopLevel*_Point,_Digits); request.sl = NormalizeDouble(request.price - StopLoss*_Point,_Digits); request.tp = NormalizeDouble(request.price + TakeProfit*_Point,_Digits); request.type=ORDER_TYPE_BUY_STOP; request.type_filling=ORDER_FILLING_FOK; if(OrderCheck(request,check)) { OrderSend(request,result); } } //----- Open SELL_STOP if(Bull[1] <= 0.0 && Bull[2] > 0.0) { request.action = TRADE_ACTION_PENDING; request.symbol = _Symbol; request.volume = LotSize; request.price=NormalizeDouble(Bid-StopLevel*_Point,_Digits); request.sl = NormalizeDouble(request.price + StopLoss*_Point,_Digits); request.tp = NormalizeDouble(request.price - TakeProfit*_Point,_Digits); request.type=ORDER_TYPE_SELL_STOP; request.type_filling=ORDER_FILLING_FOK; if(OrderCheck(request,check)) { OrderSend(request,result); } } } } //+------------------------------------------------------------------+ 1...179180181182183184185186187188189190191192193...277 新しいコメント 取引の機会を逃しています。 無料取引アプリ 8千を超えるシグナルをコピー 金融ニュースで金融マーケットを探索 新規登録 ログイン スペースを含まないラテン文字 このメールにパスワードが送信されます エラーが発生しました Googleでログイン WebサイトポリシーおよびMQL5.COM利用規約に同意します。 新規登録 MQL5.com WebサイトへのログインにCookieの使用を許可します。 ログインするには、ブラウザで必要な設定を有効にしてください。 ログイン/パスワードをお忘れですか? Googleでログイン
まだ、for文では、変数iの型を指定する必要があります。ポジションを選択するには、まずPositionGetSymbol(i)を使用し、次に選択したポジションのプロパティに目を通します。
ありがとうございます、 でしょ?
ありがとうございます、 でしょ?
ええ、だいたいそのパターンですね。この行はここです。
を指定した場合、コンパイラは警告を出す可能性が高いです。PositionGetInteger(POSITION_TYPE) を明示的に必要な enum 型にキャストすることで修正可能です。
このライン
プログラマーによっては、昇順ではなく、降順で実行することを好む人もいます。
追記正しい行を if(PositionSelect(Symbol())) に変更したのはなぜですか?
はい、だいたいそのようなパターンです。この行はここです。
を指定すると、ほとんどの場合、コンパイラは警告メッセージを生成します。PositionGetInteger(POSITION_TYPE) を明示的に必要な enum 型にキャストすることで対処できる。
このライン
昇順ではなく、降順で実行することを好むプログラマーもいます。
追記正しい行を if(PositionSelect(Symbol())) に変更したのはなぜですか?
ありがとうございました。
に変更しました。
もしくはこちらに変更します。
どのオプションが有効か確認してみます。
ありがとうございます。
もしくはこちらに交換します。
どれが効くか試してみる
あとは、インジケータから信号を取ること。
これをやってもうまくいかない。
ハンドホイールの無効を確認していますか?
ハンドルの無効性をチェックするのですか?
そうですね、すでに同じようなチェックが、別のところでありますね。
INVALID_HANDLE の場合、エラーを表示する。
そうですね......同じようなチェックは、すでに別のところでしていますね。
INVALID_HANDLEが ある場合は、エラーを表示します。
完全に疲れました。うまく開けない。
インジケーターの信号を正しく読み取らない。
よろしくお願いします。どこにエラーがあるのか?