Sormak! - sayfa 106

 

Grafiğin Zaman Periyodu

Grafiğin hangi zaman diliminde çalıştığını bulmanın kodu nedir? Böylece her zaman periyodu için değişken ayarları değiştirebilirim.

Eğer(?????) . . .

Dave

 
Dave137:
Grafiğin hangi zaman diliminde çalıştığını bulmanın kodu nedir? Böylece her zaman periyodu için değişken ayarları değiştirebilirim.

Eğer(?????) . . .

Dave
if(Period() == PERIOD_M15) ...

[/PHP]

or:

switch(Period())

{

case PERIOD_M1:

...

break;

case PERIOD_M5:

...

break;

...

}

[/PHP]

Sometime it maybe easier to work with indices:[PHP]

int tfIndex = ArrayBsearch({PERIOD_M1, PERIOD_M5, PERIOD_M15, ...}, Period());

Example : how to display the period by the string you want:[PHP]

int Periods[] = {PERIOD_M1, PERIOD_M5, PERIOD_M15, ...};

string sPeriods[] = {" M1", " M5", " M15", " M30", " Hourly", " 4 hours", " Daily", " Weekly"...};

int tfIndex = ArrayBsearch(Periods, Period());

comment(Symbol() + sPeriods[tfIndex]);

 

Teşekkürler Michel!

Umarım yarattığım bu EA tek olacaktır! Yardımınız çok takdir ediliyor!

Dave

 

Merhaba!

burada bazıları bu işlevi eklememe yardımcı olabilir. Çubuk tamamlandığında işlemi kapatın veya bir sonraki çubuk göründüğünde işlemi kapatmasını sağlayın.

harici int SystemMagicNumber=197;

harici çift TakeProfit = 100;

harici çift StopLoss = 500;

dış çift Lot = 0.1;

harici çift TrailingStop = 0;

harici int MaxBuyTrades=5;

harici int MaxSellTrades=5;

int başlangıç()

{

if( HavePosThisBar(SystemMagicNumber)==yanlış

&&iMA(NULL,0,5,0,MODE_SMA, PRICE_CLOSE,1)<iMA(NULL,0,15,0,MODE_EMA, PRICE_CLOSE,1)

&& iMA(NULL,0,5,0,MODE_SMA, PRICE_CLOSE,2)>iMA(NULL,0,15,0,MODE_EMA, PRICE_CLOSE,2)

&& SellPositionsCount()<MaxSellTrades

)

{

OrderSend(Symbol(),OP_SELL,Lots,Bid,0,Bid+StopLoss*Point,Bid-TakeProfit*Point,"",SystemMagicNumber,0,Red);

dönüş(0);

}

if( HavePosThisBar(SystemMagicNumber)==yanlış

&& iMA(NULL,0,5,0,MODE_SMA, PRICE_CLOSE,1)>iMA(NULL,0,15,0,MODE_EMA, PRICE_CLOSE,1)

&& iMA(NULL,0,5,0,MODE_SMA, PRICE_CLOSE,2)<iMA(NULL,0,15,0,MODE_EMA, PRICE_CLOSE,2)

&& BuyPositionsCount()<MaxBuyTrades

)

{

OrderSend(Symbol(),OP_BUY,Lots,Ask,0,Ask-StopLoss*Point,Ask+TakeProfit*Puan,"",SystemMagicNumber,0,Mavi);

dönüş(0);

}

for(int cnt=OrdersTotal()-1;cnt>=0;cnt--)

{

OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);

if (OrderSymbol() == Symbol())

{

if (OrderType()==OP_SEL)

{

if (TrailingStop>0)

{

if (OrderOpenPrice()-Ask>TrailingStop*Point)

{

if (OrderStopLoss() == 0 || OrderStopLoss()>(Ask+Point*TrailingStop))

{

OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Purple);

dönüş(0);

}

}

}

}

if (OrderType()==OP_BUY)

{

if (TrailingStop>0)

{

if (Bid-OrderOpenPrice()>TrailingStop*Point)

{

if (OrderStopLoss()<(Bid-Point*TrailingStop))

{

OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Yellow);

dönüş(0);

}

}

}

}

}

}

//----

dönüş(0);

}

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

bool HavePosThisBar(int büyü)

{

int cnt;

bool Sonuç=yanlış;

for(cnt=0; cnt<=OrdersHistoryTotal()-1; cnt++)

if(OrderSelect(cnt, SELECT_BY_POS, MODE_HISTORY))

if((OrderSymbol() == Symbol()) &&(OrderMagicNumber() == magic) && Time[0]<=OrderOpenTime())

{

Sonuç=doğru;

kırmak;

}

for(cnt=0; cnt<=SiparişlerToplam()-1; cnt++)

if(OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES))

if((OrderSymbol() == Symbol()) &&(OrderMagicNumber() == magic) && Time[0]<=OrderOpenTime())

{

Sonuç=doğru;

kırmak;

}

dönüş(Sonuç);

}

int BuyPositionsCount()

{

int Sonuç=0;

for(int cnt=0; cnt<=SiparişlerToplam()-1; cnt++)

if(OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES))

