MQL4、MQL5に関する初心者からの質問、アルゴリズムやコードに関するヘルプ、ディスカッションなど。 - ページ 1538

 
出金方法を教えてください。
 
昨日リクエストを送信して、24時間以上経過しても何の連絡もない。
 
ivlyeva.tatyana6:
昨日リクエストを送ったのですが、1日以上経過して沈黙しています。

1.最寄りのATMに行き、カードを挿入し、PINコードを入力する...。

2.近くの銀行に行き、目を合わせ、そして状況を追いかける...。

3.市場へ行く。3)市場へ行く。銀行へ行く。資金を引き出す(自分だけでなく、すべて引き出すことができる・・・)・・・。

4.MMMからお金を引き出さなければならないのであれば、戦車だって役に立ちませんよ。

って、マジかよ!

 
//+------------------------------------------------------------------+
//|                                                  MACD Sample.mq4 |
//|                   Copyright 2005-2014, MetaQuotes Software Corp. |
//|                                              http://www.mql4.com |
//+------------------------------------------------------------------+
#property copyright   "2005-2014, MetaQuotes Software Corp."
#property link        "http://www.mql4.com"
input double TakeProfit    =3160;
input double Lots          =0.5;
input double TrailingStop  =1040;
input int OpenLevel =22;
input int CloseLevel=77;
input int    Period =85;
input int    Period1 =57;
int LastBars=0;
extern int Magic = 110725;
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnTick(void)
  {
   
 
   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
//---
//--- Trade only if new bar has arrived
   if(LastBars!=Bars) LastBars=Bars;
   else return(0);
   if(Bars<100)
     {
      Print("bars less than 100");
      return;
     }
   if(TakeProfit<10)
     {
      Print("TakeProfit less than 10");
      return;
     }
//--- to simplify the coding and speed up access data are put into internal variables
   
   total=OrdersTotal();
   if(total<1)
     {
      //--- no opened orders identified
      if(AccountFreeMargin()<(1000*Lots))
        {
         Print("We have no money. Free Margin = ",AccountFreeMargin());
         return;
        }
      //--- check for long position (BUY) possibility
     if(iRSI(NULL,0,OpenLevel,PRICE_LOW,Period)>iRSI(NULL,0,CloseLevel,PRICE_HIGH,Period1)) 
        {
         ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Bid-TakeProfit*Point,Bid+TakeProfit*Point,"USDCADH4",Magic,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;
        }
      //--- check for short position (SELL) possibility
      if(iRSI(NULL,0,OpenLevel,PRICE_LOW,Period1)<iRSI(NULL,0,CloseLevel,PRICE_HIGH,Period)) 
        {
         ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Ask+TakeProfit*Point,Ask-TakeProfit*Point,"USDCADH4",Magic,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());
        }
      //--- exit from the "no opened orders" block
      return;
     }
//--- it is important to enter the market correctly, but it is more important to exit it correctly...   
   for(cnt=0;cnt<total;cnt++)
     {
      if(!OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES))
         continue;
      if(OrderType()<=OP_SELL &&   // check for opened position 
         OrderSymbol()==Symbol())  // check for symbol
        {
         //--- long position is opened
         if(OrderType()==OP_BUY)
           {
            //--- should it be closed?
              if(iRSI(NULL,0,OpenLevel,PRICE_LOW,Period1)<iRSI(NULL,0,CloseLevel,PRICE_HIGH,Period)) 
              {
               //--- close order and exit
               if(!OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet))
                  Print("OrderClose error ",GetLastError());
               return;
              }
            //--- check for trailing stop
            if(TrailingStop>0)
              {
               if(Bid-OrderOpenPrice()>Point*TrailingStop)
                 {
                  if(OrderStopLoss()<Bid-Point*TrailingStop)
                    {
                     //--- modify order and exit
                     if(!OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green))
                        Print("OrderModify error ",GetLastError());
                     return;
                    }
                 }
              }
           }
         else // go to short position
           {
            //--- should it be closed?
           if(iRSI(NULL,0,OpenLevel,PRICE_LOW,Period)>iRSI(NULL,0,CloseLevel,PRICE_HIGH,Period1)) 
              {
               //--- close order and exit
               if(!OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet))
                  Print("OrderClose error ",GetLastError());
               return;
              }
            //--- check for trailing stop
            if(TrailingStop>0)
              {
               if((OrderOpenPrice()-Ask)>(Point*TrailingStop))
                 {
                  if((OrderStopLoss()>(Ask+Point*TrailingStop)) || (OrderStopLoss()==0))
                    {
                     //--- modify order and exit
                     if(!OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red))
                        Print("OrderModify error ",GetLastError());
                     return;
                    }
                 }
              }
           }
        }
     }
