Yeni başlayanlardan sorular MQL4 MT4 MetaTrader 4 - sayfa 35

 

Merhaba!
Göstergeyi düzeltmek için tüm noktaları "" değiştirmek gerekiyordu. boşaltmak için "".

Dosyalar:
supDem.zip  68 kb
 

Selamlar.

Emirseçim fonksiyonunda belirli emirleri saymak için yazılan fonksiyonda, siparişe göre seçimden bilete göre seçim tipini değiştirdim.

int  BuyLimitCount(){
int  count= 0
for ( int  i= OrdersTotal ()- 1 ; i>= 0 ; i--){
if ( OrderSelect (i,  SELECT_BY_POSMODE_TRADES )== true ){
if ( OrderMagicNumber ()==MagicB){
if ( OrderType ()== OP_BUYLIMIT )
count++;}}} return (count);}  

int  BuyLimitCount(){
int  count= 0
if ( OrderSelect (ticketUP,  SELECT_BY_TICKETMODE_TRADES )== true ){
if ( OrderMagicNumber ()==MagicB){
if ( OrderType ()== OP_BUYLIMIT )
count++;}} return (count);}

Bundan sonra, birkaç düzine mum başlatırken, her şey doğru bir şekilde yapılır ve ardından aşağıdaki hatalar günlüğe gider ve tekrarlanır:

2016.12.17 17:44:31.609 2016.12.07 00:27 test3 EURUSD,M1: OrderModify işlevi için bilinmeyen bilet 2

2016.12.17 17:44:31.608 2016.12.07 00:25 test3 EURUSD,M1: OrderModify hatası 4108 // Geçersiz bilet numarası.

Dört işlevin tamamında buna göre değiştirilmiş tam metin:

extern   int  pointsl= 100 , pointtp= 100 , MagicB= 1111 , MagicS= 2222 , bars= 10 ;   extern   double  lotB= 0.1 , lotS= 0.1 ;
double  slB, tpB, slS, tpS;   double  x= 0 , z= 0int  ticketUP, ticketD;


void   OnTick ()  
{
double  maxpr1=- 9999double  minpr1= 9999 ;

for ( int  shift1= 0 ; shift1<bars; shift1++)
{ double  i= iHigh ( Symbol (),  PERIOD_CURRENT , shift1);
if  (i>maxpr1){maxpr1=i;}}

for ( int  shiftA1= 0 ; shiftA1<bars; shiftA1++)
{ double  y= iLow ( Symbol (),  PERIOD_CURRENT , shiftA1);
if  (y<minpr1) {minpr1=y;}} 

if  (BuyLimitCount()== 0  && BuyCount()== 0 ){
slB= NormalizeDouble (minpr1-pointsl* Point , 5 );
tpB= NormalizeDouble (minpr1+pointtp* Point , 5 );
ticketUP= OrderSend ( Symbol (),  OP_BUYLIMIT , lotB, minpr1,  3 , slB, tpB,  "" , MagicB,  0 , Red);
if  (ticketUP==- 1Print ( "ERROR OP_BUY" );  else   Print ( "OP_BUY OK" );}

if  (SellLimitCount()== 0  && SellCount() == 0 ){
slS= NormalizeDouble (maxpr1+pointsl* Point , 5 );
tpS= NormalizeDouble (maxpr1-pointtp* Point , 5 );
ticketD= OrderSend ( Symbol (),  OP_SELLLIMIT , lotS, maxpr1,  3 , slS, tpS,  "" , MagicS,  0 , Blue);
if  (ticketD==- 1Print ( "ERROR OP_SELL" );  else   Print ( "OP_SELL OK" );}

if  (x!=maxpr1){x=maxpr1;
slS= NormalizeDouble (maxpr1+pointsl* Point , 5 );
tpS= NormalizeDouble (maxpr1-pointtp* Point , 5 );
OrderModify (ticketD, maxpr1, slS, tpS,  0 , Blue);}

if  (z!=minpr1){z=minpr1;
slB= NormalizeDouble (minpr1-pointsl* Point , 5 );
tpB= NormalizeDouble (minpr1+pointtp* Point , 5 );
OrderModify (ticketUP, minpr1, slB, tpB,  0 , Red);}

double  maxpr=- 9999double  minpr= 9999 ;

for ( int  shift= 0 ; shift<bars; shift++)
{ double  e= iHigh ( Symbol (),  PERIOD_CURRENT , shift);
if  (e>maxpr){maxpr=e;}}

for ( int  shiftA= 0 ; shiftA<bars; shiftA++)
{ double  r= iLow ( Symbol (),  PERIOD_CURRENT , shiftA);
if  (r<minpr) {minpr=r;}} 

string  a;
if (bars== 1 )a= "bar: " ;
else  a=  IntegerToString (bars, 1 ) +  " bar's: " ;
Comment ( "Last " , a,  "max "DoubleToStr (maxpr,  5 ),  ", min "DoubleToStr (minpr,  5 ), "." );
}

int  BuyLimitCount(){
int  count= 0
if ( OrderSelect (ticketUP,  SELECT_BY_TICKETMODE_TRADES )== true ){
if ( OrderMagicNumber ()==MagicB){
if ( OrderType ()== OP_BUYLIMIT )
count++;}} return (count);}

int  BuyCount(){
int  count= 0
if ( OrderSelect (ticketUP,  SELECT_BY_TICKETMODE_TRADES )== true ){
if ( OrderMagicNumber ()==MagicB){
if ( OrderType ()== OP_BUY )
count++;}} return (count);}

int  SellLimitCount(){
int  count= 0
if ( OrderSelect (ticketD,  SELECT_BY_TICKETMODE_TRADES )== true ){
if ( OrderMagicNumber ()==MagicS){
if ( OrderType ()== OP_SELLLIMIT )
count++;}} return (count);}

int  SellCount(){
int  count= 0
if ( OrderSelect (ticketD,  SELECT_BY_TICKETMODE_TRADES )== true ){
if ( OrderMagicNumber ()==MagicS){
if ( OrderType ()== OP_SELL )
count++;}} return (count);}


Ve bir nokta var - seçim işlevini değiştirdikten sonra, sipariş değiştirme işlevi bir hata vermeye başladı ve yalnızca testin başlamasından bir süre sonra, ilk başta her şey yolundaydı.

Bu neden oluyor ve bununla nasıl başa çıkılır?


 
spoiltboy :

Selamlar.

Emirseçim fonksiyonunda belirli emirleri saymak için yazılan fonksiyonda, siparişe göre seçimden bilete göre seçim tipini değiştirdim.

int  BuyLimitCount(){
int  count= 0
for ( int  i= OrdersTotal ()- 1 ; i>= 0 ; i--){
if ( OrderSelect (i,  SELECT_BY_POSMODE_TRADES )== true ){
if ( OrderMagicNumber ()==MagicB){
if ( OrderType ()== OP_BUYLIMIT )
count++;}}} return (count);}  

int  BuyLimitCount(){
int  count= 0
if ( OrderSelect (ticketUP,  SELECT_BY_TICKETMODE_TRADES )== true ){
if ( OrderMagicNumber ()==MagicB){
if ( OrderType ()== OP_BUYLIMIT )
count++;}} return (count);}

Bundan sonra, birkaç düzine mum başlatırken, her şey doğru bir şekilde yapılır ve ardından aşağıdaki hatalar günlüğe gider ve tekrarlanır:

2016.12.17 17:44:31.609 2016.12.07 00:27 test3 EURUSD,M1: OrderModify işlevi için bilinmeyen bilet 2

2016.12.17 17:44:31.608 2016.12.07 00:25 test3 EURUSD,M1: OrderModify hatası 4108 // Geçersiz bilet numarası.

Dört işlevin tamamında buna göre değiştirilmiş tam metin:

extern   int  pointsl= 100 , pointtp= 100 , MagicB= 1111 , MagicS= 2222 , bars= 10 ;   extern   double  lotB= 0.1 , lotS= 0.1 ;
double  slB, tpB, slS, tpS;   double  x= 0 , z= 0int  ticketUP, ticketD;


void   OnTick ()  
{
double  maxpr1=- 9999double  minpr1= 9999 ;

for ( int  shift1= 0 ; shift1<bars; shift1++)
{ double  i= iHigh ( Symbol (),  PERIOD_CURRENT , shift1);
if  (i>maxpr1){maxpr1=i;}}

for ( int  shiftA1= 0 ; shiftA1<bars; shiftA1++)
{ double  y= iLow ( Symbol (),  PERIOD_CURRENT , shiftA1);
if  (y<minpr1) {minpr1=y;}} 

if  (BuyLimitCount()== 0  && BuyCount()== 0 ){
slB= NormalizeDouble (minpr1-pointsl* Point , 5 );
tpB= NormalizeDouble (minpr1+pointtp* Point , 5 );
ticketUP= OrderSend ( Symbol (),  OP_BUYLIMIT , lotB, minpr1,  3 , slB, tpB,  "" , MagicB,  0 , Red);
if  (ticketUP==- 1Print ( "ERROR OP_BUY" );  else   Print ( "OP_BUY OK" );}

if  (SellLimitCount()== 0  && SellCount() == 0 ){
slS= NormalizeDouble (maxpr1+pointsl* Point , 5 );
tpS= NormalizeDouble (maxpr1-pointtp* Point , 5 );
ticketD= OrderSend ( Symbol (),  OP_SELLLIMIT , lotS, maxpr1,  3 , slS, tpS,  "" , MagicS,  0 , Blue);
if  (ticketD==- 1Print ( "ERROR OP_SELL" );  else   Print ( "OP_SELL OK" );}

if  (x!=maxpr1){x=maxpr1;
slS= NormalizeDouble (maxpr1+pointsl* Point , 5 );
tpS= NormalizeDouble (maxpr1-pointtp* Point , 5 );
OrderModify (ticketD, maxpr1, slS, tpS,  0 , Blue);}

if  (z!=minpr1){z=minpr1;
slB= NormalizeDouble (minpr1-pointsl* Point , 5 );
tpB= NormalizeDouble (minpr1+pointtp* Point , 5 );
OrderModify (ticketUP, minpr1, slB, tpB,  0 , Red);}

double  maxpr=- 9999double  minpr= 9999 ;

for ( int  shift= 0 ; shift<bars; shift++)
{ double  e= iHigh ( Symbol (),  PERIOD_CURRENT , shift);
if  (e>maxpr){maxpr=e;}}

for ( int  shiftA= 0 ; shiftA<bars; shiftA++)
{ double  r= iLow ( Symbol (),  PERIOD_CURRENT , shiftA);
if  (r<minpr) {minpr=r;}} 

string  a;
if (bars== 1 )a= "bar: " ;
else  a=  IntegerToString (bars, 1 ) +  " bar's: " ;
Comment ( "Last " , a,  "max "DoubleToStr (maxpr,  5 ),  ", min "DoubleToStr (minpr,  5 ), "." );
}

int  BuyLimitCount(){
int  count= 0
if ( OrderSelect (ticketUP,  SELECT_BY_TICKETMODE_TRADES )== true ){
if ( OrderMagicNumber ()==MagicB){
if ( OrderType ()== OP_BUYLIMIT )
count++;}} return (count);}

int  BuyCount(){
int  count= 0
if ( OrderSelect (ticketUP,  SELECT_BY_TICKETMODE_TRADES )== true ){
if ( OrderMagicNumber ()==MagicB){
if ( OrderType ()== OP_BUY )
count++;}} return (count);}

int  SellLimitCount(){
int  count= 0
if ( OrderSelect (ticketD,  SELECT_BY_TICKETMODE_TRADES )== true ){
if ( OrderMagicNumber ()==MagicS){
if ( OrderType ()== OP_SELLLIMIT )
count++;}} return (count);}

int  SellCount(){
int  count= 0
if ( OrderSelect (ticketD,  SELECT_BY_TICKETMODE_TRADES )== true ){
if ( OrderMagicNumber ()==MagicS){
if ( OrderType ()== OP_SELL )
count++;}} return (count);}


Ve bir nokta var - seçim işlevini değiştirdikten sonra, sipariş değiştirme işlevi bir hata vermeye başladı ve yalnızca testin başlamasından bir süre sonra, ilk başta her şey yolundaydı.

Bu neden oluyor ve bununla nasıl başa çıkılır?


Büyük olasılıkla bu hatayı, zaten çalışan veya kaldırılmış bir geciktiriciyi değiştirmeye çalıştığınız için alıyorsunuz. Örneğin bekleyen bir sipariş tetiklendiğinde, bekleyen biletlerin saklandığı değişkenleri sıfırlamak gerekir.
 
Sergey Gritsay :
Büyük olasılıkla bu hatayı, zaten çalışan veya kaldırılmış bir geciktiriciyi değiştirmeye çalıştığınız için alıyorsunuz. Örneğin bekleyen bir sipariş tetiklendiğinde, bekleyen biletlerin saklandığı değişkenleri sıfırlamak gerekir.
Nasıl doğru yapacağımı söyler misin? Ve sonra bir şey çalışmıyor.
 

Herkese merhaba, neyin yanlış olduğunu anlamama yardım edin.

EA bir sipariş bileti açar=OrderSend(Symbol(),OP_BUY,Lot,Ask,3,0,0,"AV2",1111,0,Green);

MT4'ü kapat, MT4'ü aç, danışmanın önceki çalışması kontrol ediliyor

for(int prev=0; önceki< OrdersTotal() ;prev++) //EA'nın önceki çalışmasını kontrol etme

{

ViborOrdera=SiparişSeç(önceki,SELECT_BY_POS);

if(OrderSymbol()==Symbol())

//*********************************************

//-------Satın alma döngüsünü kontrol etme-------

if (OrderType()==OP_BUY && OrderMagicNumber()==1111)

{

PriceAsk=OrderOpenPrice();//EA'nın daha fazla çalışması için gerekli açılış fiyatı

}

soru şu ki, hata nerede, kontrol yok mu? döngü girilmez. Döngü gövdesi Init'tedir.

 

Anlamak için zaman yok..........

Okumaya ve doğru yerlere koymaya çalışın

bool RefreshRates ();

///
 
ed3sss :

Herkese merhaba, neyin yanlış olduğunu anlamama yardım edin.

EA bir sipariş bileti açar=OrderSend(Symbol(),OP_BUY,Lot,Ask,3,0,0,"AV2",1111,0,Green);

MT4'ü kapat, MT4'ü aç, danışmanın önceki çalışması kontrol ediliyor


soru şu ki, hata nerede, kontrol yok mu? döngü girilmez. Döngü gövdesi Init'tedir.

Ve döngüye tam olarak neyin girmediğini kanıtlayın. Ayrıca, en sonuncusuna ihtiyacınız varsa, neden hesabın ömrünün en başından itibaren TÜM siparişleri kontrol edin ???
 
Mikhail Kozhemyako :

Anlamak için zaman yok..........

Okumaya ve doğru yerlere koymaya çalışın

bool RefreshRates ();

///
Yardım etmedi(
 
Vitalie Postolache :
Ve döngüye tam olarak neyin girmediğini kanıtlayın. Ayrıca, en sonuncusuna ihtiyacınız varsa, neden hesabın ömrünün en başından itibaren TÜM siparişleri kontrol edin ???

Kanıt: Yazdır ("Önceki İş Fiyat Sorusu-", Fiyat Sorusu); günlük boş.

Ayrıca, en sonuncusuna ihtiyacınız varsa, neden hesabın ömrünün en başından itibaren TÜM siparişleri kontrol edin ??? - 10 döviz çifti açıksa başka nasıl yapılır?


 

MQL'de bunu değiştirene kadar her şey yolundaydı: ViborOrdera=OrderSelect(prev,SELECT_BY_POS);

Eskiden bu OrderSelect (önceki,SELECT_BY_POS); gibiydi. Uzun zaman önceydi, ama işe yaradı.