[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Modify exsisting forumla



PureBytes Links

Trading Reference Links

Help....I and trying to modify the formula below.

What I want to do, is run a scan that shows the buy and sell arrows.

However, when I run the scan, the AA window shows only a few buy and
sells, yet the indicator window shows all the buy and sell arrows.

What am I doing wrong?

TIA,

Cordell

/* JOHN CLAYBURG BASED SUPPORT/RESISTANCE LINES 
Coded by GBS May 2004
Modified by Tomasz Janeczko (AmiBroker.com) on 2005-Mar-07

/* CATEGORY 3 SUPPORT BREAKOUT TRIGGER FOR SHORTS: */ 

/* PARAMETERS */

ColLSC = ParamColor("SU Color",colorOrange); 
ColLRC = ParamColor("RE Color",colorBlue); 

LL_3_6 = Ref(L,-6) > Ref(L,-3); 
LL_3_5 = Ref(L,-5) > Ref(L,-3); 
LL_3_4 = Ref(L,-4) > Ref(L,-3); 
LL_3_2 = Ref(L,-2) > Ref(L,-3); 
LL_3_1 = Ref(L,-1) > Ref(L,-3); 
LL_3_0 = L > Ref(L,-3); 
Cat3Sup = LL_3_6 AND LL_3_5 AND LL_3_4 AND LL_3_2 AND LL_3_1 AND 
LL_3_0; 

/* SUPPORT LINE ("SC") */ 
y0=ValueWhen(Cat3Sup,Ref(L,-3),2); 
y1=ValueWhen(Cat3Sup,Ref(L,-3),1); 
x0=ValueWhen(Cat3Sup,BarIndex(),2)-3; 
x1=ValueWhen(Cat3Sup,BarIndex(),1)-3; 

// looking into the future here, but it is 
// only applied to historical plots to determine 
// the length of the extension. 
xsf=ValueWhen(Cat3Sup,BarIndex(),0)-3; 

/* CATEGORY 3 RESISTANCE BREAKOUT TRIGGER FOR LONGS: */ 
HH_3_6 = Ref(H,-6) < Ref(H,-3); 
HH_3_5 = Ref(H,-5) < Ref(H,-3); 
HH_3_4 = Ref(H,-4) < Ref(H,-3); 
HH_3_2 = Ref(H,-2) < Ref(H,-3); 
HH_3_1 = Ref(H,-1) < Ref(H,-3); 
HH_3_0 = H < Ref(H,-3); 
Cat3Res = HH_3_6 AND HH_3_5 AND HH_3_4 AND HH_3_2 AND HH_3_1 AND 
HH_3_0; 

y2=ValueWhen(Cat3Res,Ref(H,-3),2); 
y3=ValueWhen(Cat3Res,Ref(H,-3),1); 
x2=ValueWhen(Cat3Res,BarIndex(),2)-3; 
x3=ValueWhen(Cat3Res,BarIndex(),1)-3; 

// another look into the future. 
xrf=ValueWhen(Cat3Res,BarIndex(),0)-3; 

Plot(C,"C", colorBlack, styleCandle); 

extendedSup=0; 
extendedRes=0; 

NullY0=IsNull(y0); 
NullY2=IsNull(y2); 

Buy = Sell = Short = Cover = 0; // FIX: INITIALIZE !!!! 
GraphXSpace = 3;

for ( i = BarCount -1 ; i > 7 ; i-- ) 
{ 
   if ( !NullY0[i] ){ // only plot lines when enough datapoints avail. 
      if ( x0[i] != x0[i-1] ) { 

         ms = (y1[i] - y0[i])/(x1[i] - x0[i]); // simple slope of support 

         if ( NOT extendedSup ) { // Haven't extended one yet 

            extendedSup = 1; 
            Line1 = LineArray( x0[i], y0[i], x1[i] + 3, y1[i] + (3 *
ms),0,True); 
            Line2 = LineArray( x1[i] + 3, y1[i] + (3 * ms), x1[i]
+4,y1 [i] + (4 * ms), 1,True); 
           
            Sell=Cross(Line2,C); 
PlotShapes(IIf (Sell,shapeHollowDownArrow,shapeNone),colorRed,0,H,-10); 

         } else { // old Cat3Sup lines, use 'look ahead' extensions 

            Line3 = LineArray( x0[i], y0[i], x1[i] + 3, y1[i] + (3
*ms),0,True); 
            Line4 = LineArray( x1[i] + 3, y1[i] + (3 * ms), xsf[i] +
3, y1[i] + ms * (xsf[i] -  x1[i] + 3), 0,True); 
           
            Sell=Cross(Line4,C); 
            PlotShapes(IIf
(Sell,shapeHollowDownArrow,shapeNone),colorRed,0,H,-10); 
         } 
      } 
   } 

   if ( !NullY2[i] ){ // only plot lines when enough datapoints avail. 
      if ( x2[i] != x2[i-1] ) { 

         mr = (y3[i] - y2[i])/(x3[i] - x2[i]); // simple slope of
resistance 

         if ( NOT extendedRes ) { // Haven't extended one yet 

            extendedRes = 1; 
            Line5= LineArray( x2[i], y2[i], x3[i] + 3, y3[i] + (3
*mr),0,True); 
            Line6 = LineArray( x3[i] + 3, y3[i] + (3 * mr), x3[i]
+4,y3  [i] + (4 * mr), 1,True); 
            Buy=Cross(C,Line6); 
            PlotShapes(IIf
(Buy,shapeUpArrow,shapeNone),colorBrightGreen,0,L,-10); 

         } else { // old Cat3Sup lines, use 'look ahead' extensions 

            Line7= LineArray( x2[i], y2[i], x3[i] + 3, y3[i] + (3 *
mr),0,True); 
            Line8 = LineArray( x3[i] + 3, y3[i] + (3 * mr), xrf[i] +
3, y3[i] + mr * (xrf[i] -  x3[i] + 3), 0,True); 
            
            Buy=Cross(C,Line8); 
            PlotShapes(IIf
(Buy,shapeUpArrow,shapeNone),colorBrightGreen,0,L,-10); 
         } 
      } 
   } 
} 






------------------------ Yahoo! Groups Sponsor --------------------~--> 
What would our lives be like without music, dance, and theater?
Donate or volunteer in the arts today at Network for Good!
http://us.click.yahoo.com/Tcy2bD/SOnJAA/cosFAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

For other support material please check also:
http://www.amibroker.com/support.html

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/