ONLY CANDLE / BAR - 양초를 분류하거나 분리하는 방법은 무엇입니까? - 수정해주세요! - 페이지 4

 

나는 우리가 코드에 대한 통제력을 약간 잃은 것 같은 느낌이 든다....

         if ( SignalBULL62Executed) CheckForClose_BULL6();       // I don't know it is the right place to close

아니요, 이것은 확실히 올바른 장소가 아닙니다.

   int     result;
   if (Bid==Close[ 1 ]+ 3 * Point )  
     {
      result= OrderSend ( Symbol (),OP_BUY, 0.61 ,Ask, 0 ,Close[ 1 ]- 25 * Point , 0 , "" ,MAGICMA2, 0 ,Red);
       return ;
     }
   if (result == - 1 )
      {
       int e = GetLastError ();
       Print (e);
      }   
  } 

이 '오류 처리'는 아무 것도 개선하지 않습니다. 다시 확인하십시오.

 bool Fun_New_Bar()                               // bool             

   {                                
   static datetime New_Time= 0 ;      
   New_Bar= false ;                   
   if (New_Time!=Time[ 0 ])           
      {
      New_Time=Time[ 0 ];                
      New_Bar= true ;                    
      }
   }

이것은 재미를 위해 만들어지지 않았습니다! 새 막대에서 실행된 플래그를 재설정하는 데 사용해야 합니다.

 if (Bid==Close[ 1 ]+ 3 * Point )  

복식 비교 에 대해 무엇을 배웠고 이것이 여기에서 의미가 있는지 여부는 무엇입니까?

 

그래서 당신은 내가 참조하는 당신의 게시물을 삭제하기로 결정했습니다... 잘했습니다, 그것은 매우 도움이 됩니다!

[삭제]  

죄송하지만 어제는 인터넷 문제였습니다(mql4.com 작동 중지). 나는 무언가를 수정하려고 했고 ... 붕괴

 //+------------------------------------------------------------------+
//+------------------------------------------------------------------+
#define MAGICMA1   2000          // blue starategy
#define MAGICMA2   2001          // red strategy

//+------------------------------------------------------------------+
//| Check NEW BAR                                |
//+------------------------------------------------------------------+
bool New_Bar = false ;

bool Fun_New_Bar()                               // bool             

   {                                
   static datetime New_Time= 0 ;      
   New_Bar= false ;                   
   if (New_Time!=Time[ 0 ])           
      {
      New_Time=Time[ 0 ];                
      New_Bar= true ;                    
      }
   }

//+------------------------------------------------------------------+
//| Calculate open positions    HOW MEANY OF THIS is open   |
//+------------------------------------------------------------------+

//--- FOR BLUE---------------------------------------------------------
int OpenOrders_BULL4( string symbol)
  {
   int buys= 0 ;

   for ( int i= 0 ;i< OrdersTotal ();i++)
     {
       if ( OrderSelect (i,SELECT_BY_POS,MODE_TRADES)== false ) break ; 
       if (OrderSymbol()== Symbol () && OrderMagicNumber()==MAGICMA1)     // magic ma 1 ( is ==)
        {
         if (OrderType()==OP_BUY) buys++;
        }
     }
   return (buys);
  }
  
//--- FOR RED--------------------------------------------------------------
int OpenOrders_BULL6( string symbol)
  {
   int buys= 0 ;

   for ( int i= 0 ;i< OrdersTotal ();i++)
     {
       if ( OrderSelect (i,SELECT_BY_POS,MODE_TRADES)== false ) break ; 
       if (OrderSymbol()== Symbol () && OrderMagicNumber()==MAGICMA2)     // magic ma 2 ( is ==)
        {
         if (OrderType()==OP_BUY) buys++;
        }
     }
   return (buys);
  }



//+------------------------------------------------------------------+
//| Condition candle                                                 |
//+------------------------------------------------------------------+
bool BULL4()
   {
   if (Close[ 1 ]-Open[ 1 ]>= 4 * Point && Close[ 1 ]-Open[ 1 ]<= 5 * Point )
   return ( true );
   } 