if((OrderSymbol() == Symbol()) &&(OrderMagicNumber() == SystemMagicNumber) &&

(OrderType()==OP_BUY)

)

{

Sonuç++;

}

dönüş(Sonuç);

}

int SellPositionsCount()

{

int Sonuç=0;

for(int cnt=0; cnt<=SiparişlerToplam()-1; cnt++)

if(OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES))

if((OrderSymbol() == Symbol()) &&(OrderMagicNumber() == SystemMagicNumber) &&

(OrderType()==OP_SEL)

)

{

Sonuç++;

}

dönüş(Sonuç);

}

 
bearfoot090:
Merhaba!

burada bazıları bu işlevi eklememe yardımcı olabilir. Çubuk tamamlandığında işlemi kapatın veya bir sonraki çubuk göründüğünde işlemi kapatmasını sağlayın.

Yeni bir çubuğu algılamak için birkaç çözüm vardır:

1)

if(Volume[0] == 1) CloseOrders(); [/PHP] Not very reliable, for example if the terminal has to be restarted you may loose the first tick of the bar.

2)

if(BarsCnt < Bars) {BarsCnt = Bars; CloseOrders();}[/PHP] Not very reliable, for example if new bars are added to the left of the chart.

3)

if(Time1 < Time[0]) {Time1 = Time[0]; CloseOrders();}

Better, but again, restarting the terminal may produce wrong behaviors.

So my opinion is that the best is to write the lifetime max of each order into the order itself, using the "Comment" field :[PHP]OrderSend(..., ""+(Time[0] + Period()*60), ..);
Then you can scan the orders and check :[PHP]if(TimeCurrent() > OrderComment()) OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 0, CLR_NONE);

. Bu iyi bir çözüm çünkü kapatmanız gereken birkaç siparişiniz varsa, bunu yapmak için her zaman ihtiyacınız var.

 

cevap için teşekkürler michel.

deneyeceğim. ama yoruma ne koyayım? beğendiğim bir şey var mı?

 
bearfoot090:
cevap için teşekkürler michel. deneyeceğim. ama yoruma ne koyayım? beğendiğim bir şey var mı?

Siparişi kapatmak istediğiniz zamanı girin. Yorum alanı bir dize olmalıdır, bu yüzden değerin önünde ""+ vardır. örneğin:

""+(Time[0] + Period()*60) // begin of the next bar on the current timeframe

""+(TimeCurrent() + 2*360 + 30*60) // 2 hours 30 minutes after the openning

""+(iTime(NULL,PERIOD_D1,0) + 23*360 + 45*60) // today at 23:45 (server time)

""+(iTime(NULL,PERIOD_W1,0) + (PERIOD_W1 - 10)*60) // next friday at 23:50
 

teşekkürler

Michel:
Gerekirse, önce saat 8'den sonra olup olmadığınızı kontrol edin:
if(Hour() < 8) return;[/PHP]

Then, find the max and min of the current day. (if its ok for you, its easier than from 8 am): [PHP]double Max = iHigh(Symbol(), PERIOD_D1, 0);

double Min = iLow(Symbol(), PERIOD_D1, 0);

int Range = (Max - Min) / Point;

if(Range > 90) return;

...

Merhaba,

"Teşekkür ederim" demek için bu kadar uzun zaman aldığım için özür dilerim.

Yardımını takdir ediyorum.

Tekrar teşekkürler.

Şek

 
Michel:
Yeni bir çubuğu algılamak için birkaç çözüm vardır:

1)

if(Volume[0] == 1) CloseOrders(); [/PHP] Not very reliable, for example if the terminal has to be restarted you may loose the first tick of the bar.

2)

if(BarsCnt < Bars) {BarsCnt = Bars; CloseOrders();}[/PHP] Not very reliable, for example if new bars are added to the left of the chart.

3)

if(Time1 < Time[0]) {Time1 = Time[0]; CloseOrders();}[/PHP] Better, but again, restarting the terminal may produce wrong behaviors.

So my opinion is that the best is to write the lifetime max of each order into the order itself, using the "Comment" field :

OrderSend(..., ""+(Time[0] + Period()*60), ..);[/PHP] Then you can scan the orders and check :[PHP]if(TimeCurrent() > OrderComment()) OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 0, CLR_NONE);
. This is a good solution because if you have several orders to close, you have all the time needed to do it.

i got the error below.what does ot mean?

[PHP]'>' - different types in comparison F:\Program Files\MetaTrader - FXOpen\experts\EMA_10.mq4 (88, 22)

I make it like this

for the send order

[PHP]OrderSend(Symbol(),OP_BUY,Lots,Ask,0,Ask-25*Point,Ask+TakeProfit*Point, ""+(Time[0] + Period()*60),SystemMagicNumber,0,Blue);

ve yakın sipariş için

[PHP]if(TimeCurrent() > OrderComment())

{

OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 0, CLR_NONE);

}

ve yukarıda gösterilen hatayı aldım.

Doğru mu?

 

benim hatam, üzgünüm.

Bu çalışmalı:

if(TimeCurrent() > StringToInteger(OrderComment())
Neden: