MQL4 ve MQL5 ile ilgili herhangi bir acemi sorusu, algoritmalar ve kodlar hakkında yardım ve tartışma - sayfa 35

 

İşte olanlar.

Ayrı ayrı doğru tespit ediyor gibi görünüyor

#property version    "1.00"
#property strict
#property indicator_chart_window
#property indicator_buffers 6
#property indicator_plots    6
//--- plot UpBar
#property indicator_label1   "UpBar"
#property indicator_type1   DRAW_ARROW
#property indicator_color1   clrDeepSkyBlue
#property indicator_style1   STYLE_SOLID
#property indicator_width1   1
//--- plot DnBar
#property indicator_label2   "DnBar"
#property indicator_type2   DRAW_ARROW
#property indicator_color2   clrDeepPink
#property indicator_style2   STYLE_SOLID
#property indicator_width2   1

//--- plot UpFr
#property indicator_label3   "UpFr"
#property indicator_type3   DRAW_ARROW
#property indicator_color3   clrBlue
#property indicator_style3   STYLE_SOLID
#property indicator_width3   1
//--- plot DnFr
#property indicator_label4   "DnFr"
#property indicator_type4   DRAW_ARROW
#property indicator_color4   clrRed
#property indicator_style4   STYLE_SOLID
#property indicator_width4   1

//--- plot UpBarFr
#property indicator_label5   "UpBarFr"
#property indicator_type5   DRAW_ARROW
#property indicator_color5   clrBlue
#property indicator_style5   STYLE_SOLID
#property indicator_width5   1
//--- plot DnBarFr
#property indicator_label6   "DnBarFr"
#property indicator_type6   DRAW_ARROW
#property indicator_color6   clrRed
#property indicator_style6   STYLE_SOLID
#property indicator_width6   1

//--- input parameters
input ENUM_TIMEFRAMES TimeFrame = PERIOD_CURRENT ;
input string           cSymbol   = "AUDCAD" ;
input int              CountBar  = 5 ; // Баров подряд

//--- indicator buffers
double BufferUPb[];
double BufferDNb[];
double BufferUPf[];
double BufferDNf[];
double BufferUPbf[];
double BufferDNbf[];

//--- global variables
double open1= 0 ,close1= 0 ,open2= 0 ,close2= 0 ;
double frDn= 0 ,frUp= 0 ,frUp1= 0 ,frUp2= 0 ,frUp3= 0 ,frDn1= 0 ,frDn2= 0 ,frDn3= 0 ;
string dSymbol;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit ()
  {
//---
dSymbol=cSymbol== "" ? _Symbol :cSymbol;
//--- indicator buffers mapping
   SetIndexBuffer ( 0 ,BufferUPb);
   SetIndexBuffer ( 1 ,BufferDNb);
   SetIndexBuffer ( 2 ,BufferUPf);
   SetIndexBuffer ( 3 ,BufferDNf);
   SetIndexBuffer ( 4 ,BufferUPbf);
   SetIndexBuffer ( 5 ,BufferDNbf);
//--- setting a code from the Wingdings charset as the property of PLOT_ARROW
   SetIndexArrow ( 0 , 233 );
   SetIndexArrow ( 1 , 234 );
   SetIndexArrow ( 2 , 221 );
   SetIndexArrow ( 3 , 222 );
   SetIndexArrow ( 4 , 108 );
   SetIndexArrow ( 5 , 108 );
//---
   return ( INIT_SUCCEEDED );
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate ( const int rates_total,
                 const int prev_calculated,
                 const datetime &time[],
                 const double &open[],
                 const double &high[],
                 const double &low[],
                 const double &close[],
                 const long &tick_volume[],
                 const long &volume[],
                 const int &spread[])
{
//---
int     b= 1 ,s= 1 ;

if (rates_total< 2 ) return ( 0 );
int limit=rates_total-prev_calculated;
   if (limit> 1 ) {
   limit=rates_total- 2 ;
     ArrayInitialize (BufferUPb, EMPTY_VALUE );
     ArrayInitialize (BufferDNb, EMPTY_VALUE );
     ArrayInitialize (BufferUPf, EMPTY_VALUE );
     ArrayInitialize (BufferDNf, EMPTY_VALUE );
     ArrayInitialize (BufferUPbf, EMPTY_VALUE );
     ArrayInitialize (BufferDNbf, EMPTY_VALUE );
  }
  
for ( int i=limit; i>= 0 ; i--) {

//--------------------------------------------------------------
  open1= iOpen (dSymbol, TimeFrame, i);
  close1= iClose (dSymbol, TimeFrame, i);
  open2= iOpen (dSymbol, TimeFrame, i+ 1 );
  close2= iClose (dSymbol, TimeFrame, i+ 1 );
  
   if (open2<close2 && open1<close1 && open2<open1) {
    b++;
     if (b==CountBar) {
      BufferUPb[i]= Low [i]- 200 * _Point ;
      b= 1 ;
    }
   } else { b= 1 ;}

//---
   if (open2>close2 && open1>close1 && open2>open1) {
    s++;
     if (s==CountBar) {
      BufferDNb[i]= High [i]+ 200 * _Point ;
      s= 1 ;
    }
   } else { s= 1 ;}

//--------------------------------------------------------------
  frDn= iFractals (dSymbol, TimeFrame, MODE_LOWER , i);
   if (frDn!= 0 ) {
    frDn1=frDn;
   }
//-
   if (frDn3 > frDn2 && frDn2 < frDn1) {
    BufferUPf[i]= Low [i]- 200 * _Point ;
  }

   if (frDn2!=frDn3 && frDn2!=frDn1) { frDn3=frDn2;} frDn2=frDn1;
  
//---
  frUp= iFractals (dSymbol, TimeFrame, MODE_UPPER , i);
   if (frUp!= 0 ) {
    frUp1=frUp;
   }
//-
   if (frUp3 < frUp2 && frUp2 > frUp1) {
    BufferDNf[i]= High [i]+ 200 * _Point ;
  }

   if (frUp2!=frUp3 && frUp2!=frUp1) { frUp3=frUp2;} frUp2=frUp1;

//--------------------------------------------------------------

//-
   if ( /*что сюда*/ ) {
    BufferUPbf[i]= Low [i]- 200 * _Point ;
  }
  
//-
   if ( /*что сюда*/ ) {
    BufferDNbf[i]= High [i]+ 200 * _Point ;
  }


//------------
  } // end for
//--- return value of prev_calculated for next call
   return (rates_total);
}
//--------------------------------------------------------------

Soru şu: tüm bunların nasıl birleştirileceği ve 5 ve 6 arabelleklerine nasıl çıkarılacağı.

Teşekkür ederim!

 

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_POS , MODE_TRADES )== true ){
if ( OrderMagicNumber ()==MagicB){
if ( OrderType ()== OP_BUYLIMIT )
count++;}}} return (count);}  

