/ / + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +  
 / / |                                                                                                             P r o j e c t N a m e   |  
 / / |                                                                             C o p y r i g h t   2 0 1 8 ,   C o m p a n y N a m e   |  
 / / |                                                                               h t t p : / / w w w . c o m p a n y n a m e . n e t   |  
 / / + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +  
  
 # i n c l u d e   < s t d l i b . m q h >  
 # i n c l u d e   < s t d e r r o r . m q h >  
  
 / / + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +  
 / / |                                                     C o n f i g u r a t i o n                                                       |  
 / / + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +  
  
 e x t e r n   b o o l   E n a b l e A l e r t   =   t r u e ;  
 e x t e r n   b o o l   E n a b l e N o t i f i c a t i o n   =   t r u e ;  
 i n p u t   i n t   L e f t B a r s   =   5 ;  
 i n p u t   i n t   W i c k L o n g M i n   =   3 3 ;  
 i n p u t   i n t   W i c k S h o r t M a x   =   1 8 ;  
 i n p u t   i n t   W i c k S h o r t M i n   =   3 ;  
 i n p u t   c o l o r   N o r m a l C o l o u r   =   c l r W h i t e ;  
 i n p u t   c o l o r   S h o r t C o l o u r   =   L i g h t G r e e n ;  
 i n p u t   c o l o r   L o n g C o l o u r   =   L i g h t B l u e ;  
  
 d o u b l e   C l o s e O l d ;                                         / /   U s e d   t o   i d e n t i f y   a   n e w   b a r   i n   t h e   c o d e .  
 d o u b l e   B o d y S i z e ,   W i c k L o n g ,   W i c k S h o r t ,   B u y S h o r t ,   B u y L o n g ;  
 d o u b l e   E M A 5 0 ,   E M A 2 0 0 ;  
  
 i n t   B o d y ,   P i n b a r S h o r t ,   P i n b a r L o n g ;  
  
 / / + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +  
 / / |                                                     I n i t                                                                         |  
 / / + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +  
 i n t   O n I n i t ( )  
     {  
       r e t u r n ( I N I T _ S U C C E E D E D ) ;  
     }  
 / / + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +  
 / / |                                                     S t a r t                                                                       |  
 / / + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +  
 i n t   s t a r t ( )  
  
     {  
       i n t   d   =   T i m e D a y O f W e e k ( T i m e C u r r e n t ( ) ) ;   / /   S u n d a y   i s   0  
       i n t   h   =   T i m e H o u r ( T i m e C u r r e n t ( ) ) ;  
       i n t   m   =   T i m e M i n u t e ( T i m e C u r r e n t ( ) ) ;  
  
       B u y L o n g   =   0 ;  
       B u y S h o r t   =   0 ;  
  
 / / + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +  
 / / |                                           P a t t e r n   s e c t i o n                                                             |  
 / / + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +  
  
       E M A 5 0   =   i M A ( N U L L ,   0 ,   5 0 ,   0 ,   M O D E _ E M A ,   P R I C E _ C L O S E ,   1 ) ;  
       E M A 2 0 0   =   i M A ( N U L L ,   0 ,   2 0 0 ,   0 ,   M O D E _ E M A ,   P R I C E _ C L O S E ,   1 ) ;  
  
 / /   B o d y S i z e  
       B o d y S i z e   =   C l o s e [ 1 ]   -   O p e n [ 1 ] ;  
       i f ( B o d y S i z e   > =   0 )  
             B o d y   =   1 ;   / /   B l u e  
  
       i f ( B o d y S i z e   < =   0 )  
           {  
             B o d y S i z e   =   O p e n [ 1 ]   -   C l o s e [ 1 ] ;  
             B o d y   =   - 1 ;   / /   R e d  
           }  
 / /   * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  
  
  
 / / P i n B a r   v a l i d a t i o n  
       P i n b a r L o n g   =   0 ;  
       P i n b a r S h o r t   =   0 ;  
  
       i f ( B o d y   = =   1 )   / /   B l u e   b a r  
           {  
             W i c k L o n g   =   O p e n [ 1 ]   -   L o w [ 1 ] ;  
             W i c k S h o r t   =   H i g h [ 1 ]   -   C l o s e [ 1 ] ;  
             i f ( W i c k L o n g   > =   ( B o d y S i z e   /   1 0 0   *   W i c k L o n g M i n   *   P o i n t ( ) )   & &   B o d y S i z e   /   1 0 0   *   W i c k S h o r t M i n   *   P o i n t ( )   > =   W i c k S h o r t   < =   ( B o d y S i z e   /   1 0 0   *   W i c k S h o r t M a x   *   P o i n t ( ) ) )  
                 {  
                   P i n b a r L o n g   =   1 ;  
                 }  
  
             W i c k L o n g   =   H i g h [ 1 ]   -   C l o s e [ 1 ] ;  
             W i c k S h o r t   =   O p e n [ 1 ]   -   L o w [ 1 ] ;  
             i f ( E M A 5 0   < =   E M A 2 0 0   & &   W i c k L o n g   > =   ( B o d y S i z e   /   1 0 0   *   W i c k L o n g M i n   *   P o i n t ( ) )   & &     B o d y S i z e   /   1 0 0   *   W i c k S h o r t M i n   *   P o i n t ( )   > =   W i c k S h o r t   < =   ( B o d y S i z e   /   1 0 0   *   W i c k S h o r t M a x   *   P o i n t ( ) ) )  
                 {  
                   P i n b a r S h o r t   =   1 ;  
                 }  
           }  
  
       i f ( B o d y   = =   - 1 )   / /   R e d   b a r  
           {  
             W i c k L o n g   =   C l o s e [ 1 ]   -   L o w [ 1 ] ;  
             W i c k S h o r t   =   H i g h [ 1 ]   -   O p e n [ 1 ] ;  
             i f ( W i c k L o n g   > =   ( B o d y S i z e   /   1 0 0   *   W i c k L o n g M i n )   & &     B o d y S i z e   /   1 0 0   *   W i c k S h o r t M i n   > =   W i c k S h o r t   < =   ( B o d y S i z e   /   1 0 0   *   W i c k S h o r t M a x ) )  
                 {  
                   P i n b a r L o n g   =   1 ;  
                 }  
  
             W i c k L o n g   =   H i g h [ 1 ]   -   O p e n [ 1 ] ;  
             W i c k S h o r t   =   C l o s e [ 1 ]   -   L o w [ 1 ] ;  
             i f ( W i c k L o n g   > =   ( B o d y S i z e   /   1 0 0   *   W i c k L o n g M i n )   & &     B o d y S i z e   /   1 0 0   *   W i c k S h o r t M i n   > =   W i c k S h o r t   < =   ( B o d y S i z e   /   1 0 0   *   W i c k S h o r t M a x ) )  
                 {  
                   P i n b a r S h o r t   =   1 ;  
                 }  
           }  
  
  
       i f ( P i n b a r L o n g   = =   1   & &   L o w [ 1 ]   < =   E M A 5 0   & &   C l o s e [ 1 ]   > =   E M A 5 0   & &   O p e n [ 1 ]   > =   E M A 5 0   & &   O p e n [ 2 ]   > =   E M A 5 0   & &   C l o s e [ 2 ]   > =   E M A 5 0   & &   E M A 5 0   > =   E M A 2 0 0 )  
             B u y L o n g   =   1 ;  
  
       i f ( P i n b a r L o n g   = =   1   & &   H i g h [ 1 ]   > =   E M A 5 0   & &   C l o s e [ 1 ]   < =   E M A 5 0   & &   O p e n [ 1 ]   < =   E M A 5 0   & &   O p e n [ 2 ]   < =   E M A 5 0   & &   C l o s e [ 2 ]   < =   E M A 5 0   & &   E M A 5 0   < =   E M A 2 0 0 )  
             B u y S h o r t   =   1 ;  
  
       i f ( P i n b a r S h o r t   = =   1   & &   L o w [ 1 ]   < =   E M A 5 0   & &   C l o s e [ 1 ]   > =   E M A 5 0   & &   O p e n [ 2 ]   > =   E M A 5 0   & &   C l o s e [ 2 ]   > =   E M A 5 0   & &   E M A 5 0   > =   E M A 2 0 0 )  
             B u y L o n g   =   1 ;  
  
       i f ( P i n b a r S h o r t   = =   1   & &   H i g h [ 1 ]   > =   E M A 5 0   & &   O p e n [ 1 ]   < =   E M A 5 0   & &   C l o s e [ 1 ]   < =   E M A 5 0   & &   O p e n [ 2 ]   < =   E M A 5 0   & &   C l o s e [ 2 ]   < =   E M A 5 0   & &   E M A 5 0   < =   E M A 2 0 0 )  
             B u y S h o r t   =   1 ;  
  
  
 / / L o o k i n g   l e f t .   5 0 E M A   m u s t   n o t   b e   e x c e e d e d .  
  
       f o r ( i n t   i = 1 ;   i < =   L e f t B a r s ;   i + + )  
           {  
             i f ( E M A 5 0   < =   E M A 2 0 0 )  
                 {  
                   i f ( O p e n [ i ]   > =   E M A 5 0   | |   C l o s e [ i ]   > =   E M A 5 0 )  
                       {  
                         B u y L o n g   =   0 ;  
                         B u y S h o r t   =   0 ;  
                       }  
                 }  
             i f ( E M A 5 0   > =   E M A 2 0 0 )  
                 {  
                   i f ( O p e n [ i ]   < =   E M A 5 0   | |   C l o s e [ i ]   < =   E M A 5 0 )  
                       {  
                         B u y L o n g   =   0 ;  
                         B u y S h o r t   =   0 ;  
                       }  
                 }  
           }  
  
  
  
  
 / /   * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  
 / /   F r o m   h e r e   t h e   c o d e   i s   v i s i t e d   o n l y   a t   e v e r y   n e w   b a r .  
       i f ( C l o s e [ 1 ]   ! =   C l o s e O l d ) / /   D e r v e d   k ø r e r   s c r i p t e t   k u n   é n   g a n g   p e r   b r i c k  
           {  
             C l o s e O l d   =   C l o s e [ 1 ] ;   / / E n   n y   b a r   f o r e k o m m e r .  
  
             / /   A l a r m s :  
             i f ( B u y L o n g   = =   1 )  
                 {  
                   C h a r t S e t I n t e g e r ( C h a r t I D ( ) ,   C H A R T _ C O L O R _ B A C K G R O U N D ,   L o n g C o l o u r ) ;           / /   O w n e d   L o n g .  
                   i f ( E n a b l e A l e r t   = =   t r u e )  
                         A l e r t ( S y m b o l ( ) ,   " P i n b a r   L o n g   s i g n a l " ) ;  
                   i f ( E n a b l e N o t i f i c a t i o n   = =   t r u e )  
                         S e n d N o t i f i c a t i o n ( " P i n b a r   L o n g   s i g n a l .       " +   S y m b o l ( )   +   "       T i m e F r a m e   "   +     C h a r t P e r i o d ( 0 ) ) ;  
                 }  
  
  
             i f ( B u y S h o r t   = =   1 )  
                 {  
                   C h a r t S e t I n t e g e r ( C h a r t I D ( ) ,   C H A R T _ C O L O R _ B A C K G R O U N D ,   S h o r t C o l o u r ) ;           / /   O w n e d   L o n g .  
                   i f ( E n a b l e A l e r t   = =   t r u e )  
                         A l e r t ( S y m b o l ( ) ,     " P i n b a r   S h o r t   s i g n a l " ) ;  
                   i f ( E n a b l e N o t i f i c a t i o n   = =   t r u e )  
                         S e n d N o t i f i c a t i o n ( " P i n b a r   S h o r t   s i g n a l .     " +   S y m b o l ( ) +   "       T i m e F r a m e   " +     C h a r t P e r i o d ( 0 ) ) ;  
                 }  
  
             i f ( B u y S h o r t   = =   0   & &   B u y L o n g   = =   0 )  
                 {  
                   C h a r t S e t I n t e g e r ( C h a r t I D ( ) ,   C H A R T _ C O L O R _ B A C K G R O U N D ,   N o r m a l C o l o u r ) ;           / /   O w n e d   L o n g .  
                 }  
  
           }   / / i f ( C l o s e [ 1 ]   ! =   C l o s e O l d )  
  
  
 / /   * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  
  
  
  
 / / + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +  
 / / |                                       S h o w   s p l i t   o n   s c r e e n                                                       |  
 / / + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +  
  
       s t r i n g   S p l i t ,   S p l i t 2 ;  
  
       S p l i t   =   " S p l i t t " ;  
       S p l i t 2   =   " S p l i t t 2 " ;  
  
       d o u b l e   S p l i t V a l u e   =   N o r m a l i z e D o u b l e ( ( A s k   -   B i d )   /   P o i n t   /   1 0 ,   2 ) ;  
  
       O b j e c t D e l e t e ( " S p l i t t " ) ;  
       O b j e c t C r e a t e ( " S p l i t t " ,   O B J _ L A B E L ,   0 ,   0 ,   0 ) ;  
       O b j e c t S e t T e x t ( " S p l i t t " , " S p l i t " ,   1 2 ,   " V e r d a n a " ,   W h i t e ) ;  
       O b j e c t S e t ( " S p l i t t " ,   O B J P R O P _ C O R N E R ,   C O R N E R _ R I G H T _ U P P E R ) ;  
       O b j e c t S e t ( " S p l i t t " ,   O B J P R O P _ X D I S T A N C E , 1 0 0 ) ;  
       O b j e c t S e t ( " S p l i t t " ,   O B J P R O P _ Y D I S T A N C E , 2 0 ) ;  
  
 / / + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +  
 / / |                                                                                                                                     |  
 / / + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +  
       O b j e c t D e l e t e ( " S p l i t t 2 " ) ;  
       O b j e c t C r e a t e ( " S p l i t t 2 " ,   O B J _ L A B E L ,   0 ,   0 ,   0 ) ;  
       O b j e c t S e t T e x t ( " S p l i t t 2 " , S p l i t V a l u e , 1 2 ,   " V e r d a n a " ,   R e d ) ;  
       O b j e c t S e t ( " S p l i t t 2 " ,   O B J P R O P _ C O R N E R ,   C O R N E R _ R I G H T _ U P P E R ) ;  
       O b j e c t S e t ( " S p l i t t 2 " ,   O B J P R O P _ X D I S T A N C E , 2 5 ) ;  
       O b j e c t S e t ( " S p l i t t 2 " ,   O B J P R O P _ Y D I S T A N C E , 2 0 ) ;  
  
  
 / / + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +  
 / / |                                                     S k r i v   p å   s k æ r m e n                                                 |  
 / / + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +  
       C o m m e n t (  
 / /   J u s t   p r o g r a m m i n g   a i d s :  
             " S y m b o l   =   " ,   S y m b o l ( )   +   " \ n " ,  
             " L e v e l   =   " ,   A c c o u n t I n f o I n t e g e r ( A C C O U N T _ L E V E R A G E )   +   " \ n " ,  
             " B u y L o n g   =   " ,   B u y L o n g   +   " \ n " ,  
             " B u y S h o r t   =   " ,   B u y S h o r t   +   " \ n " ,  
             " B o d y S i z e   =   " ,   B o d y S i z e   +   " \ n " ,  
             " B o d y   =   " ,   B o d y   +   " \ n " ,  
             " W i c k L o n g   =   " ,   W i c k L o n g   +   " \ n " ,  
             " W i c k S h o r t   =   " ,   W i c k S h o r t   +   " \ n " ,  
             " h   =   " ,   h   +   " \ n "  
       ) ;  
     }  
 / / + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +  
 