//
// price chart with trade calls for aroon + sar signs
//
//------------------------------------------------------------------------------
Plot(C,"",colorBlack,styleCandle|styleNoLabel);
PositionSize = 100;
slope = Param("slope",2,2,100,1);
Color20= IIf(LinRegSlope(MA(C,20),slope)<0,colorRed,colorBrightGreen);
event1= LinRegSlope(MA(C,20),slope)<0;
Plot( MA( C, 20), "",Color20 , styleLine);
//Plot( event1, "", colorRose, styleArea|styleOwnScale);
Color50= IIf(LinRegSlope(MA(C,50),slope)<0,colorRed,colorBlue);
Plot( MA( C, 50), "",Color50 , styleLine);
Color100= IIf(LinRegSlope(MA(C,100),slope)<0,colorRed,colorYellow);
Plot( MA( C, 100), "",Color100 , styleLine);
Color150= IIf(LinRegSlope(MA(C,150),slope)<0,colorRed,10);
Plot( MA( C, 150), "",Color150 , styleLine);
event1=Cross(MA(C,20),MA(C,50));
PlotShapes( IIf(event1 ,shapeDigit1,0) ,5, 0, L,-30);
event2=Cross(MA(C,50),MA(C,100));
PlotShapes( IIf(event2 ,shapeDigit2,0) ,6, 0, L,-30);
event3=Cross(MA(C,100),MA(C,150));
PlotShapes( IIf(event3 ,shapeDigit3,0) ,7, 0, L,-30);
event4=Cross(MA(C,50),MA(C,20));
PlotShapes( IIf(event4 ,shapeDigit4,0) ,5, 0, H,30);
event5=Cross(MA(C,100),MA(C,50));
PlotShapes( IIf(event5 ,shapeDigit5,0) ,6, 0, H,30);
event6=Cross(MA(C,150),MA(C,100));
PlotShapes( IIf(event6 ,shapeDigit6,0) ,7, 0, H,30);
event7=Cross(MA(C,5),MA(C,20));
PlotShapes( IIf(event7 ,shapeDigit7,0) ,9, 0, L,-30);
//////////////////////////////////MACD///////////////////////////////////
MACDRequired=1;
FAST = Param("FAST",12,0,100,1);
SLOW = Param("SLOW",26,0,100,1);
SIG = Param("SIG",9,0,100,1);
MACDLine = MACD(FAST,SLOW);
MACDSignal = Signal(FAST,SLOW,SIG);
MACDHisto = MACDLine - MACDSignal;
MinDir= Param("DirChange",0.6,-5,5,step=0.01);
NOEXCESS= Param("Remove Excess Signals",1,0,1,step=1);
HistDivUp = Cross(LinRegSlope(MACDHisto,3),0);
HistDivDn = Cross(0,LinRegSlope(MACDHisto,3));
HBuy = HistDivUp ;
HSell = HistDivDn ;
event7=Cross(AO,-50);
event8= Cross(0,AO);
event9= Cross(AU,AD);
event10=Cross(AD,AU);
AroonBuy= event9;
AroonSell=event10;
MACDLine = MACD(FAST,SLOW);
ADXBuy18=Cross(PDI(range),MDI(range));
ADXSell19=Cross(MDI(range),PDI(range));
ADXBuy=ADXBuy18;
ADXSell=ADXSell19;
dirup= (BarsSince(Low<LowBand)<5);
dirdn= (BarsSince(High>TopBand)<5);
BBBuy=0;
BBSell=0;
//Buy = AroonBuy;
//Sell = AroonSell;
//Short = Sell;
//Cover = Buy;
LookBack=Param("Lookback (RegressionChannel)",72,1,300);
N=0;
if(NL>NH) { N=NL; } else { N=NH; }
Start = 1;
/* Calculate the slope (bconst) and the y intercept (aconst) of the line */
SUMX = LastValue(Sum(X,N));
SUMY = LastValue(Sum(Y,N));
SUMXY = LastValue(Sum(X*Y,N));
SUMXSqd = LastValue(Sum(X*X,N));
SUMSqdX = LastValue(SUMX * SUMX);
/* Force the x value to be very negative so the graph does not apear before the
lookback period */
reverse = 0;
//check for reversal
if ( long )
{
if ( Low [ i ] < psar [ i ] )
{
long = 0; reverse = 1; // reverse position to Short
psar [ i ] = hp; // SAR is High point in prev trade
lp = Low [ i ];
af = IAF;
}
}
else
{
if ( High [ i ] > psar [ i ] )
{
long = 1; reverse = 1; //reverse position to long
psar [ i ] = lp;
hp = High [ i ];
af = IAF;
}
}
if ( reverse == 0 )
{
if ( long )
{
if ( High [ i ] > hp )
{
hp = High [ i ];
af = af + IAF;
if( af > MaxAF ) af = MaxAF;
}
if( SelectedValue(ADXFastDir)>0 )
{
if(SelectedValue(ADXBuy5)) printf("Wait for retest of low, and then ADX turn
down");
if(SelectedValue(ADXSell6)) printf("Wait for retest of high, and then ADX turn
down");
}
WriteIf( ADXBuy1 AND MACDLine < 1 AND HistDivDn, "*WARNING* Trend could fail to
begin !","");
WriteIf( ADXSell2 AND MACDLine > -1 AND HistDivUp, "*WARNING* Trend could fail to
begin !","");
WriteIf( ADX(range) < 20 , "Trading range, weak direction - watch for Histogram
Divergences","");