int BuyLimitCount(){
int count= 0 ;
if ( OrderSelect (ticketUP, SELECT_BY_TICKET , MODE_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= 0 ; int ticketUP, ticketD;


void OnTick ()  
{
double maxpr1=- 9999 ; double 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==- 1 ) Print ( "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==- 1 ) Print ( "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=- 9999 ; double 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_TICKET , MODE_TRADES )== true ){
if ( OrderMagicNumber ()==MagicB){
if ( OrderType ()== OP_BUYLIMIT )
count++;}} return (count);}

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

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

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


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


 
spoiltboy :

Selamlar.

Emir seç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_POS , MODE_TRADES )== true ){

if ( OrderMagicNumber ()==MagicB){

if ( OrderType ()== OP_BUYLIMIT )

count++;}}} return (count);}  
Ve nerede?
 
Artyom Trishkin :
Ve nerede?
Katma. Verimlilik için teşekkür ederiz.
 
spoiltboy :
Katma. Verimlilik için teşekkür ederiz.
Ve nerede? Bilette seçim nerede?
 
Artyom Trishkin :
Ve nerede? Bilette seçim nerede?

Evet, yukarıdaki yazıda. Yoksa yanlış bir şey mi var?

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

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

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

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

Evet, yukarıdaki yazıda. Yoksa yanlış bir şey mi var?

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

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

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

int SellCount(){
int count= 0 ;
if ( OrderSelect (ticketD, SELECT_BY_TICKET , MODE_TRADES )== true ){
if ( OrderMagicNumber ()==MagicS){
if ( OrderType ()== OP_SELL )
count++;}} return (count);}
Doğru bileti nasıl seçeceğinizi okumanızı tavsiye ederim. Ne yaptığınızı kendiniz anlamanız arzu edilir. Cep telefonundan başka bir şey söylemek benim için zor.
 
Artyom Trishkin :
Doğru bileti nasıl seçeceğinizi okumanızı tavsiye ederim. Ne yaptığınızı kendiniz anlamanız arzu edilir. Cep telefonundan başka bir şey söylemek benim için zor.

Okudum, hata bulamadım (salonun yardımına ihtiyacım var).

Ve burada bir nokta var - seçim işlevini değiştirdikten sonra, sipariş değiştirme işlevi hata vermeye başladı ve test başladıktan sadece bir süre sonra.

 
spoiltboy :

Okudum, hata bulamadım (salonun yardımına ihtiyacım var).

Ve burada bir nokta var - seçim işlevini değiştirdikten sonra, sipariş değiştirme işlevi hata vermeye başladı ve test başladıktan sadece bir süre sonra.

Bilet siparişlerini nereden alıyorsunuz?
 
Artyom Trishkin :
Bilet siparişlerini nereden alıyorsunuz?
ticketUP= OrderSend ( Symbol (), OP_BUYLIMIT , lotB, minpr1, 3 , slB, tpB, "" , MagicB, 0 , Red);

ticketD= OrderSend ( Symbol (), OP_SELLLIMIT , lotS, maxpr1, 3 , slS, tpS, "" , MagicS, 0 , Blue);