bool BULL6()
   {
   if (Close[ 1 ]-Open[ 1 ]>= 6 * Point && Close[ 1 ]-Open[ 1 ]<= 7 * Point )
   return ( true );
   }
      
//+------------------------------------------------------------------+
//| Check for open order conditions                                  |
//+------------------------------------------------------------------+
//--------------------------- blue bull4 magicma1 
void OpenBULL41()
  {
   int     result;
   if (Bid==Close[ 1 ]+ 3 * Point )  
     {
      result= OrderSend ( Symbol (),OP_BUY, 0.41 ,Ask, 0 ,Close[ 1 ]- 25 * Point , 0 , "" ,MAGICMA1, 0 ,Blue);
       return ( true );
     }
     if (result == - 1 )
      {
       int e = GetLastError ();
       Print (e);
      }      
  }
  
void OpenBULL42()
  {
   int     result;
   
   for ( int i= 1 ;i<= OrdersTotal ();i++)
   {
       if ( OrderSelect (i,SELECT_BY_POS,MODE_TRADES)== false ) break ; 
       if (OrderSymbol()== Symbol () && OrderMagicNumber()==MAGICMA1)     // magic ma 1 ( is ==)
        {
         if (Ask>OrderOpenPrice()+ 2 * Point )  
            {
             result= OrderSend ( Symbol (),OP_BUY, 0.42 ,Ask, 0 ,Close[ 1 ]- 25 * Point , 0 , "" ,MAGICMA1, 0 ,Blue);
             return ;
            }
           if (result == - 1 )
             {
             int e = GetLastError ();
             Print (e);
             }    
        }
     }
  }  
//--------------------------- red bull6 magicma2 
void OpenBULL61()
  {
   int     result;
   if (Bid==Close[ 1 ]+ 3 * Point )  
     {
      result= OrderSend ( Symbol (),OP_BUY, 0.61 ,Ask, 0 ,Close[ 1 ]- 25 * Point , 0 , "" ,MAGICMA2, 0 ,Red);
       return ;
     }
   if (result == - 1 )
      {
       int e = GetLastError ();
       Print (e);
      }   
  }
  
void OpenBULL62()
  {
   int     result;
   if (Ask>OrderOpenPrice()+ 2 * Point )  
     {
      result= OrderSend ( Symbol (),OP_BUY, 0.62 ,Ask, 0 ,Close[ 1 ]- 25 * Point , 0 , "" ,MAGICMA2, 0 ,Red);
       return ;
     }
     if (result == - 1 )
      {
       int e = GetLastError ();
       Print (e);
      }     
  }

void OpenBULL63()
  {
   int     result;
   if (Ask>OrderOpenPrice()+ 2 * Point )  
     {
      result= OrderSend ( Symbol (),OP_BUY, 0.63 ,Ask, 0 ,Close[ 1 ]- 25 * Point , 0 , "" ,MAGICMA2, 0 ,Red);
       return ;
     }
     if (result == - 1 )
      {
       int e = GetLastError ();
       Print (e);
      }    
  }
//+------------------------------------------------------------------+
//| Check for close order conditions                                 |
//+------------------------------------------------------------------+

void CheckForClose_BULL4()
{

   if (OrderOpenPrice()+ 4 * Point < Ask)
   for ( int i = OrdersTotal ()- 1 ; i >= 0 ;i--)           // add: -1
   {
       OrderSelect (i,SELECT_BY_POS,MODE_TRADES);
       if (OrderSymbol() == Symbol ()&& OrderMagicNumber()==MAGICMA1) 
      {
         bool ticket = true ;
         if (OrderType() == OP_BUY) ticket = OrderClose(OrderTicket(),OrderLots(),Bid, 1 ,Blue);

      }
   }
} 

void CheckForClose_BULL6()
{

   if (OrderOpenPrice()+ 8 * Point < Ask)
   for ( int i = OrdersTotal ()- 1 ; i >= 0 ;i--)
   {
       OrderSelect (i,SELECT_BY_POS,MODE_TRADES);
       if (OrderSymbol() == Symbol ()&& OrderMagicNumber()==MAGICMA2) 
      {
         bool ticket = true ;
         if (OrderType() == OP_BUY) ticket = OrderClose(OrderTicket(),OrderLots(),Bid, 1 ,Red);

      }
   }
}  
  
