[ARCHIVE] フォーラムを散らかさないように、どんなルーキーでも質問してください。プロフェッショナルは、通り過ぎないでください。Nowhere without you - 3. - ページ 204 1...197198199200201202203204205206207208209210211...652 新しいコメント Victor Nikolaev 2011.09.22 14:43 #2031 skyjet: これはネストされた関数ではなく、基本的なMACDサンプルEAの一部です。計算されたロットを追加するようにしています。メインで唯一のstart()関数 それなら、コード全体を見る必要があります。表示されているのは、関数 noobys 2011.09.22 14:48 #2032 そこへ :)ただ、上記のロット計算をどう収めるかがわからない。//+------------------------------------------------------------------+ //| MACD Sample.mq4 | //| Copyright © 2005, MetaQuotes Software Corp. | //| http://www.metaquotes.net/ | //+------------------------------------------------------------------+ extern double TakeProfit = 50; extern double Lots = 0.1; extern double TrailingStop = 30; extern double MACDOpenLevel=3; extern double MACDCloseLevel=2; extern double MATrendPeriod=26; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int start() { double MacdCurrent, MacdPrevious, SignalCurrent; double SignalPrevious, MaCurrent, MaPrevious; int cnt, ticket, total; // initial data checks // it is important to make sure that the expert works with a normal // chart and the user did not make any mistakes setting external // variables (Lots, StopLoss, TakeProfit, // TrailingStop) in our case, we check TakeProfit // on a chart of less than 100 bars if(Bars<100) { Print("bars less than 100"); return(0); } if(TakeProfit<10) { Print("TakeProfit less than 10"); return(0); // check TakeProfit } // to simplify the coding and speed up access // data are put into internal variables MacdCurrent=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,0); MacdPrevious=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,1); SignalCurrent=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,0); SignalPrevious=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,1); MaCurrent=iMA(NULL,0,MATrendPeriod,0,MODE_EMA,PRICE_CLOSE,0); MaPrevious=iMA(NULL,0,MATrendPeriod,0,MODE_EMA,PRICE_CLOSE,1); total=OrdersTotal(); if(total<1) { // no opened orders identified if(AccountFreeMargin()<(1000*Lots)) { Print("We have no money. Free Margin = ", AccountFreeMargin()); return(0); } // check for long position (BUY) possibility if(MacdCurrent<0 && MacdCurrent>SignalCurrent && MacdPrevious<SignalPrevious && MathAbs(MacdCurrent)>(MACDOpenLevel*Point) && MaCurrent>MaPrevious) { ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,Ask+TakeProfit*Point,"macd sample",16384,0,Green); if(ticket>0) { if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice()); } else Print("Error opening BUY order : ",GetLastError()); return(0); } // check for short position (SELL) possibility if(MacdCurrent>0 && MacdCurrent<SignalCurrent && MacdPrevious>SignalPrevious && MacdCurrent>(MACDOpenLevel*Point) && MaCurrent<MaPrevious) { ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,Bid-TakeProfit*Point,"macd sample",16384,0,Red); if(ticket>0) { if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("SELL order opened : ",OrderOpenPrice()); } else Print("Error opening SELL order : ",GetLastError()); return(0); } return(0); } // it is important to enter the market correctly, // but it is more important to exit it correctly... for(cnt=0;cnt<total;cnt++) { OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); if(OrderType()<=OP_SELL && // check for opened position OrderSymbol()==Symbol()) // check for symbol { if(OrderType()==OP_BUY) // long position is opened { // should it be closed? if(MacdCurrent>0 && MacdCurrent<SignalCurrent && MacdPrevious>SignalPrevious && MacdCurrent>(MACDCloseLevel*Point)) { OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet); // close position return(0); // exit } // check for trailing stop if(TrailingStop>0) { if(Bid-OrderOpenPrice()>Point*TrailingStop) { if(OrderStopLoss()<Bid-Point*TrailingStop) { OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green); return(0); } } } } else // go to short position { // should it be closed? if(MacdCurrent<0 && MacdCurrent>SignalCurrent && MacdPrevious<SignalPrevious && MathAbs(MacdCurrent)>(MACDCloseLevel*Point)) { OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet); // close position return(0); // exit } // check for trailing stop if(TrailingStop>0) { if((OrderOpenPrice()-Ask)>(Point*TrailingStop)) { if((OrderStopLoss()>(Ask+Point*TrailingStop)) || (OrderStopLoss()==0)) { OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red); return(0); } } } } } } return(0); } // the end. Victor Nikolaev 2011.09.22 15:09 #2033 skyjet: そこへ :)ただ、上記のロット計算をどう収めるかがわからない。//+------------------------------------------------------------------+ //| MACD Sample.mq4 | //| Copyright © 2005, MetaQuotes Software Corp. | //| http://www.metaquotes.net/ | //+------------------------------------------------------------------+ extern double TakeProfit = 50; extern double Lots = 0.1; extern double TrailingStop = 30; extern double MACDOpenLevel=3; extern double MACDCloseLevel=2; extern double MATrendPeriod=26; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int start() { double MacdCurrent, MacdPrevious, SignalCurrent; double SignalPrevious, MaCurrent, MaPrevious; int cnt, ticket, total; // initial data checks // it is important to make sure that the expert works with a normal // chart and the user did not make any mistakes setting external // variables (Lots, StopLoss, TakeProfit, // TrailingStop) in our case, we check TakeProfit // on a chart of less than 100 bars if(Bars<100) { Print("bars less than 100"); return(0); } if(TakeProfit<10) { Print("TakeProfit less than 10"); return(0); // check TakeProfit } // to simplify the coding and speed up access // data are put into internal variables MacdCurrent=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,0); MacdPrevious=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,1); SignalCurrent=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,0); SignalPrevious=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,1); MaCurrent=iMA(NULL,0,MATrendPeriod,0,MODE_EMA,PRICE_CLOSE,0); MaPrevious=iMA(NULL,0,MATrendPeriod,0,MODE_EMA,PRICE_CLOSE,1); total=OrdersTotal(); if(total<1) { // no opened orders identified if(AccountFreeMargin()<(1000*Lots)) { Print("We have no money. Free Margin = ", AccountFreeMargin()); return(0); } // check for long position (BUY) possibility if(MacdCurrent<0 && MacdCurrent>SignalCurrent && MacdPrevious<SignalPrevious && MathAbs(MacdCurrent)>(MACDOpenLevel*Point) && MaCurrent>MaPrevious) { ticket=OrderSend(Symbol(),OP_BUY,Lots(),Ask,3,0,Ask+TakeProfit*Point,"macd sample",16384,0,Green); if(ticket>0) { if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice()); } else Print("Error opening BUY order : ",GetLastError()); return(0); } // check for short position (SELL) possibility if(MacdCurrent>0 && MacdCurrent<SignalCurrent && MacdPrevious>SignalPrevious && MacdCurrent>(MACDOpenLevel*Point) && MaCurrent<MaPrevious) { ticket=OrderSend(Symbol(),OP_SELL,Lots(),Bid,3,0,Bid-TakeProfit*Point,"macd sample",16384,0,Red); if(ticket>0) { if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("SELL order opened : ",OrderOpenPrice()); } else Print("Error opening SELL order : ",GetLastError()); return(0); } return(0); } // it is important to enter the market correctly, // but it is more important to exit it correctly... for(cnt=0;cnt<total;cnt++) { OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); if(OrderType()<=OP_SELL && // check for opened position OrderSymbol()==Symbol()) // check for symbol { if(OrderType()==OP_BUY) // long position is opened { // should it be closed? if(MacdCurrent>0 && MacdCurrent<SignalCurrent && MacdPrevious>SignalPrevious && MacdCurrent>(MACDCloseLevel*Point)) { OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet); // close position return(0); // exit } // check for trailing stop if(TrailingStop>0) { if(Bid-OrderOpenPrice()>Point*TrailingStop) { if(OrderStopLoss()<Bid-Point*TrailingStop) { OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green); return(0); } } } } else // go to short position { // should it be closed? if(MacdCurrent<0 && MacdCurrent>SignalCurrent && MacdPrevious<SignalPrevious && MathAbs(MacdCurrent)>(MACDCloseLevel*Point)) { OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet); // close position return(0); // exit } // check for trailing stop if(TrailingStop>0) { if((OrderOpenPrice()-Ask)>(Point*TrailingStop)) { if((OrderStopLoss()>(Ask+Point*TrailingStop)) || (OrderStopLoss()==0)) { OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red); return(0); } } } } } } return(0); } // the end. double Lots() { double lot; lot=(AccountFreeMargin()*AccountLeverage()*Risk)/(MarketInfo(Symbol(), MODE_LOTSIZE)); lot=NormalizeDouble(lot,1); return(lot); } それは、次のようなものです。 noobys 2011.09.22 15:17 #2034 Vinin: こんな感じです。 ご協力ありがとうございました Victor Nikolaev 2011.09.22 15:26 #2035 skyjet: ご協力ありがとうございました ロット計算機能のみ普遍化すること 削除済み 2011.09.22 16:02 #2036 こんにちは。 私はこの仕事の初心者です。そこで、皆さんのお力をお借りしたいのです。 以下はコードの一部です。 int start() { if(IsTesting())return; if (AccountBalance() < 111 ){ Alert("Erorr Balance"); return; if (AccountNumber() != 11111){ Alert("Error AccountNumber"); return;} } 私は、最初に金額の残高を確認し、111より少ない場合は警告と戻り、多い場合は口座番号を 確認し、口座が正しい場合は取引し、そうでない場合は警告と戻るようにしたいのですが...。 しかし、なぜかAccountBalanceや AccountNumberを 削除すると個別にしか実行されない...。 おそらくヌーボー的な質問だと思いますが、何が足りなかったのでしょうか? しゃい Victor Nikolaev 2011.09.22 16:10 #2037 volodin_andrei: こんにちは。 私はこの仕事の初心者です。そこで、皆さんのお力をお借りしたいのです。 以下はコードの一部です。 私は、最初に金額の残高を確認し、111より少ない場合は警告と戻り、多い場合は口座番号を確認し、口座が正しい場合は取引し、そうでない場合は警告と戻るようにしたいのですが...。 しかし、なぜかAccountBalanceや AccountNumberを 削除すると個別にしか実行されない...。 おそらくヌーボー的な質問だと思いますが、何が足りなかったのでしょうか? しゃい ブラケット(変形ブラケット)は試されましたか? int start() { if(IsTesting())return; if (AccountBalance() < 111 ) { Alert("Erorr Balance"); return(0); } if (AccountNumber() != 11111) { Alert("Error AccountNumber"); return(0); } return(0); } ブラケットは十分にあったが、間違った場所にあった 削除済み 2011.09.22 16:38 #2038 皆さんの助けを借りていじったのですが、コンパイルに失敗するのでスクリーンショットです、きっと余分なブラケットか...です。:( DDFedor 2011.09.22 16:42 #2039 括弧の追跡機能があるテキストエディタを探す。 Всеволод 2011.09.22 16:47 #2040 Vinin: また、他の商品、他のEAのオープンポジションがあった場合は?何を書いているのかを考える。 残念ながら、この条件の説明は完全を装っておらず、「40番目の注文」の概念を完全に開示していません。 それなら、標準の関数を使うのではなく、EAのオープンオーダーの数を変数で管理しておく方がずっと簡単でしょう。この状況では、保留中のオーダーは別問題です。 1...197198199200201202203204205206207208209210211...652 新しいコメント 取引の機会を逃しています。 無料取引アプリ 8千を超えるシグナルをコピー 金融ニュースで金融マーケットを探索 新規登録 ログイン スペースを含まないラテン文字 このメールにパスワードが送信されます エラーが発生しました Googleでログイン WebサイトポリシーおよびMQL5.COM利用規約に同意します。 新規登録 MQL5.com WebサイトへのログインにCookieの使用を許可します。 ログインするには、ブラウザで必要な設定を有効にしてください。 ログイン/パスワードをお忘れですか? Googleでログイン
これはネストされた関数ではなく、基本的なMACDサンプルEAの一部です。計算されたロットを追加するようにしています。メインで唯一のstart()関数
それなら、コード全体を見る必要があります。表示されているのは、関数
こんな感じです。
ご協力ありがとうございました
ロット計算機能のみ普遍化すること
こんにちは。
私はこの仕事の初心者です。そこで、皆さんのお力をお借りしたいのです。
以下はコードの一部です。
私は、最初に金額の残高を確認し、111より少ない場合は警告と戻り、多い場合は口座番号を 確認し、口座が正しい場合は取引し、そうでない場合は警告と戻るようにしたいのですが...。
しかし、なぜかAccountBalanceや AccountNumberを 削除すると個別にしか実行されない...。
おそらくヌーボー的な質問だと思いますが、何が足りなかったのでしょうか?
しゃい
こんにちは。
私はこの仕事の初心者です。そこで、皆さんのお力をお借りしたいのです。
以下はコードの一部です。
私は、最初に金額の残高を確認し、111より少ない場合は警告と戻り、多い場合は口座番号を確認し、口座が正しい場合は取引し、そうでない場合は警告と戻るようにしたいのですが...。
しかし、なぜかAccountBalanceや AccountNumberを 削除すると個別にしか実行されない...。
おそらくヌーボー的な質問だと思いますが、何が足りなかったのでしょうか?
しゃい
ブラケット(変形ブラケット)は試されましたか?
ブラケットは十分にあったが、間違った場所にあった
皆さんの助けを借りていじったのですが、コンパイルに失敗するのでスクリーンショットです、きっと余分なブラケットか...です。:(
また、他の商品、他のEAのオープンポジションがあった場合は?何を書いているのかを考える。