Re: Breakout

51

Code: Select all

 int start()

  {

    int limit;

    int counted_bars;

    //double prev, current, old;

    double Value=0,Value1=0,Value2=0,Fish=0,Fish1=0,Fish2=0;

    double price;

    double MinL=0;

    double MaxH=0;

   

    counted_bars = IndicatorCounted();

    if ( counted_bars > 0 ) counted_bars--;

    limit = Bars - counted_bars;



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

      {

        MaxH = High[iHighest(NULL,0,MODE_CLOSE,period,i)];                       

        MinL = Low[iLowest(NULL,0,MODE_CLOSE,period,i)];                          

        price = (Open[i]+ Close[i])/2;                                             



        if(MaxH-MinL == 0) Value = 0.33*2*(0-0.5) + 0.67*Value1;

        else Value = 1.369999*2*((price-MaxH)/(MinL-MaxH)-0.5) + 1.3899999*Value1;



        Value=MathMin(MathMax(Value,-0.999),0.999);

 

        if(1-Value == 0) ExtBuffer0[i]=0.5+0.5*Fish1;

        else ExtBuffer0[i]=0.5*MathLog((1+Value)/(1-Value))+0.5*Fish1;



        Value1=Value;

        Fish1=ExtBuffer0[i];

      }

    int counted_bars2 = IndicatorCounted();

    if ( counted_bars2 > 0 ) counted_bars2--;

    int limit2 = Bars - counted_bars2;

    for ( int j = limit2; j >= 0; j-- )

      {

        if ( Arrow )

          {

            if ( ExtBuffer0[j+SIGNAL_BAR+1] > 0.0  && ExtBuffer0[j+SIGNAL_BAR] < 0.0 ) manageArr(j+1, clArrowBuy,  233, false);

            if ( ExtBuffer0[j+SIGNAL_BAR+1] < 0.0  && ExtBuffer0[j+SIGNAL_BAR] > 0.0 ) manageArr(j+1, clArrowSell, 234, true );

          }

      }

    return(0);

  }

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

void manageArr(int j, color clr, int theCode, bool up)   

  {

    string objName = PREFIX + Time[j];

    double gap  = 3.0*iATR(NULL,0,20,j)/4.0;

    

    ObjectCreate(objName, OBJ_ARROW,0,Time[j],0);

    ObjectSet   (objName, OBJPROP_COLOR, clr);  

    ObjectSet   (objName, OBJPROP_ARROWCODE,theCode);

    ObjectSet   (objName, OBJPROP_WIDTH,ArrowSize);  

    if ( up )

      ObjectSet(objName,OBJPROP_PRICE1,Open[j]+gap);

    else  

      ObjectSet(objName,OBJPROP_PRICE1,Close[j] -gap);

  }

// -------------------------------------------------------------------------------------------------------------
0 + 0 = 0
Infinite / Infinite = 1
1 way to Heaven & it matters






Who is online

Users browsing this forum: Sogou [Bot] and 19 guests