//+------------------------------------------------------------------+
//| flag                               |
//+------------------------------------------------------------------+ 
Fun_New_Bar();
if (New_Bar== false );
bool SignalBULL41Executed= false ;
bool SignalBULL42Executed= false ;
bool SignalBULL61Executed= false ;
bool SignalBULL62Executed= false ;
bool SignalBULL63Executed= false ;

if (Fun_New_Bar())
{
   SignalBULL41Executed= true ;
   return (SignalBULL41Executed);
}


  
  
//+------------------------------------------------------------------+
//| Start function                                 |
//+------------------------------------------------------------------+
void start()
  {
// ----------------bull4
if (BULL4())             
   if (!SignalBULL41Executed && OpenOrders_BULL4( Symbol ())== 0 )
  {
    OpenBULL41(); //do open buy position
    SignalBULL41Executed= true ;
     if ( SignalBULL41Executed) CheckForClose_BULL4();       // I don't know it is the right place to close
  }
  
  
   if (!SignalBULL42Executed && OpenOrders_BULL4( Symbol ())== 1 )
  {
    OpenBULL42(); //do open buy position
    SignalBULL42Executed= true ;
         if ( SignalBULL42Executed) CheckForClose_BULL4();       // I don't know it is the right place to close
  }
  
// ----------------bull6  
if (BULL6())             
   if (!SignalBULL61Executed && OpenOrders_BULL6( Symbol ())== 0 )
  {
    OpenBULL61(); //do open buy position
    SignalBULL61Executed= true ;
         if ( SignalBULL61Executed) CheckForClose_BULL6();       // I don't know it is the right place to close
  }
  
  
   if (!SignalBULL62Executed && OpenOrders_BULL6( Symbol ())== 1 )
  {
    OpenBULL62(); //do open buy position
    SignalBULL62Executed= true ;
         if ( SignalBULL62Executed) CheckForClose_BULL6();       // I don't know it is the right place to close
  }
  
  
   if (!SignalBULL63Executed && OpenOrders_BULL6( Symbol ())== 2 )
  {
    OpenBULL63(); //do open buy position
    SignalBULL42Executed= true ;
         if ( SignalBULL62Executed) CheckForClose_BULL6();       // I don't know it is the right place to close
  }   

  }
//+------------------------------------------------------------------+
 

당신을 돕는 것은 쉽지 않습니다. 지금은 적절한 Open(), Close(), Count(), NewBar(), Signal() 함수 를 사용하여 한 가지 전략만 구현하려고 하지 않는 이유는 무엇입니까?

아래 블록은 시작 기능 외부에 있습니다. 이것이 원하는 것인지 확실하지 않습니다.

Fun_New_Bar();
if (New_Bar== false );               // <-- ???
bool SignalBULL41Executed= false ;   // <-- This could be correct, but I am not sure you know why and
bool SignalBULL42Executed= false ;   //     its not more an accident that you initalize it here.
bool SignalBULL61Executed= false ;
bool SignalBULL62Executed= false ;
bool SignalBULL63Executed= false ;

if (Fun_New_Bar())                   // <-- Your Fun_New_Bar() function doesn't return anything,
{                                   //     you set the global New_Bar variable with the function. 
   SignalBULL41Executed= true ;       // <-- You should set it to false on a new bar.    
   return (SignalBULL41Executed);   // <-- ???
}
[삭제]  

당신 과 같은 생각 , 작은 걸음 . BULL4 하나만 선택 하자
때때로 내 코드베이스에 E 처럼 보입니다 .

https://www.mql5.com/en/code/9156 - 흥미로운

나는 이것을 이해하지만 (느낌은 아님) 나는 깃발이고 그 목적 을 이해 합니다

어떻게 생각하세요? 작은 걸음 에 대해

 //+------------------------------------------------------------------+
//+------------------------------------------------------------------+
#define MAGICMA1   2000          // blue starategy


//+------------------------------------------------------------------+
//| Check NEW BAR                                |
//+------------------------------------------------------------------+


//+------------------------------------------------------------------+
//| Calculate open positions    HOW MEANY OF THIS is open   |
//+------------------------------------------------------------------+

int OpenOrders_BULL4( string symbol)
  {
   int buys= 0 ;

   for ( int i= 0 ;i< OrdersTotal ();i++)
     {
       if ( OrderSelect (i,SELECT_BY_POS,MODE_TRADES)== false ) break ; 
       if (OrderSymbol()== Symbol () && OrderMagicNumber()==MAGICMA1)   
        {
         if (OrderType()==OP_BUY) buys++;
        }
     }
   return (buys);
  }
  
//+------------------------------------------------------------------+
//| Condition candle                                                 |
//+------------------------------------------------------------------+
bool BULL4()
   {
   if (Close[ 1 ]-Open[ 1 ]>= 4 * Point && Close[ 1 ]-Open[ 1 ]<= 5 * Point )
      {
         return ( true );
      } 
   else
      {
         return ( false );
      } 
   }
//+------------------------------------------------------------------+
//| Condition send buy                                                 |
//+------------------------------------------------------------------+
 
bool BULL4send()
   {
   if ( Bid==Close[ 1 ]+ 3 * Point )
      {
         return ( true );
      } 
     else
      {
         return ( false );
      }
   }
 
//+------------------------------------------------------------------+
//| Check for open order conditions                                  |
//+------------------------------------------------------------------+

bool OpenBULL41()
  {
       int     result;

      result= OrderSend ( Symbol (),OP_BUY, 0.41 ,Ask, 0 ,Close[ 1 ]- 25 * Point , 0 , "" ,MAGICMA1, 0 ,Blue);
       if (result> 0 )
           {
             if ( OrderSelect (result,SELECT_BY_TICKET,MODE_TRADES)) Print ( "BUY order opened : " ,OrderOpenPrice());
           }
       else
         {
             Print ( "Error opening BUY order : " , GetLastError ()); 
             return ( false );
         }
       return ( true );       
   }
   
//+------------------------------------------------------------------+
//| Check for close order conditions                                 |
//+------------------------------------------------------------------+

  
//+------------------------------------------------------------------+
//| Start function                                 |
//+------------------------------------------------------------------+
void start()
  {
// ----------------bull4
   if (BULL4() && BULL4send() && OpenOrders_BULL4( Symbol ())== 0 )             

     {
       OpenBULL41(); //do open buy position
     }
  }
//+------------------------------------------------------------------+
 

예, 작은 단계로 오류를 관리할 수 있습니다...
코드베이스 EA에서 특정한 것을 강조하고 싶습니까?

나는 이것을 다시 보지 않을 것입니다 - 당신이 수정 단계를 더 이상 무시한다면 나는 더 이상 당신을 돕지 않을 것입니다. 나 또는 다른 사람은 다음과 같이 조언했습니다.

 if ( Bid==Close[ 1 ]+ 3 * Point )

미끄러짐이 0인가요? 아마 오류가 날 것입니다. 그러나 수정된 오류 처리는 그것을 잡을 것입니다 :-)

result= OrderSend ( Symbol (),OP_BUY, 0.41 ,Ask, 0 ,Close[ 1 ]- 25 * Point , 0 , "" ,MAGICMA1, 0 ,Blue);

이것은 잘못된 것은 아니지만 이상적이지는 않으며 최악의 경우 루프 내에서 원하는 대로 되지 않습니다. 0에서 OrdersTotal까지 루프를 사용하지 않는 것이 좋습니다. 읽어보기: 루프 및 주문 마감 또는 삭제

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

중개인의 스프레드는 얼마이며 거래하려는 기호에 대해 몇 자릿수를 가지고 있습니까? Point를 올바르게 사용하고 있는지 확신할 수 없습니다(스레드의 첫 페이지에서 읽으십시오).

[삭제]  
kronin :

예, 작은 단계이므로 오류를 관리할 수 있습니다...
코드베이스 EA에서 특정한 것을 강조하고 싶습니까?

아니오, 조명할 것이 없다고 생각합니다. 제가 쓴 내용을 이해합니다.

나는 이것을 다시 보지 않을 것입니다 - 당신이 수정 단계를 더 이상 무시하면 나는 더 이상 당신을 돕지 않을 것입니다. 나 또는 다른 사람은 다음과 같이 조언했습니다.

네. 나는 NormalizeDouble이 무엇을 하는지 알고 있습니다(내가 가지고 있는 경우: euro/usd = 1.2390022129.....09.... 그리고 우리는 필요합니다: 1,29893 end! not infinity ) 그러나 나는 이것을 쓸 수 없습니다. 이것들이 될까요?

if ( NormalizeDouble ( abc(),0 ) )

부울 ABC()

{

부울 z,y,z;

x=입찰가;

y=닫기[1]

z=x-y+3*점

리턴(z);

}

또는 ?

If ( NormalizeDouble ((Close[1]-Bid) +3*point),0 ) ;

미끄러짐이 0인가요? 아마 오류가 날 것입니다. 그러나 수정된 오류 처리는 그것을 잡을 것입니다 :-)

+1 문제가 없습니다. result= OrderSend ( Symbol (),OP_BUY, 0.41 ,Ask, 1 ,Close[ 1 ]- 25 * Point , 0 , "" ,MAGICMA1, 0 ,Blue);

오류 처리, 양호, 이후에 무엇을 볼 수 있습니다.

이것은 잘못된 것은 아니지만 이상적이지는 않으며 최악의 경우 루프 내에서 원하는 대로 되지 않습니다. 0에서 OrdersTotal까지 루프를 사용하지 않는 것이 좋습니다. 읽어보기: 루프 및 주문 마감 또는 삭제

아주 좋은 기사! 나는 이것을 처음에 읽어야합니다 :)

중개인의 스프레드는 얼마이며 거래하려는 기호에 대해 몇 자릿수를 가지고 있습니까? Point를 올바르게 사용하고 있는지 확신할 수 없습니다(스레드의 첫 페이지에서 읽으십시오).

나는 이것들을 기억한다. Admiral Market Bid=1,29000 Ask = 1,29001입니다. 이것은 내가 아는 문제이지만 현재로서는 좋은 예를 찾지 못해 해결 방법이 없습니다.

코드를 작성하고 있습니다...

 
Wodzuuu :

네. 나는 NormalizeDouble이 무엇을 하는지 알고 있습니다(내가 가지고 있는 경우: euro/usd = 1.2390022129.....09.... 그리고 우리는 필요합니다: 1,29893 end! not infinity ) 그러나 나는 이것을 쓸 수 없습니다. 이것들이 될까요?


if ( NormalizeDouble ( abc(),0 ) )

부울 ABC()

{


bool을 NormalizeDouble() 할 수 없습니다. 단서는 함수 이름과 설명서에도 있습니다. . .

더블 NormalizeDouble ( 이중 , 정수 숫자 )

 
RaptorUK :

bool을 NormalizeDouble() 할 수 없습니다. 단서는 함수 이름과 설명서에도 있습니다. . .

true를 매우 사실로 정규화할 수 없다는 것은 유감입니다 :-(

우드주 :
네. 나는 NormalizeDouble이 무엇을 하는지 알고 있습니다(내가 가지고 있는 경우: euro/usd = 1.2390022129.....09.... 그리고 우리는 다음이 필요합니다: 1,29893 end! not infinity ) 그러나 나는 이것을 쓸 수 없습니다. 이것들이 될까요?

아니요, Bid 또는 Close[1]를 정규화할 필요가 없습니다. 내 말은 당신이 평등을 위해 그것을 비교해서는 안된다는 것입니다.

상상하다:
닫기[1] = 1.31933
신규_바
Tick1, 입찰가 = 1.31935
Tick2, 입찰가 = 1.31934
Tick3, 입찰가 = 1.31937
Tick4, 입찰가 = 1.31937
Tick5, 입찰가 = 1.31942


귀하의 코드는 입찰가가 1.31936인 Tick을 찾습니다.

 if ( Bid==Close[ 1 ]+ 3 * Point )

신호를 놓치게 됩니다. > 를 사용하면 이런 일이 발생하지 않습니다.

우드주 :
+1 문제가 없습니다. result= OrderSend ( Symbol (),OP_BUY, 0.41 ,Ask, 1 ,Close[ 1 ]- 25 * Point , 0 , "" ,MAGICMA1, 0 ,Blue);

이것은 훨씬 나아지지 않습니다. 포인트의 모든 계산은 내 이해에서 핍이어야 합니다. 그러나 ECN 브로커에 대한 경험이 없으므로 작동할 수 있습니다.

우드주 :

이것은 잘못된 것은 아니지만 이상적이지는 않으며 최악의 경우 루프 내에서 원하는 대로 되지 않습니다. 0에서 OrdersTotal까지 루프를 사용하지 않는 것이 좋습니다. 읽어보기: 루프 및 주문 마감 또는 삭제

아주 좋은 기사! 나는 이것을 처음에 읽어야합니다 :)

동의하고 같은 저자가 쓴 아주 좋은 기사가 더 많이 있습니다. 또한 은 시작하기에 나쁘지 않습니다.

우드주 :

Admiral Market Bid=1,29000 Ask = 1,29001입니다. 이것은 내가 아는 문제이지만 현재로서는 좋은 예를 찾지 못해 해결 방법이 없습니다.

중개인 웹사이트에는 EURUSD의 경우 최소 스프레드가 0,1이라고 명시되어 있습니다. 평균 스프레드는 0.5입니다. <-- 이것은 핍으로 의미합니다! 따라서 0,1은 1 포인트입니다. 0,5는 5점입니다.
따라서 귀하의 경우 1핍은 10*포인트입니다. 스프레드는 가격에 3포인트만 추가하는 모든 미니 계산을 혼란스럽게 합니다.
'5자리 브로커 조정'을 검색하면 많은 예를 찾을 수 있습니다.

[삭제]  

안녕하세요 :)

내가 신호 를 전달 했기 때문에 코드 잘못 되었다면 개선된 것입니다. 나는 문제 가 평등 의 부호가 아닌 완전히 다른 장소에 있다고 생각했습니다. '=='....... '>=' 물론 더 나은 생각

 if ( Bid==Close[ 1 ]+ 3 * Point )
 if ( Bid>=Close[ 1 ]+MyPips* 3 )

질문 1. 이 기능에서 촛불에 MyPips를 사용할 수 있습니까? 부울 BULL4()

숫자 문제.

나는 이것들을 발견했다

https://www.mql5.com/en/forum/140097 작성자 WHRoeder

https://www.mql5.com/en/forum/123736 by WHRoeder

숫자 란 무엇입니까? https://docs.mql4.com/predefined/variables/digitshttps://docs.mql4.com/convert/doubletostr

B 당신이 전문가 이기 때문에 내가 한 마디 말 했어야 했는데 , 그것이 중요할 수도 있습니다.
이제 MT4 플랫폼 사용 하고 소수점 이하 4자리 를 봅니다 (Bid - Ask = 0.0001 보통) . 현재 우리 는 MQL4로 프로그래밍 했습니다 .
MT5에서 소수점 뒤에 5자리표시 됩니다. MQL4MQL5 사이 에는 d가지가 있습니다. 현재 속도는 나에게 중요 하지 않습니다 . EA중요한 것은 작동 했습니다.
지금은 그것에 대해 이야기 하고 싶지 않습니다 ( 필요 하지 않은 경우).

그리고 나는 나를 위해 좋은 프로그램을 썼습니다 :) 당신은 어떻습니까?

 //+------------------------------------------------------------------+
//+------------------------------------------------------------------+
#define MAGICMA1   2000          // blue starategy

//+------------------------------------------------------------------+
//| Check NEW BAR                                |
//+------------------------------------------------------------------+

// nothing yet, one moment

//+------------------------------------------------------------------+
//| These are adjusted for 5/4 digit brokers                           |
//+------------------------------------------------------------------+

double   MyPips;         // slippage and others

