[ARCHIVE!] フォーラムを散らかさないように、どんなルーキーの質問でも。プロフェッショナルは、通り過ぎないでください。あなたなしではどこにも行けない - 4. - ページ 121

 
mahla:

トレーリングストップとブレイクイーブンの出力はどこに追加するのですか?また、預金を増やしてもロットが 増えません。

アドバイザーの中で

//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+

機能ロットアップ......したほうがいいかもしれません。

の例です。

extern double Lots               = 0.1;
extern double MaximumRisk        = 0.02;
extern double DecreaseFactor     = 3;
//////
//+------------------------------------------------------------------+
//| Calculate optimal lot size                                       |
//+------------------------------------------------------------------+
double LotsOptimized()
  {
   double lot=Lots;
   int    orders=HistoryTotal();     // history orders total
   int    losses=0;                  // number of losses orders without a break
//---- select lot size
   lot=NormalizeDouble(AccountFreeMargin()*MaximumRisk/1000.0,1);
//---- calcuulate number of losses orders without a break
   if(DecreaseFactor>0)
     {
      for(int i=orders-1;i>=0;i--)
        {
         if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==false) { Print("Error in history!"); break; }
         if(OrderSymbol()!=Symbol() || OrderType()>OP_SELL) continue;
         //----
         if(OrderProfit()>0) break;
         if(OrderProfit()<0) losses++;
        }
      if(losses>1) lot=NormalizeDouble(lot-lot*losses/DecreaseFactor,1);
     }
//---- return lot size
   if(lot<0.1) lot=0.1;
   return(lot);
  }

移動平均を 見る.mq4

[Deleted]  

ボリンジャーバンドを 価格ではなく、モメンタムに使う方法を教えてください。 こんな感じでやってみました。

BandOPeriodT - 外部変数、ボリンジャーバンドの期間。

MomentumPeriodT - それぞれ、運動量の期間

BandOBottom=iBands(NULL,0,BandOPeriodT,1,0,iMomentum(NULL,0,MomentumPeriodT,PRICE_OPEN,0),MODE_LOWER,0)となります。

と、こんな感じでもあります。

MomO=iMomentum(NULL,0,MomentumPeriodT,PRICE_OPEN,0); - 内部変数で値を返す。

BandOBottom=iBands(NULL,0,BandOPeriodT,1,0,MomO,MODE_LOWER,0); - この変数は、前の変数値に対するボリンジャーラインの下限値を返す必要があります。

また、MODE_LOWERは、BOLLINGER ボリンジャーラインの値を変数で取得するという意味と考えてよろしいでしょうか?そうでない場合、具体的にどのように入手すればよいのでしょうか?

 
Ovari:

ボリンジャーバンドを価格ではなく、モメンタムに使う方法を教えてください。 こんな感じでやってみました。

BandOPeriodT - 外部変数、ボリンジャーバンドの期間。

MomentumPeriodT - それぞれ、運動量の期間

BandOBottom=iBands(NULL,0,BandOPeriodT,1,0,iMomentum(NULL,0,MomentumPeriodT,PRICE_OPEN,0),MODE_LOWER,0)となります。

と、こんな感じでもあります。

MomO=iMomentum(NULL,0,MomentumPeriodT,PRICE_OPEN,0); - 内部変数で値を返す。

BandOBottom=iBands(NULL,0,BandOPeriodT,1,0,MomO,MODE_LOWER,0); - この変数は、前の変数値に対するボリンジャーラインの下限値を返す必要があります。

また、MODE_LOWERは、BOLLINGER ボリンジャーラインの値を変数で取得するという意味と考えてよろしいでしょうか?そうでない場合、具体的にどのように入手すればよいのでしょうか?


トレーラー参照 - RSIのバンド -Momentumの バンドも同じようにします。

説明 - ログに記載 - 冒頭のコードを参照してください。

ファイル:
[Deleted]  
ありがとうございます、私はとても新人で、プログラマーでもないので:)
 

こんにちは!助けてくださいPVTインジケータを試してみたい。

double PVT = iCustom(NULL,240,"PVT",PRICE_CLOSE,1,1)

何が足りないのか、教えてください。

It says: 2012.05.14 19:34:46 Cannotopen file'C:\Program FilesAlpari NZ MT4 ³³indicators ³³PVT.ex4' on EURUSD,H4

ありがとうございました。

 
mahla:

トレーリングストップとブレイクイーブンの出力はどこに追加するのですか? また、預金を増やしてもロットが増えません。

int Buy (int StopLoss = 0, int TakeProfit = 0, double Lot = 0)

{

int Ticket = 0;

double SL = 0;

double TP = 0;

double VolumeLot = 0;

RefreshRates()。

if (StopLoss != 0)

SL = NormalizeDouble(Bid-StopLoss*Point, Digits)です。

if (TakeProfit != 0)

TP = NormalizeDouble(Ask+TakeProfit*Point, Digits)。

if (Lot == 0)

VolumeLot = GetLot ();

さもなくば

VolumeLot = Lot;

チケット = OrderSend(Symbol(), OP_BUY, VolumeLot, NormalizeDouble(Ask, Digits), 20, SL, TP, NULL, AccountNumber(), 0, Green)です。

if (Ticket == -1)

{

return (GetLastError ();

}

さもなくば

{

リターン(チケット)です。

}

}

int Sell (int StopLoss = 0, int TakeProfit = 0, double Lot = 0)

{

int Ticket = 0;

double SL = 0;

double TP = 0;

double VolumeLot = 0;

RefreshRates()。

if (StopLoss != 0)

SL = NormalizeDouble(Ask+StopLoss*Point, Digits)です。

if (TakeProfit != 0)

TP = NormalizeDouble(Bid-TakeProfit*Point, Digits)。

if (Lot == 0)

VolumeLot = GetLot ();

さもなくば

VolumeLot = Lot;

チケット = OrderSend(Symbol(), OP_SELL, VolumeLot, NormalizeDouble(Bid, Digits), 20, SL, TP, NULL, AccountNumber(), 0, Red)です。

if (Ticket == -1)

return (GetLastError ();

さもなくば

リターン(チケット)です。

}

double GetLot ()

{

int lot;

if (AccountBalance()>=300) lot=0.01;

if (AccountBalance()>=500) lot=0.02;

if (AccountBalance()>=800) lot=0.03;

を返します(ロット)。

}

オープンポジションが既に選択されており、このポジションがエキスパートアドバイザーが接続されているシンボルに対して
開かれていることが確実に分かっていると仮定しましょう。また、TrailingStop変数にトレーリングストップ(
)の値(pips)が入っているとします。

   int err;
   if (OrderType() == OP_BUY)
     {
       // позиция на покупку
       if ((Bid-OrderOpenPrice())>=(TrailingStop*Point))
         {
           // выставляем Stop Loss
           if (OrderModify(OrderTicket(), OrderOpenPrice(), Bid-TrailingStop*Point,
                                    OrderTakeProfit(), 0))
             Print("#", OrderTicket(),": trailing stop ", Bid-TrailingStop*Point);
           else
             {
              err = GetLastError();
              Print("#", OrderTicket(),": trailing stop error ", err);
             }
         }
     }
   else
     {
       // позиция на продажу
       if ((OrderOpenPrice()-Ask)>=(TrailingStop*Point))
         {
           // выставляем Stop Loss
           if (OrderModify(OrderTicket(), OrderOpenPrice(), Ask+TrailingStop*Point,
                                    OrderTakeProfit(), 0))
             Print("#", OrderTicket(),": trailing stop ", Ask+TrailingStop*Point);
           else
             {
              err = GetLastError();
              Print("#", OrderTicket(),": trailing stop error ", err);
             }
         }
     }
OrderProfit()関数は、OrderSelect()関数で 選択された注文の利益を返します。

クローズしたポジションから得た利益を計算したいとします。

   int profit = 0;
   int pos;
   for ( pos = 0; pos<HistoryTotal(); pos++ )
     {
       // выделим позицию
       if (OrderSelect(pos, SELECT_BY_POS, MODE_HISTORY) == true)
         {
           // это не отложенный ордер?
           if ( OrderType() <= OP_SELL) profit += OrderProfit();            
         }
       else
           Print("Ошибка ", GetLastError(), " при выделении ордера ", OrderTicket());
     }
   Print("Суммарный профит по закрытым позициям = ", profit);
そして、今日オープンしたすべてのクローズドポジション、
の利益を計算する完全なコードは、次のようになります:

   //---- вычислим начало дня - переменная day_start
   int c_time = CurTime();  
   datetime day_start;
   day_start=c_time-TimeHour(c_time)*60*60-TimeMinute(c_time)*60-TimeSeconds(c_time);
   //---- подсчитаем прибыль
   int profit = 0;
   int pos;
   for ( pos = 0; pos<HistoryTotal(); pos++ )
     {
       // выделим позицию
       if (OrderSelect(pos, SELECT_BY_POS, MODE_HISTORY) == true)
         {
           // это не отложенный ордер?
           if ( OrderType() <= OP_SELL)
             {
               // ордер был открыт сегодня?
               if (OrderOpenTime()>=day_start) profit += OrderProfit();
             }
         }
       else
           Print("Ошибка ", GetLastError(), " при выделении ордера ", OrderTicket());
     }
   Print("Суммарный профит по закрытым позициям = ", profit);
 
mahla:

また、保証金を増やしてもロットは増えません。


もしかしたら、他に何かコードの抜けがあるかもしれません。

doubleオーダーロット( )
選択された注文のロット数を返します。
注文は、OrderSelect() であらかじめ選択されている必要があります。
 if(OrderSelect(10,SELECT_BY_POS)==true) Print("lots for order 10 ",OrderLots()); else Print("OrderSelect() has returned an error - ",GetLastError()");
 
borilunad:

こんにちは!助けてくださいPVTインジケータを試してみたい。

何が足りないのか、教えてください。

It says: 2012.05.14 19:34:46 Cannot open file 'C:\Program FilesAlpari NZ MT4 ³³indicators ³³PVT.ex4' on EURUSD,H4

ありがとうございました。

PVTインジケーターそのものがない(本当にあるのか?)
 
alsu:
PVTインジケーターそのものがない(本当にあるのか?)

もちろん持ってますし、コンパイルしてeh4してます。チャートにも載せてね。もしかして、書き方が悪かったかな?ありがとうございました。
 

ボリルナド

もちろん、コンパイル済みとeh4の両方があります。そして、それをチャートに書き込む。もしかして、書き方が悪かったかな?ありがとうございます。


バッファは1つしかないのに、存在しない2つ目のバッファを呼び出すEAに何の意味があるのでしょうか?