Kodlama yardımı.. Uyarı yerine filtrelenecek göstergeyi nasıl alabilirim? - sayfa 8

 

Adamım!

yani....bakalım bunu doğru anlamış mıyım...

Hareketli bir ortalamanın arka çaprazına dayalı pozisyonları kapatmak isteseydim, kodlamam gereken tek şey bu...

if(currentlong>minorts) {CloseOrder(OP_SELL); // Tüm satış emirlerini kapat}

şimdikiuzun 20ema ve minörlerin 150ema olduğu yerde, açık pozisyon seyrini sürdüren bir kısa pozisyon olurdu veya IS ve şimdi 20ema, kısa ticaret için yakın sinyal olan 150ema'nın üzerinde hareket ediyor.

ve...

if (mevcutuzun<minorts) {CloseOrder(OP_BUY); // Tüm satın alma siparişlerini kapat}

şu ankiuzun 20ema ve minörlerin 150ema olduğu yerde, açık pozisyon, seyrini sürdüren uzun bir pozisyon olurdu veya IS ve şimdi 20ema, uzun ticaret için yakın sinyal olan 150ema'nın altına hareket ediyor.

Böylece sadece bu iki satırı koyabilirim

if (mevcutuzun<minorts) {CloseOrder(OP_BUY); // Tüm satın alma siparişlerini kapat}

if(currentlong>minorts) {CloseOrder(OP_SELL); // Tüm satış emirlerini kapat}

giriş kodundan hemen sonra ve bunun gibi diğer tüm kapanış ve sondaki durma şeylerinden önce mi? ve işe yarayacak mı?

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

}

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

return(0);

}

}

//+---------end of order entry-------------------------+

//+------close on moving average cross-----------------+

if(currentlong<minorts) {CloseOrder(OP_BUY);} // Close all buy orders}

if(currentlong>minorts) {CloseOrder(OP_SELL);} // Close all sell orders}

//+--------end of close on moving average cross--------+

//+-------------------------Trailing Stop Code------------------------------------+

for(cnt=0;cnt<total;cnt++) {

OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);

if(OrderType()<=OP_SELL && OrderSymbol()==Symbol()) {

if(OrderType()==OP_BUY){

derleyici şunu söylüyor:

')' - yanlış parametre sayımı C:\Program Files\Interbank FX Trader 4-live mini\experts\whatever.mq4 (85, 43)

')' - yanlış parametre sayımı C:\Program Files\Interbank FX Trader 4-live mini\experts\whatever.mq4 (86, 44)

Bu satırları sevmiyor. Çok iyi iletişim kurduğumu hissetmiyorum.

 

bu ilginç aniden metaeditördeki arama fonksiyonum çalışıyor?

bool OrderCloseBy( int bilet, int zıt, renkli Renk=CLR_NONE)

Açık bir emri, başka bir açık emir tarafından kapatır. İşlev başarılı olursa, dönüş değeri doğrudur. İşlev başarısız olursa, dönüş değeri false olur. Ayrıntılı hata bilgilerini almak için GetLastError() öğesini çağırın .

parametreler:

bilet - Sipariş biletinin benzersiz numarası.

ters - Karşı sipariş biletinin benzersiz numarası.

Renk - Grafikteki kapanış okunun rengi. Parametre eksikse veya CLR_NONE değerine sahipse, grafikte kapatma oku çizilmeyecektir.

Örneklem:

if(iRSI(NULL,0,14,PRICE_CLOSE,0)>75)

{

OrderCloseBy(order_id, karşıt_id);

dönüş(0);

}

bu yüzden böyle bir şey hayal ediyorum ...

if(currentlong<minorts)

{

OrderCloseBy(order_id,opposite_id);

return(0);

}[/PHP]

thing is this doesn't distinguish what kind of position I'm into first, long or short. So if I put the opposite side of this with it...like this...

[PHP] if(currentlong>minorts)

{

OrderCloseBy(order_id,opposite_id);

return(0);

}

birlikte her şeyi kapatırlardı değil mi? daha fazlası olmalı...İçimde dışarı çıkamayacağım tam fikirler varken, henüz tam cümleleri iletmek için gerçekten konuşamayan bir çocuk kadar hüsrana uğramış hissediyorum.

 
elihayun:
bunu unuttum
void CloseOrder(int ticket,double numLots,double close_price)

{

int CloseCnt, err;

// try to close 3 Times

CloseCnt = 0;

color clr = Violet;

if (OrderType() == OP_SELL)

clr = Orange;

while (CloseCnt < 3)

{

if (OrderClose(ticket,numLots,close_price,Slippage,clr))

{

CloseCnt = 3;

}

else

{

err=GetLastError();

Print(CloseCnt," Error closing order : (", err , ") " + ErrorDescription(err));

if (err > 0) CloseCnt++;

}

}

}

[/PHP]

and dont forget to add this line after #property link

[PHP]#property link "http://www.elihayun.com"

#include

bu ne yapar? Bu, çağrılabilmesi için indirmem gereken başka bir şey mi? Bunun ne yaptığını, uzun pozisyonları kısa pozisyonlardan nasıl ayırt ettiğini anlamak istiyorum. Öğrenmek istiyorum.

 
Aaragorn:
Adamım!

yani....bakalım bunu doğru anlamış mıyım...

Böylece sadece bu iki satırı koyabilirim

if (mevcutuzun<minorts) {CloseOrder(OP_BUY); // Tüm satın alma siparişlerini kapat}

if(currentlong>minorts) {CloseOrder(OP_SELL); // Tüm satış emirlerini kapat}

//+------ hareketli ortalama çaprazında kapat -----------------+

if(currentlong<minorts) {CloseOrder(OP_BUY);} // Tüm satın alma siparişlerini kapat}

if(currentlong>minorts) {CloseOrder(OP_SELL);} // Tüm satış emirlerini kapat}

if(OrderType()==OP_BUY){[/PHP]

derleyici şunu söylüyor:

')' - yanlış parametre sayımı C:\Program Files\Interbank FX Trader 4-live mini\experts\whatever.mq4 (85, 43)

')' - yanlış parametre sayımı C:\Program Files\Interbank FX Trader 4-live mini\experts\whatever.mq4 (86, 44)

Bu satırları sevmiyor. Çok iyi iletişim kurduğumu hissetmiyorum.

CloseOrder s'yi sonunda CloseOrder değil s ile çağırmanız gerekir (sadece bir siparişi kapatır)

 
Aaragorn:
bu ne yapar? Bu, çağrılabilmesi için indirmem gereken başka bir şey mi? Bunun ne yaptığını, uzun pozisyonları kısa pozisyonlardan nasıl ayırt ettiğini anlamak istiyorum. Öğrenmek istiyorum.

MQL4'ün bir parçasıdır ve ErrorDescription işlevini içerir

 
elihayun:
MQL4'ün bir parçasıdır ve ErrorDescription işlevini içerir

tamam Hala hareketli ortalama çaprazına dayalı olarak kapatmama izin verecek bir koda ihtiyacım var.

 

Bu kod parçası sizi harekete geçirmeli ...

Tabii ki, kendi ihtiyaçlarınıza göre değiştirmek zorunda kalacaksınız. Ancak, bu size bir başlangıç noktası sağlamalıdır. Bu rutin, takip eden durak olarak SMA1 hattını kullanır. Öyleyse bu fikri al ve bundan ne çıkarabileceğini gör.

//these two lines within start()

SMA1 = iMA(NULL,TimePeriod,SlowPeriod,0,SlowMode,SlowPrice,1);

TrailingAlls(TrailStart, SMA1);

// trailing routine using the value of SMA1

void TrailingAlls(int start, double currvalue)

{

int profit;

double stoptrade;

double stopcal;

// if(stop==0) return;

int trade;

for(trade=OrdersTotal()-1;trade>=0;trade--)

{

if(!OrderSelect(trade,SELECT_BY_POS,MODE_TRADES))

continue;

if(OrderSymbol()!=Symbol()||OrderMagicNumber()!=MagicNumber)

continue;

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

{

if(OrderType()==OP_BUY)

{

profit=NormalizeDouble((Bid-OrderOpenPrice())/Point,0);

if(profit<start)

continue;

stoptrade=OrderStopLoss();

// stopcal=Bid-(stop*Point);

stopcal=NormalizeDouble(currvalue, Digits);

if(stoptrade==0||(stoptrade!=0&&stopcal>stoptrade))

OrderModify(OrderTicket(),OrderOpenPrice(),stopcal,OrderTakeProfit(),0,Blue);

}//Long

if(OrderType()==OP_SELL)

{

profit=NormalizeDouble((OrderOpenPrice()-Ask)/Point,0);

if(profit<start)

continue;

stoptrade=OrderStopLoss();

// stopcal=Ask+(stop*Point);

stopcal=NormalizeDouble(currvalue, Digits);

if(stoptrade==0||(stoptrade!=0&&stopcal<stoptrade))

OrderModify(OrderTicket(),OrderOpenPrice(),stopcal,OrderTakeProfit(),0,Red);

}//Shrt

}

}//for

}

 

önce bunu çözebilirsem, takip eden bir durma kapanışı muhtemelen yararlıdır ....

elihayun'un bana verdiği bu snippet, eğer birisi onu ma backcross'a nasıl tepki vereceğini ve doğru yönde nasıl alacağını bulabilirse işe yarayacağını düşünüyorum. Hangisi olan op_buy ve op_sell ile kafam karıştı. hangilerinin uzun pozisyonları, hangilerinin kısa pozisyonları kapatmak için kullanılacağı.

//+------close on moving average cross-----------------+

void CloseOrders(int op)

{

int tik[30], t = 0;

for(int i =0;i<OrdersTotal();i++){

if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)){

if(OrderSymbol()==Symbol() && MagicNum==OrderMagicNumber() && OrderType() == op){

tik[t] = OrderTicket(); t++;

}

}

}

for (i = 0; i<t; i++)

{

if(OrderSelect(tik,SELECT_BY_TICKET)){

double prc = Bid;

if (op == OP_SELL) prc = Ask;

CloseOrder(tik, OrderLots(), prc);

}

}

}

//+--------end of close on moving average cross--------+[/PHP]

I think I see that at this point in the code it has selected the orders by ticket and it's figuring out to set the close price based on the bid or the ask. So I'm not sure which is which for long or short positions. If the ticket is a long position that means it was opened at the ask price right? so it should close on the bid price? so this snippet is saying use the bid price to close so I assume that's for a long position. THEN it asks the

if (op == OP_SELL) prc = Ask;

so I assume this is the first place in this code where we now know if we are looking at a long or a short position ticket.

Then it moves immediately to close. But if I can put my closing criteria in here BEFORE it does that???

here it is as I received it...

for (i = 0; i<t; i++)

{

if(OrderSelect(tik,SELECT_BY_TICKET)){

double prc = Bid;

if (op == OP_SELL) prc = Ask;

CloseOrder(tik, OrderLots(), prc);

}[/PHP]

so what I'm thinking is that this is the place in the code where I should insert the moving average criteria to trigger the close for long or short positions. Something like this...

[PHP]for (i = 0; i<t; i++)

{

if(OrderSelect(tik,SELECT_BY_TICKET)){

double prc = Bid;

if (op == OP_SELL) prc = Ask;

if (prc == Bid && currentlong minorts);

CloseOrder(tik, OrderLots(), prc);

}

Will this do it? I think it might if I understand correctly..

Please tell me coders if this is correct??

I think this connects the direction of the moving average cross to the type of position that the ticket is identifed as being.

if the bid is to close long positions so we know the ticket is for a long position then it can close long positions if the currentlongema < minortsEMA because it knows that the ticket is for a long position and the 20ema has moved below the 150ema.

If the ask is for closing short positions and the ticket is identified as a short position because it wants to close at the ask price and the currentlongEMA has moved above the minortsEMA because it knows the ticket is for a short position and the 20ema has moved above the 150ema.

if that is correct will adding this line to the code,

if (prc == Bid && currentlong minorts)

stop it from closing UNLESS each ticket fits this criteria?

...that for the long position the 20ema150ema?

if that is ok then the logic for deciding to close long or short based on the emacrossback is ok and it's worth fixing these errors

I get these errors from the compiler...

[PHP]Compiling 'whatever.mq4'...

'(' - function definition unexpected C:\Program Files\Interbank FX Trader 4-live mini\experts\whatever.mq4 (85, 17)

'MagicNum' - variable not defined C:\Program Files\Interbank FX Trader 4-live mini\experts\whatever.mq4 (90, 40)

'op' - variable not defined C:\Program Files\Interbank FX Trader 4-live mini\experts\whatever.mq4 (90, 87)

'tik' - variable not defined C:\Program Files\Interbank FX Trader 4-live mini\experts\whatever.mq4 (91, 13)

't' - variable not defined C:\Program Files\Interbank FX Trader 4-live mini\experts\whatever.mq4 (91, 17)

't' - variable not defined C:\Program Files\Interbank FX Trader 4-live mini\experts\whatever.mq4 (91, 37)

't' - variable not defined C:\Program Files\Interbank FX Trader 4-live mini\experts\whatever.mq4 (96, 18)

'tik' - variable not defined C:\Program Files\Interbank FX Trader 4-live mini\experts\whatever.mq4 (98, 22)

'op' - variable not defined C:\Program Files\Interbank FX Trader 4-live mini\experts\whatever.mq4 (100, 14)

'tik' - variable not defined C:\Program Files\Interbank FX Trader 4-live mini\experts\whatever.mq4 (102, 21)

'cnt' - expression on global scope not allowed C:\Program Files\Interbank FX Trader 4-live mini\experts\whatever.mq4 (108, 5)

'cnt' - variable not defined C:\Program Files\Interbank FX Trader 4-live mini\experts\whatever.mq4 (108, 5)

'cnt' - expression on global scope not allowed C:\Program Files\Interbank FX Trader 4-live mini\experts\whatever.mq4 (108, 11)

'cnt' - variable not defined C:\Program Files\Interbank FX Trader 4-live mini\experts\whatever.mq4 (108, 11)

'total' - expression on global scope not allowed C:\Program Files\Interbank FX Trader 4-live mini\experts\whatever.mq4 (108, 15)

'total' - variable not defined C:\Program Files\Interbank FX Trader 4-live mini\experts\whatever.mq4 (108, 15)

'cnt' - expression on global scope not allowed C:\Program Files\Interbank FX Trader 4-live mini\experts\whatever.mq4 (108, 21)

'cnt' - variable not defined C:\Program Files\Interbank FX Trader 4-live mini\experts\whatever.mq4 (108, 21)

'{' - expression on global scope not allowed C:\Program Files\Interbank FX Trader 4-live mini\experts\whatever.mq4 (108, 28)

'i' - variable is already defined C:\Program Files\Interbank FX Trader 4-live mini\experts\whatever.mq4 (135, 11)

'}' - unbalanced parentheses C:\Program Files\Interbank FX Trader 4-live mini\experts\whatever.mq4 (165, 1)

16 error(s), 5 warning(s)

 

Tüm üyelere bir öneri, işlemleri kapatmak için "sayım" rutinlerini kullanmayın. Örneğin, böyle bir şey kullanmayın:

için (i = 0; i<t; i++)

{

if(OrderSelect(tik,SELECT_BY_TICKET)){

double prc = Teklif;

if (op == OP_SELL) prc = Sor;

CloseOrder(tik, OrderLots(), prc);

}

Birden fazla sipariş kullanıyorsanız, son siparişi kapatmaz. Bir "geri sayım" rutini kullanın. Bu rahatsız edici "böcek"le ilk karşılaştığımda Metaquotes geliştiricileri ile yaptığım tartışma burada.

http://www.metaquotes.net/forum/2018/

 
Maji:
Bu kod parçası sizi harekete geçirmeli ...

Tabii ki, kendi ihtiyaçlarınıza göre değiştirmek zorunda kalacaksınız. Ancak, bu size bir başlangıç noktası sağlamalıdır. Bu rutin, takip eden durak olarak SMA1 hattını kullanır. Öyleyse bu fikri al ve bundan ne çıkarabileceğini gör.

//these two lines within start()

SMA1 = iMA(NULL,TimePeriod,SlowPeriod,0,SlowMode,SlowPrice,1);

TrailingAlls(TrailStart, SMA1);

// trailing routine using the value of SMA1

void TrailingAlls(int start, double currvalue)

{

int profit;

double stoptrade;

double stopcal;

// if(stop==0) return;

int trade;

for(trade=OrdersTotal()-1;trade>=0;trade--)

{

if(!OrderSelect(trade,SELECT_BY_POS,MODE_TRADES))

continue;

if(OrderSymbol()!=Symbol()||OrderMagicNumber()!=MagicNumber)

continue;

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

{

if(OrderType()==OP_BUY)

{

profit=NormalizeDouble((Bid-OrderOpenPrice())/Point,0);

if(profit<start)

continue;

stoptrade=OrderStopLoss();

// stopcal=Bid-(stop*Point);

stopcal=NormalizeDouble(currvalue, Digits);

if(stoptrade==0||(stoptrade!=0&&stopcal>stoptrade))

OrderModify(OrderTicket(),OrderOpenPrice(),stopcal,OrderTakeProfit(),0,Blue);

}//Long

if(OrderType()==OP_SELL)

{

profit=NormalizeDouble((OrderOpenPrice()-Ask)/Point,0);

if(profit<start)

continue;

stoptrade=OrderStopLoss();

// stopcal=Ask+(stop*Point);

stopcal=NormalizeDouble(currvalue, Digits);

if(stoptrade==0||(stoptrade!=0&&stopcal<stoptrade))

OrderModify(OrderTicket(),OrderOpenPrice(),stopcal,OrderTakeProfit(),0,Red);

}//Shrt

}

}//for

}

çok teşekkür ederim. Bunu incelemek ve bundan ne yapabileceğimi görmek için sabırsızlanıyorum ...

emacrossback'i önce çalıştırmak istememin nedeni, temelde benim stoploss'um ve varsayılan çıkış stratejim olacak.

Bu işe yaradığında, karlılığı artırmak için bunun gibi şeyler ekleyeceğim. Ancak, her şeyi mahvetmeden stop loss'a sahip olamadığım ve büyük stop loss parametrelerine izin vermeye istekli olmadığım için, önce hareketli ortalama çapraz kapanışın çalışmasını istiyorum. Çapraz kapanışla şu ana kadar ne yaptığımı doğrulama şansınız olursa minnettar olurum.

Neden: