Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
OLT
//OLT 

#property indicator_separate_window
#property indicator_buffers 4
#property indicator_color1 Orange
#property indicator_style1 0 
#property indicator_width1 2
#property indicator_color2 DodgerBlue
#property indicator_style2 0 
#property indicator_width2 1
#property indicator_color3 LimeGreen
#property indicator_style3 0 
#property indicator_width3 1
#property indicator_color4 SlateGray
#property indicator_style4 0 
#property indicator_width4 1
// ââîäíûå ïàðàìåòðû

   extern int Q = 989;          // êîëè÷åñòâî äíåâíûõ áàðîâ â ñòàòèñòèêå 
   extern int period = 4;       // ïåðèîä ñðåäíåãî äíåâíîãî äèàïàçîíà
//--------------------------------
   double Buffer[];
   double Buffer1[];
   double Buffer2[];
   double Buffer3[];
   int x2 = 1;
   datetime ex;
//------------------
        int init( )
        {
        IndicatorBuffers( 4 );
        SetIndexStyle( 0, DRAW_LINE );
        SetIndexStyle( 1, DRAW_LINE );
        SetIndexStyle( 2, DRAW_LINE );
        SetIndexStyle( 3, DRAW_LINE );
        SetIndexBuffer( 0, Buffer );
        SetIndexBuffer( 1, Buffer1 );
        SetIndexBuffer( 2, Buffer2 );
        SetIndexBuffer( 3, Buffer3 );
        SetIndexDrawBegin( 0, Bars - 300 );
        SetIndexDrawBegin( 1, Bars - 300 );
        SetIndexDrawBegin( 2, Bars - 300 );
        SetIndexDrawBegin( 3, Bars - 300 );
        return(0);
        }
//----------------
        int deinit( )
        {
        ObjectsDeleteAll( 1 );
        return(0);
        }
//--------------------------
        int start( )
        {
        
        if( ( x2 > 0 ) || ( ex != Time[0] ) )
        {
        ex = Time[0];
        int h;
        int z;
        int pct;
        int n;
        double g;
        double G;
        double M;
        double P;
        datetime t = 300 * Period( );
        while( h < 300 )
        {
        g = g + 0.01;
        int i = 1;
        while( i <= Q )
        {
        int r = 1;
        double Sum = 0;
        double ar;
        while( r <= period )
        {
        Sum = Sum + ( High[i + r] - Low[i + r] );
        ar = Sum / period;
        r++;
        }
        if( ar > 0 )
        {
        double ds = ( High[i] - Low[i] ) / ar;
        double y1 = ( High[i] - Open[i] ) / ar;
        double y2 = ( Open[i] - Low[i] ) / ar;
        }
        double sv1;
        double sv2;
        if( y1 > y2 )
        {
        sv1 = y1;
        sv2 = y2;
        }
        else
        {
        if( y1 < y2 )
        {
        sv1 = y2;
        sv2 = y1;
        }
        }
        double e;
        double b1;
        if( ds >= g )
        {
        e++;
        }
        if( sv1 >= g )
        {
        if( sv2 >= g )
        {
        b1++;
        }
        }
        i++;
        }
        if( i > 0 )
        {
        P = e / i;
        Buffer2[h] = b1 / i;
        }        
        G = g * P;
        if( M < G )
        {
        M = G;
        pct = 100 * g;
        n = 100 * P;
        }
        Buffer[h] = G;
        Buffer1[h] = P;
        Buffer3[h] = 0;
        e = 0;
        b1 = 0;
        h++;
        z++;
        if( z == 10 )
        {
        string q = h;
        ObjectCreate( q, OBJ_TEXT, 1, Time[h], -0.011 );
        ObjectSet( q, OBJPROP_TIME1, Time[h] );
        ObjectSet( q, OBJPROP_PRICE1, -0.011 );
        ObjectSetText( q," "+h+" ", 6, "Verdana", Blue );
        z = 0;
        }
        if( h <= 10 )
        {
        string f = 10 * h + " ";
        double x5 = 0.1 * h;
        ObjectCreate( f, OBJ_TEXT, 1, Time[0] + t, x5 );
        ObjectSet( f, OBJPROP_TIME1, Time[0] + t );
        ObjectSet( f, OBJPROP_PRICE1, x5 );
        ObjectSetText( f," "+f+" ", 6, "Verdana", Blue );
        }
        }
        ObjectCreate( "VL", OBJ_VLINE, 1, Time[0], 0 );
        ObjectSet( "VL", OBJPROP_TIME1, Time[0] );
        ObjectSet( "VL", OBJPROP_COLOR, Gray );
        string short_name = "Optimum Procent of AR("+period+") = "+pct+"%  Probability = "+n+"%    ";
        IndicatorShortName( short_name );
        SetIndexLabel( 0, short_name );
        x2--;
        }

        return(0);
        }

Comments