コーディングの方法は? - ページ 106

 

それは、価格には有効だ。彼はイディケーターの最高値と最安値を見つけたいのです。

ラックス

 

こんにちは。

あなたはこれを試すことができます。

....

int highest=0, lowest=0, bar=WindowBarsPerChart();

for(int shift=0;shift<bar;shift++)

{

double indie=iCustom(.........,shift);

if(highest<indie) highest=indie;

if(lowest==0) lowest=indie;

if(lowest>indie) lowest=indie;

}

.....

注:このコードは、現在のオープンローソクも計算し、あなたが閉じたローソクだけを計算したい場合は、shift = 1を使用してください。

これが役立つことを願っています。

Ardie

 
:: iBarShiftは、その日/時間に始まるバー...またはその日/時間の終了バー...を探します。(高値/安値を見つけるために開始したい時間枠やチャートに依存します)。

int iBarShift( string symbol, int timeframe, datetime time, bool exact=false)

次に...

:: iHighestとiLowestの結果を見つけるために、これらのバーポジションを使用します。

int iHighest( 文字列 symbol, int timeframe, int type, int count=WHOLE_ARRAY, int start=0)

int iLowest( 文字列シンボル, int timeframe, int type, int count=WHOLE_ARRAY, int start=0)

:: 結果と完了 、この中でループを使わないでください!

 

プログラムによるリペイントインジケータの更新

こんにちは。

リペイントインディケータをX分毎に更新する方法を探しています。

現在、リフレッシュする唯一の方法は、チャート上のインジケータをクリックし、"ok "をクリックすることです。MQL4コードで自動化できないでしょうか?

codersguruのサイトで、Programmatically Refresh your charts | www.metatrader.info というのを見つけたのですが、私には使えないようです。それとも、どなたかこれを試して、違う結果(動作)を得た方はいらっしゃいますか?

ありがとうございます。

 

私の英語で申し訳ありません。

条件が成立した回数を1つのバーに1回だけカウントしたいのですが。 コンピュータは、バーごとに何回も追加されます。 私は何を間違っていますか?

 
IngvarDagmar:
条件が成立した回数をバーごとに1回だけカウントしたいのですが。 コンピュータは、バーごとに何回も追加します。 私は何を間違っていますか?

このような関数を 使用します...

bool NewBar() {

static datetime LastTime = 0;

if (Time[0] != LastTime) {

LastTime = Time[0];

return (true);

} else

return (false);

}

[/php]

Then put an if statement round your main code, like...

[php]

if(NewBar() == true){

// do the main processing here

}

お役に立てれば幸いです。

ラックス

 

ラックスさん、よかったですね。

こんなのを見つけました。

各バーを一度だけ処理する - MQL4 forum

Automated 2008.01.15 18:54 新しいバーの最初のティック(つまり、前のバーが閉じた直後)でコードを実行することができます。

以下は、新しいバーが形成されたときに TRUE を返す関数です。

// この関数は、新しいバーの最初のティック、すなわち前のバーが閉じた直後に TRUE を返します。

bool NewBar()