int init()
  {
     if ( Digits == 5 )     // Adjust for five (5) 
    {                
         MyPips= Point * 10 ; 
    } 
     else                  // Adjust for four (4, and ..)
    {
         MyPips= Point * 1 ;  
    }
  }
 
//+------------------------------------------------------------------+
//| Calculate open positions    HOW MEANY OF THIS is open   |
//+------------------------------------------------------------------+

int OpenOrders_BULL4( string symbol)
  {
   int buys= 0 ;

   for ( int i= 0 ;i< OrdersTotal ();i++)
     {
       if ( OrderSelect (i,SELECT_BY_POS,MODE_TRADES)== false ) break ; 
       if (OrderSymbol()== Symbol () && OrderMagicNumber()==MAGICMA1)   
        {
         if (OrderType()==OP_BUY) buys++;
        }
     }
   return (buys);
  }
  
//+------------------------------------------------------------------+
//| Condition candle                                                 |
//+------------------------------------------------------------------+
bool BULL4()
   {
   if (Close[ 1 ]-Open[ 1 ]>= 4 * Point && Close[ 1 ]-Open[ 1 ]<= 5 * Point )
      {
         return ( true );
      } 
   else
      {
         return ( false );
      } 
   }

//+------------------------------------------------------------------+
//| Condition send buy                                                 |
//+------------------------------------------------------------------+
 
bool BULL4send()
   {
   if ( Bid>=Close[ 1 ]+MyPips* 3 )
      {
         return ( true );
      } 
     else
      {
         return ( false );
      }
   }
 
//+------------------------------------------------------------------+
//| Check for open order conditions                                  |
//+------------------------------------------------------------------+

bool OpenBULL41()
  {
       int     result;

      result= OrderSend ( Symbol (),OP_BUY, 0.41 ,Ask,MyPips,Close[ 1 ]- 25 *MyPips, 0 , "" ,MAGICMA1, 0 ,Blue);
       if (result> 0 )
           {
             if ( OrderSelect (result,SELECT_BY_TICKET,MODE_TRADES)) Print ( "BUY order opened : " ,OrderOpenPrice());
           }
       else
         {
             Print ( "Error opening BUY order : " , GetLastError ()); 
             return ( false );
         }
       return ( true );       
   }
   
//+------------------------------------------------------------------+
//| Check for close order conditions                                 |
//+------------------------------------------------------------------+

bool CheckForCloseBULL4()
{
   int i;
   for (i= OrdersTotal ()- 1 ;i>= 0 ;i--)
       if ( ! OrderSelect (i, SELECT_BY_POS, MODE_TRADES) ) continue ;
         if ( OrderMagicNumber() == MAGICMA1 && OrderSymbol() == Symbol ()  && OrderType() == OP_BUY )
             if (OrderOpenPrice()+ 8 *MyPips < Ask) return ( true );
            
   else return ( false );
}

//+------------------------------------------------------------------+
//|  close                               |
//+------------------------------------------------------------------+

void CloseBULL4()
{
   int i;   
   for (i= OrdersTotal ()- 1 ;i>= 0 ;i--)
      {
       if ( ! OrderSelect (i, SELECT_BY_POS, MODE_TRADES) ) continue ;  
   
       if ( OrderMagicNumber() == MAGICMA1 && OrderSymbol() == Symbol ()  && OrderType() == OP_BUY )  
   
         if ( ! OrderClose( OrderTicket(), OrderLots(), OrderClosePrice(), MyPips* 1 ,Black ) )               
             Print ( "Order Close failed, order number: " , OrderTicket(), " Error: " , GetLastError () );  
      } 
}

//+------------------------------------------------------------------+
//| Start function                                 |
//+------------------------------------------------------------------+
void start()
  {
// ----------------bull4
   if (BULL4() && BULL4send() && OpenOrders_BULL4( Symbol ())== 0 )             

     {
       OpenBULL41(); //do open buy position
     }
     
   if (CheckForCloseBULL4()== true && OpenOrders_BULL4( Symbol ())== 1 ) CloseBULL4();   
  }
//+------------------------------------------------------------------+