MQL4 및 MQL5에 대한 초보자 질문, 알고리즘 및 코드에 대한 도움말 및 토론 - 페이지 32

 
Vitalie Postolache :

글쎄, 그것은 또 다른 문제입니다. 이제 1%가 무엇에 상대적인지 분명합니다.)

if ( Open [x] > Close [x]+ Open [x]* 0.01 ) {code}
젠장, 당신은이 언어를 이해하지 못할 것입니다 .. 그런 다음 두 단어를 쓰려면 10 줄이 필요하고 10 단어를 쓰면 두 단어로 충분합니다. 프로그래밍을 말하는 것처럼 생각하고 아마도 순서가 있고 혼란이 있습니다. 끝)) 모두가 사랑하는 소원으로 씁니다)))
 
spoiltboy :
EA는 마지막 X 막대의 최소값과 최대값을 계산하고 주문합니다. 또한, 최대값이 감소하거나 최소값이 증가하면 해당 주문을 삭제하고 새 데이터를 사용하여 열어야 합니다.


언제 딜레이를 수정하는지 정확히 이해가 안가는데 최소 가가 기존 BuyLimit 설정 가격보다 높으면 새로운 최소가로 수정해야 하도록 만들었어요

SellLimit의 경우 - 미러.

그리고 그것이 사실인지 아닌지 - 당신이 더 잘 알고 있습니다 - 문제가 있으면 확인하고 수정하십시오 - 방금 코드를 작성했지만 전혀 확인하지 않았습니다 - 수정 사항을 추가하고 알고리즘과 코드의 정확성을 확인하도록 남겨 둡니다. 일반.

//--- input variables
input      double    LotB= 0.1 ;       // Лот Buy
input      double    LotS= 0.1 ;       // Лот Sell
input      int       Pointsl= 100 ;   // StopLoss в пунктах
input      int       Pointtp= 100 ;   // TakeProfit в пунктах
input      int       NumBars= 10 ;     // Количество баров для поиска Max/Min
input      int       Magic= 100500 ;   // Magic

//--- global variables
struct DataPendingOrder
  {
   int       number;     // Количество
   double    price_set;   // Цена установки
  };

struct DataPending
  {
   DataPendingOrder  buy_limit;   // BuyLimit
   DataPendingOrder  buy_stop;   // BuyStop
   DataPendingOrder  sell_limit; // SellLimit
   DataPendingOrder  sell_stop;   // SellStop
  };

struct DataOrders
  {
   int          buy;     // Количество позиций Buy
   int          sell;     // Количество позиций Sell
   DataPending order;   // Данные отложенного ордера
  };