{

if(PreviousBarTime<Time[0])

{

PreviousBarTime = Time[0];

return(true)とする。

}

return(false); // if - else文が実行されない場合

EAの冒頭でPreviousBarTimeという日時を宣言する必要があります。

そして、あなたのコードでは、次のように使用することができます。

if ( NewBar() )

{

......ここでバーが閉じた後に実行される必要があるコード......。

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

automatedfx@gmail.com

---------------------------------------------------

STATICを使ってるんですね...。私はそれを調べた...STATICを使用することの利点は、グローバル変数と比較して何ですか?

 

マルチエントリーEA

私は次の入力パラメータでEAを作成するために見つけるか、または助けを必要としたいと思います。4つの別々のトレードエントリは、ロット数、ストップロス、トレーリングストップ、ブレークイーブン、および利益目標を持っています。

ありがとうございます

 

トレーリングストップオプションのヘルプが必要です

MQL4フォーラムでこのEAを見つけたのですが、なかなか面白いEAですね。

どなたか、トレーリングストップのオプションを追加するのを手伝っていただけませんか?

themastermind2.mq4

ファイル:
 

皆さん、こんにちは。

MACDが「n」の形になると売りのポストをオープンし、「u」の形になると買いのポストをオープンします。

問題は、EAがポストを開かないことです。

ここにコードがあります...

extern double TakeProfit = 20;

extern double Lots = 0.1;

extern double StopLoss = 20;

extern double MagicNumber = 17384;

extern int FastEMA=12;

extern int SlowEMA=26;

extern int SignalSMA=9;

//+------------------------------------------------------------------+

//| expert initialization function |

//+------------------------------------------------------------------+

double MacdBuffer1[];

double MacdBuffer2[];

double MacdBuffer3[];

double MacdBuffer4[];

double MacdBuffer5[];

double MacdBuffer6[];

double MacdBuffer7[];

double MacdBuffer8[];

int init()

{

//----

//SetIndexBuffer(0, lag1_buffer);

//SetIndexBuffer(1, lag2_buffer);

//----

return(0);

}

//+------------------------------------------------------------------+

//| expert deinitialization function |

//+------------------------------------------------------------------+

int deinit()

{

//----

//----

return(0);

}

//+------------------------------------------------------------------+

//| expert start function |

//+------------------------------------------------------------------+

int start()

{

int limit;

int counted_bars=IndicatorCounted();

//---- last counted bar will be recounted

if(counted_bars>0) counted_bars--;

limit=Bars-counted_bars;

//---- macd counted in the 1-st buffer

for(int i=0; i<limit; i++)

MacdBuffer1=iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i)-iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i);

MacdBuffer2=iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i-1)-iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i-1);

MacdBuffer3=iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i+1)-iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i+1);

MacdBuffer4=iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i-2)-iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i-2);

MacdBuffer5=iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i+2)-iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i+2);

MacdBuffer6=iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i-3)-iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i-3);

MacdBuffer7=iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i+3)-iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i+3);

/*Alert( "MacdBuffer7 =",MacdBuffer7);

Alert( "MacdBuffer5 =",MacdBuffer5);

Alert( "MacdBuffer3 =",MacdBuffer3);

Alert( "MacdBuffer1 =",MacdBuffer1);

Alert( "MacdBuffer2 =",MacdBuffer2);

Alert( "MacdBuffer4 =",MacdBuffer4);

Alert( "MacdBuffer6 =",MacdBuffer6);*/

//----

int ticket_buy, ticket_sell, total;

total=OrdersTotal();

//MACD become 'u' shape

if (MacdBuffer7>MacdBuffer5&&MacdBuffer5>MacdBuffer3&&MacdBuffer3>MacdBuffer1

&&MacdBuffer1<MacdBuffer2&&MacdBuffer2<MacdBuffer4&&MacdBuffer4<MacdBuffer6)

{

if (total < 1) {

ticket_buy=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-StopLoss*Point,Ask+TakeProfit*Point,"scalp 1 min - buy",MagicNumber,0,Green);

if(ticket_buy>0)

{

if(OrderSelect(ticket_buy,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice());

}

else Print("Error opening BUY order : ",GetLastError());

return(0);

} else {

}

}

//MACD become 'n' shape

if(MacdBuffer7<MacdBuffer5&&MacdBuffer5<MacdBuffer3&&MacdBuffer3<MacdBuffer1

&&MacdBuffer1>MacdBuffer2&&MacdBuffer2>MacdBuffer4&&MacdBuffer4>MacdBuffer6)

{

if (total < 1) {

ticket_sell=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Bid+StopLoss*Point,Bid-TakeProfit*Point,"scalp 1 min - sell",MagicNumber,0,Red);

if(ticket_sell>0)

{

if(OrderSelect(ticket_sell,SELECT_BY_TICKET,MODE_TRADES)) Print("SELL order opened : ",OrderOpenPrice());

}

else Print("Error opening SELL order : ",GetLastError());

return(0);

} else {

}

}

//----

return(0);

}

//+------------------------------------------------------------------+

誰かがこの問題を解決するのを助けてくれることを願っています。