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

 
Fast235 #:

この行だけ疑問

-50 余分なものと配列

"0 "の上/下を描画することです。

でも、なくても大丈夫です。要はハンドルの使い方が知りたいんです。

 
Vladimir Simakov #:

ぜひお勧めします。

そうでない場合は oops が表示されます))

さらに、分割した後、すぐに全体に落とし込む。そうでなければ、2進数のカウントはいろいろなことができる)。

 
MakarFX #:

これは、"0 "の上/下に描画するためのものです。

でも、なくても大丈夫です。ハンドルの使い方を知りたいんです。

ハンドルはインジケーターファイルへのポインターで、通常OnInit()で作成されます。

   Handle=iCustom(Symbol(),PERIOD_H1,"_iTrend",10);
//--- Если не удалось получить хендл индикатора
   if(Handle==INVALID_HANDLE)
     {
      PrintFormat("Failed to create handle of the iAO indicator for the symbol %s/%s, error code %d",
                  Symbol(),
                  EnumToString(Period()),
                  GetLastError());
      //---
      return(INIT_FAILED);
     }

後述

    if(CopyBuffer(Handle,0,1,1,Buffer1) <=0 проверка на ошибку
---
в Buffer1[1111] получаем значение
 
Fast235 #:

ハンドルはインジケータファイルへのポインタであり、通常OnInit()で作成されます。

後述

ありがとうございます!しかし、ヘルプのようで残念ながら私にはよくわかりません(

そのため、仕事のロジックを理解するために、私のコードをmql5に翻訳するよう依頼しました。

私はこうしています

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
   IndicatorSetInteger(INDICATOR_DIGITS,_Digits);
   prd = _Period > TimeFrame ? _Period : TimeFrame;
   atrHandle = iATR(_Symbol, prd, Per_Count);
   if(atrHandle == INVALID_HANDLE)
     {
      Print("Can't load indicator."); return INIT_FAILED;
     }
//--- indicator buffers mapping
   SetIndexBuffer(0,Label1Buffer,INDICATOR_DATA);
   SetIndexBuffer(1,Label2Buffer,INDICATOR_DATA);
   
   ArraySetAsSeries(Label1Buffer, true);
   ArraySetAsSeries(Label2Buffer, true);
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator 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[])
  {
//---
   int limit,i;
   int barPlus=iBarShift(_Symbol,_Period,iTime(_Symbol,PERIOD_W1,WeekCount),false);
   limit=rates_total-prev_calculated-3;
   if(WeekCount!=0)limit=barPlus-1;
   if(limit<1) return(0);
   for(i=limit;i>=0;i--)
     {
      TimeToStruct(time[i],inTime);
      index01=iBarShift(_Symbol,PERIOD_D1,time[i],false);
      if(inTime.hour==0&&inTime.min==0)
        {
         Label1Buffer[i]=GetIndicator(atrHandle, index01+1);
        }
     }
   
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
double GetIndicator(const int handle, const int i)
  {
   double res[1];
   if(CopyBuffer(handle, 0, i, 1, res) <= 0) return 0;
   return res[0];
  }
//+------------------------------------------------------------------+

しかし、何かが間違っているような気がしますし、iMAOnArrayはヘルプに記載されていません。

 

こんにちは。

マーチンループの問題が解決できない。

マーチンのループの問題が解決できません。実行後:(n>=OrdersClose)-で 切断され、その後、マーチンは有益な取引が発生するまでトリガーさ れないのです。

(n>=OrdersClose)の後にreturn(dLots) が必要で、次のトレードが再び負けた場合、マーティンは再び開始さ れます。

どのようにすればよいか、アドバイスをお願いします。

double LOT()
{
   int n=0;
   double OL=dLots;
   for (int j = OrdersHistoryTotal()-1; j >= 0; j--)
   {
      if (OrderSelect(j, SELECT_BY_POS,MODE_HISTORY))
      {
         if (OrderSymbol() == Symbol() && OrderMagicNumber() == iMagic)
         {
            if (OrderProfit()<0) 
            {
               if (n==0) OL=NormalizeDouble(OrderLots()*K_Martin,DigitsLot);
               n++;
               if (n>=OrdersClose) {return(dLots);}
            }
            else
            {
               if (n==0) {return(dLots);}
               else {return(OL);}
            }
         }
      }
   }
   return(OL);
}
 

皆さん、こんにちは!!!

チャート上の平均価格の表示を規定したグリッドアドバイザーのコードで私に助言してください。それはOKでしょうが、正しくグリッドを閉じた後の行を削除しない、つまり、平均価格はありません。 私は間違っていたのか私に教えてください。以下はそのコードと画像です。

//+-----------------------------------------------------------------------------
//| グループ注文の修正|
//+-----------------------------------------------------------------------------
void ModifyOrders(int otype)
{
double avg_price, AveragePriceBuy, AveragePriceSell, order_lots = 0;
price = 0;

for(int i = OrdersTotal()-1; i>)=0; i--)
{
if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
{
if(OrderSymbol() == Symbol() && OrderMagicNumber() == Magic && OrderType() == otype)
{
price += OrderOpenPrice() * OrderLots();
order_lots += OrderLots() ;
}
}
}
。avg_price = NormalizeDouble(price / order_lots, Digits);
AveragePriceBuy = NormalizeDouble(avg_price + Spread, Digits);
AveragePriceSell = NormalizeDouble(avg_price - Spread, Digits)です。
{
ObjectDelete(0, "AveragePriceLine");
ObjectCreate("AveragePriceLine" ,OBJ_HLINE, 0, 0 ,AveragePriceBuy);
。ObjectCreate("AveragePriceLine" ,OBJ_HLINE, 0, 0 ,AveragePriceSell);
ObjectSet("AveragePriceLine",OBJPROP_COLOR,Blue);

▼。if ((otype == OP_BUY) && (Drawdown <= DrawdownClosingTakeprofitZero))
tp = NormalizeDouble (AveragePriceBuy + TakeProfitGroupOrder*Point, Digits);
。if ((otype == OP_SELL) && (Drawdown <= DrawdownClosingTakeprofitZero))
tp = NormalizeDouble (AveragePriceSell-TakeProfitGroupOrder*Point、Digits);
if ((otype == OP_BUY) && (Drawdown > DrawdownClosingTakeprofitZero))
tp = NormalizeDouble (AveragePriceBuy, Digits);
if ((otype == OP_SELL) &/Original)& (Drawdown > DrawdownClosingTakeprofitZero))
tp = NormalizeDouble (AveragePriceSell, Digits);

for(int i = OrdersTotal()-1;i>=0; i--)
{
if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
{
if(OrderSymbol() == Symbol() && OrderMagicNumber() == Magic && OrderType() == otype)
{
if(OrderModify(OrderTicket(), OrderOpenPrice(), 0, tp, 0))
Print("Orders successfully modified!");
else Print("Error modifying orders!");
}
}
}
} }.


 
EVGENII SHELIPOV #:

皆さん、こんにちは!!!

チャート上の平均価格の表示を規定したグリッドアドバイザーのコードで私に助言してください。私はOKだろうが、正しくグリッドを閉じた後に行を削除しない、つまり、平均価格はありません。 私は間違っていたのか私に教えてください。以下はそのコードと画像です。

このように試してみてください。

//+----------------------------------------------------------------------------+
//| Модификация групповых ордеров                                              |
//+----------------------------------------------------------------------------+
void ModifyOrders(int otype)
{
    double avg_price, AveragePriceBuy, AveragePriceSell, order_lots = 0;
    price = 0;
   
    for(int i = OrdersTotal()-1; i>=0; i--)
    {
       if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
       {
         if(OrderSymbol() == Symbol() && OrderMagicNumber() == Magic && OrderType() == otype)
         {
            price += OrderOpenPrice() * OrderLots();
            order_lots += OrderLots() ;
         }
       }
    }
    avg_price = NormalizeDouble(price / order_lots, Digits);
    AveragePriceBuy = NormalizeDouble(avg_price + Spread, Digits);
    AveragePriceSell = NormalizeDouble(avg_price - Spread, Digits);
    if(ObjectFind(0,"AveragePriceLineBuy")==0)
     {
     ObjectDelete(0,"AveragePriceLineBuy");
     ObjectCreate(0,"AveragePriceLineBuy" ,OBJ_HLINE, 0, 0 ,AveragePriceBuy);
     ObjectSetInteger(0,"AveragePriceLine",OBJPROP_COLOR,Blue);
     }
    else
     {
     ObjectCreate(0,"AveragePriceLineBuy" ,OBJ_HLINE, 0, 0 ,AveragePriceBuy);
     ObjectSetInteger(0,"AveragePriceLine",OBJPROP_COLOR,Blue);
     }
    if(ObjectFind(0,"AveragePriceLineSell")==0)
     {
     ObjectDelete(0,"AveragePriceLineSell");
     ObjectCreate(0,"AveragePriceLineSell" ,OBJ_HLINE, 0, 0 ,AveragePriceSell);
     ObjectSetInteger(0,"AveragePriceLine",OBJPROP_COLOR,Blue);
     }
    else
     {
     ObjectCreate(0,"AveragePriceLineSell" ,OBJ_HLINE, 0, 0 ,AveragePriceSell);
     ObjectSetInteger(0,"AveragePriceLine",OBJPROP_COLOR,Blue);
     }
    if ((otype == OP_BUY) && (Drawdown <= DrawdownClosingTakeprofitZero)) 
    tp = NormalizeDouble (AveragePriceBuy + TakeProfitGroupOrder*Point, Digits);
    if ((otype == OP_SELL) && (Drawdown <= DrawdownClosingTakeprofitZero))
    tp = NormalizeDouble (AveragePriceSell - TakeProfitGroupOrder*Point, Digits);
    if ((otype == OP_BUY) && (Drawdown > DrawdownClosingTakeprofitZero)) 
    tp = NormalizeDouble (AveragePriceBuy, Digits);
    if ((otype == OP_SELL) && (Drawdown > DrawdownClosingTakeprofitZero))
    tp = NormalizeDouble (AveragePriceSell, Digits);
    
    for(int i = OrdersTotal()-1; i>=0; i--) 
    {
       if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
       {
           if(OrderSymbol() == Symbol() && OrderMagicNumber() == Magic && OrderType() == otype)
           {
               if(OrderModify(OrderTicket(), OrderOpenPrice(), 0, tp, 0))
                  Print("Ордера успешно модифицированы!");
                else Print("Ошибка модификации ордеров!");
           }
       }
    }
}   

あるいは、より良い処方をする。

売りの注文がない場合、売りの行を削除します。

ばいきんまんにも

 
こんばんは、グラフィックボタンをクリックしたときに、もう一度クリックするまでずっと押されていない状態にリセットするにはどうしたらいいのでしょうか?
 
Nerd Trader #:
こんばんは、グラフィックボタンをクリックしたときに、もう一度クリックするまでずっと押されていない状態にリセットするにはどうしたらいいのでしょうか?
ObjectSetInteger(0,name,OBJPROP_STATE,false);
 
MakarFX #:
いや、勘違いしている。クリックを離した後、通常のボタンと同様に状態をリセットする必要があります。mql4がマウスボタンの状態イベント:click/releaseを持っていない場合、どのようにこれを実装するのでしょうか。