DataOrders getData;   // Данные ордеров и позиций
double lotB, lotS;
int     pointsl, pointtp, numBars;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit ()
  {
   numBars=(NumBars< 1 ? 1 :NumBars> Bars ? Bars :NumBars);
   pointsl=(Pointsl< 0 ? 0 :Pointsl);
   pointtp=(Pointtp< 0 ? 0 :Pointtp);
   double minLot= SymbolInfoDouble ( Symbol (), SYMBOL_VOLUME_MIN );
   double maxLot= SymbolInfoDouble ( Symbol (), SYMBOL_VOLUME_MAX );
   lotB=(LotB<minLot?minLot:LotB>maxLot?maxLot:LotB);
   lotS=(LotS<minLot?minLot:LotS>maxLot?maxLot:LotS);
//---
   return ( INIT_SUCCEEDED );
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick ()
  {
   //--- заполним структуру количеством ордеров и позиций
   GetNumOrders( Symbol (),Magic,getData);
  
   //--- найдём максимальную и минимальную цены за bars свечей
   double maxPrice= 0.0 , minPrice= DBL_MAX ;
   for ( int i= 0 ; i<numBars; i++) {
       double max_i= iHigh ( Symbol (), PERIOD_CURRENT ,i);
       if (max_i>maxPrice) maxPrice=max_i;
       double min_i= iLow ( Symbol (), PERIOD_CURRENT ,i);
       if (min_i<minPrice) minPrice=min_i;
      }

   //--- если нету рыночных Buy
   if (getData.buy== 0 ) {
       //--- если нет отложенного BuyLimit
       if (getData.order.buy_limit.number== 0 ) {
         double slB=(pointsl== 0 ? 0 : NormalizeDouble (minPrice-pointsl* Point (), Digits ()));
         double tpB=(pointtp== 0 ? 0 : NormalizeDouble (minPrice+pointtp* Point (), Digits ()));
         ResetLastError ();
         int ticketUP= OrderSend ( Symbol (), OP_BUYLIMIT , lotB, minPrice, 3 , slB, tpB, "" , Magic, 0 , clrRed );
         if (ticketUP==- 1 ) Print ( "ERROR SETTING OP_BUYLIMIT :" , GetLastError ());
         else Print ( "OP_BUYLIMIT OK" );
         }
       //--- если есть BuyLimit
       else {
         //--- если цена Min больше цены установки BuyLimit
         if (minPrice>getData.order.buy_limit.price_set) {
             // модифицировать BuyLimit - поставить его на цену minPrice ...
             //--- ... и сместить его стоп-уровни относительно новой цены установки
            }
         }
      }
  
   //--- если нету рыночных Sell
   if (getData.sell== 0 ) {
       //--- если нет отложенного SellLimit
       if (getData.order.sell_limit.number== 0 ) {
         double slS=(pointsl== 0 ? 0 : NormalizeDouble (maxPrice+pointsl* Point (), Digits ()));
         double tpS=(pointtp== 0 ? 0 : NormalizeDouble (maxPrice-pointtp* Point (), Digits ()));
         ResetLastError ();
         int ticketD= OrderSend ( Symbol (), OP_SELLLIMIT , lotS, maxPrice, 3 , slS, tpS, "" , Magic, 0 , clrBlue );
         if (ticketD==- 1 ) Print ( "ERROR SETTING OP_SELLLIMIT :" , GetLastError ());
         else Print ( "OP_SELLLIMIT OK" );
         }
       //--- если есть SellLimit
       else {
         //--- если цена Max меньше цены установки SellLimit
         if (maxPrice<getData.order.sell_limit.price_set) {
             // модифицировать SellLimit - поставить его на цену maxPrice ...
             //--- ... и сместить его стоп-уровни относительно новой цены установки
            }
         }
      }

   //---
   string a=(numBars== 1 )? "bar: " : IntegerToString (numBars, 1 )+ " bar's: " ;
   Comment ( "Last " , a, "max " , DoubleToStr (maxPrice, Digits ()), ", min " , DoubleToStr (minPrice, Digits ()), "." );
  }
//+------------------------------------------------------------------+
//| Записывает в структуру количество позиций и отложенных ордеров   |
//+------------------------------------------------------------------+
void GetNumOrders( string symbol_name, int magic_number, DataOrders &data_of) {
   ZeroMemory (data_of);
   for ( int i= OrdersTotal ()- 1 ; i>= 0 ; i--) {
       if ( OrderSelect (i, SELECT_BY_POS )) {
         if ( OrderMagicNumber ()!=magic_number) continue ;
         if ( OrderSymbol ()!=symbol_name)       continue ;
         //--- рыночные позиции
         if ( OrderType ()== OP_BUY )    data_of.buy++;
         if ( OrderType ()== OP_SELL )   data_of.sell++;
         //--- отложенные ордера
         if ( OrderType ()== OP_BUYLIMIT )  {  data_of.order.buy_limit.number++;   data_of.order.buy_limit.price_set= OrderOpenPrice ();   }
         if ( OrderType ()== OP_BUYSTOP )   {  data_of.order.buy_stop.number++;    data_of.order.buy_stop.price_set= OrderOpenPrice ();    }
         if ( OrderType ()== OP_SELLLIMIT ) {  data_of.order.sell_limit.number++;  data_of.order.sell_limit.price_set= OrderOpenPrice ();  }
         if ( OrderType ()== OP_SELLSTOP )  {  data_of.order.sell_stop.number++;   data_of.order.sell_stop.price_set= OrderOpenPrice ();   }
         }
      }
}
//+------------------------------------------------------------------+

나는 당신이 그것을 이해하기를 바랍니다

 
Artyom Trishkin :

설정 가격을 수정할 수 있을 때 삭제하고 새 수준에 대한 상대적인 테이크를 중단하는 이유는 무엇입니까?

방금 공부를 시작했는데 삭제 옵션은 해당 기능의 적용을 공부하기 위한 것이었는데 왜 작동하지 않는지 의문이 생겼습니다.

응답해 주셔서 감사합니다.

 

extern 매개변수를 재설정하는 명령이 어떻게 생겼는지 알려줄 수 있는 사람

어떻게 보여야

1) 실행될 명령에 대한 목록에서 일련의 필수 조건이 선택됩니다. 예를 들어 주문을 여는 경우