//---
  }
//+------------------------------------------------------------------+

Expert Advisorが他の人のトレードを閉じたり、他の人のトレードがある場合は自分のトレードを開かなかったりしているのですが、どうしたらいいでしょうか?

 
darirunu1:

Expert Advisorが他の人のトレードを閉じたり、他の人のトレードがある場合は自分のトレードを開かなかったりしているのですが、どうしたらいいでしょうか?

注文を見つけるためのマジックはどこにある?
 

上記のように記述した場合、Expert Advisor は手動で開いた取引を閉じます。

このような言い方をすれば

 if(!OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES))
         continue;
      if(OrderType()<=OP_SELL &&   // check for opened position 
         OrderSymbol()==Symbol()&& OrderMagicNumber()==Magic)  // check for symbol

手動で開いた取引がある場合、Expert Advisor は他の取引を閉じませんが、手動で開いた取引がある場合、自分自身の取引は開きません。

 
darirunu1:

上記のように記述した場合、Expert Advisor は手動で開いた取引を閉じます。

このような言い方をすれば

手動で開いた取引がある場合、Expert Advisor は他の取引を閉じませんが、手動で開いた取引がある場合、自分自身の取引は開きません。

を開く際にも、ウィザードリィによる選択が必要です。
 
MakarFX:
開店時のマジックナンバーの選定もお願いします。
 ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Ask+TakeProfit*Point,Ask-TakeProfit*Point,"USDCADH4",Magic,0,Red);

これは何でしょう?開口部が表示されます。複数のExpert Advisorを使用している場合は問題ありませんが、手動でポジションを建てる場合のみ問題が発生します。

手動で口座に取引が開始されると、Expert Advisorは動作を停止します。

これをコードで削除するとすぐに、total=OrdersTotal()となります。

if(total<1)

EAは直進するが、多くのトレードを開く

 
darirunu1:

これは何でしょう?開口部が表示されます。複数のExpert Advisorを使用している場合は問題ありませんが、手動でポジションを建てる場合のみ問題が発生します。

手動で口座に取引が開始されると、Expert Advisorは動作を停止します。

これをコードで削除するとすぐに、total=OrdersTotal()となります。

if(total<1)

EAは直進するけど、たくさんトレードを開く。

これは私が言っていることです - OrdersTotal()はすべての注文のために、あなたはEAの注文が必要です。

   if(CountOrders("", -1,  Magic)<1)
     {
     открытие ордеров
     }
//+----------------------------------------------------------------------------+
//| Подсчет ордеров                                                            |
//+----------------------------------------------------------------------------+
//| -1 - Все типы ордеров                                                      |
//|  0 - ордера типа BUY                                                       |
//|  1 - ордера типа SELL                                                      |
//|  2 - ордера типа BUYLIMIT                                                  |
//|  3 - ордера типа SELLLIMIT                                                 |
//|  4 - ордера типа BUYSTOP                                                   |
//|  5 - ордера типа SELLSTOP                                                  |
//+----------------------------------------------------------------------------+
int CountOrders(string symb="", int or_ty=-1, int magiс=-1) 
  {
   int cnt=0;
   if(symb=="0") symb=_Symbol;
   for(int pos=OrdersTotal()-1;pos>=0;pos--)
     {
      if(OrderSelect(pos,SELECT_BY_POS)==true)
        {
         if((OrderSymbol()==symb || symb=="")&&(or_ty<0 || or_ty==OrderType()))
           {
            if(magiс<0 || OrderMagicNumber()==magiс) cnt++;
           }
        }
     }
   return(cnt);
  }
 
MakarFX:

それこそ、OrdersTotal()は全注文で、EA注文をしたい場合

if(CountOrders("", -1,  Magic)<1)
     {

これは、代わりに

total=OrdersTotal()。

if(total<1)か、これも残すか?