2) 주문이 열렸고 이 명령은 어떤 상황에서도 더 이상 작동하지 않습니다. 티켓 및 주문 수로 필터링하는 것은 옵션이 아닙니다. 원칙 자체가 목록 전체에 분산되어야 하기 때문입니다.

 
(MA1>GrossMA1 && MA2<GrossMA2 && Bid>MA1+Distance*Point() ) GrossMA1[0]인 경우 여기서 오류는 무엇입니까? MA1[0] GrossMA2[1] MA2[1] 이동 교차점 + 이동 교차점 후 거리별 필터 가 사용됩니다 . 이 조건이 어느 정도 맞습니까?
 
Movlat Baghiyev :
(MA1>GrossMA1 && MA2<GrossMA2 && Bid>MA1+Distance*Point() ) GrossMA1[0]인 경우 여기서 오류는 무엇입니까? MA1[0] GrossMA2[1] MA2[1] 이동 교차점 + 이동 교차점 후 거리별 필터가 사용됩니다. 이 조건이 어느 정도 맞습니까?

GrossMA1과 GrossMA2가 반환하는 것에는 차이가 있을 가능성이 높으며 결국 다음과 같은 결과를 얻습니다.

MA1 = 1.0050

if (MA1 > 0.0052) // 즉, 가격 자체가 아니라 그 차이이므로 비교가 잘못됨

 
Vitaly Muzichenko :

GrossMA1과 GrossMA2가 반환하는 것에는 차이가 있을 가능성이 높으며 결국 다음과 같은 결과를 얻습니다.

MA1 = 1.0050

if (MA1 > 0.0052) // 즉, 가격 자체가 아니라 그 차이이므로 비교가 잘못됨

어떻게 하면 좋을지 말해줘?
 
Vitaly Muzichenko :

GrossMA1과 GrossMA2가 반환하는 것에는 차이가 있을 가능성이 높으며 결국 다음과 같은 결과를 얻습니다.

MA1 = 1.0050

if (MA1 > 0.0052) // 즉, 가격 자체가 아니라 그 차이이므로 비교가 잘못됨

FRMA1= iMA ( Symbol (), 0 , Faster_MA_Period, Faster_MA_Shift, Faster_MA_method, Faster_MA_Apply_to, 0 );
    FRMA2= iMA ( Symbol (), 0 , Faster_MA_Period, Faster_MA_Shift, Faster_MA_method, Faster_MA_Apply_to, 1 );

    FMA1= iMA ( Symbol (), 0 , Fast_MA_Period, Fast_MA_Shift, Fast_MA_method, Fast_MA_Apply_to, 0 );
    FMA2= iMA ( Symbol (), 0 , Fast_MA_Period, Fast_MA_Shift, Fast_MA_method, Fast_MA_Apply_to, 1 );

    GrossMA1= iMA ( Symbol (), 0 , Gross_MA_Period, Gross_MA_Shift, Gross_MA_method, Gross_MA_Apply_to, 0 );
    GrossMA2= iMA ( Symbol (), 0 , Gross_MA_Period, Gross_MA_Shift, Gross_MA_method, Gross_MA_Apply_to, 1 );
 
Vitaly Muzichenko :

GrossMA1과 GrossMA2가 반환하는 것에는 차이가 있을 가능성이 높으며 결국 다음과 같은 결과를 얻습니다.

MA1 = 1.0050

if (MA1 > 0.0052) // 즉, 가격 자체가 아니라 그 차이이므로 비교가 잘못됨

교차가 올바르게 발생합니다. 질문은 이 조건에 대한 것입니다. Bid>MA1+Distance*Point()
 

친절한. 오류가 어디에 있습니까?

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;}}



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" );
  } 

모든 것이 작동하며 maxpr1 가격으로 주문합니다.

다음으로 나는 같은 일을 하고 싶지만 minpr1의 가격으로:

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;}}



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

오류 130 을 씁니다(잘못된 중지). 내가 무엇을 잘못하고 있지?