Stock Portfolio Organizer

The ultimate porfolio management solution.

Shares, Margin, CFD's, Futures and Forex
EOD and Realtime
Dividends and Trust Distributions
And Much More ....
For Portfolio Manager Click Here

WiseTrader Toolbox

#1 Selling Amibroker Plugin featuring:

Advanced Adaptive Indicators
Advanced Pattern Exploration
Neural Networks
And Much More ....
Find Out More Here

Basic Trading System for Amibroker (AFL)
morgen
over 14 years ago
Amibroker (AFL)

Rating:
5 / 5 (Votes 1)
Tags:
trading system, amibroker

I look at the chart and this is it! It is a simple but efficient trading system.

Screenshots

Similar Indicators / Formulas

weighted moving average scan
Submitted by naninn almost 14 years ago
Kase Peak Osc. V2 batu
Submitted by batu1453 over 10 years ago
Kase CD V2batu
Submitted by batu1453 over 10 years ago
Ichimoku
Submitted by prashantrdx over 10 years ago
EMA System Ribbon
Submitted by yo123 almost 14 years ago
Three-Bar Inside Bar Pattern
Submitted by EliStern over 13 years ago
You cannot view the code for the following reasons:
  • You must be a member.

5 comments

1. morgen

For more buy’s points, you could eliminate “botdn” from both “mybuy” formulas.

2. morgen

Try to add to “mybuy” also “volatbuy” from FORMULE.
Seems to be better…

3. chetan ninganiya

@morgen @admin

sir, can anyone of you please explain how to use this system?

4. morgen

Try this!
Is similar, but newer and better, even more clear perhaps.

// BB

P = ParamField("Price field",-1);
Periods = Param("Periods", 20, 2, 300, 1 );
Width = Param("Width", 2, 0, 10, 0.05 );
//Color = ParamColor("Color", colorCycle );
//Style = ParamStyle("Style");
bbtop= BBandTop( P, Periods, Width ) ;
bbbot= BBandBot( P, Periods, Width ) ;
//Plot( BBandTop( P, Periods, Width ), "BBTop" + _PARAM_VALUES(), Color, Style ); 
//Plot( BBandBot( P, Periods, Width ), "BBBot" + _PARAM_VALUES(), Color, Style ); 
bbdif= bbtop-bbbot ;
bbdifup= bbdif>Ref(bbdif,-1) ;
bbtopup= bbtop>Ref(bbtop,-1) ;
bbbotup= bbbot>Ref(bbbot,-1) ;
bbmid= (bbtop+bbbot)/2 ;
bbmidup= bbmid>=Ref(bbmid,-1) ;
Cupbbmid= C>bbmid ;
bbtopcol= IIf(bbtopup,colorRed,colorPink) ;
bbbotcol= IIf(bbbotup,colorRed,colorPink) ;
bbmidcol= IIf(bbmidup,colorBlue,colorAqua) ;
Plot(bbmid,"\nBBMid",bbmidcol,styleDots+styleThick ) ;
Plot( bbtop , "\nBBTop", bbtopcol, styleDots+styleThick);
Plot( bbbot , "\nBBBot", bbbotcol, styleDots+styleThick); 
//Plot( bbbot , "\nBBBot", colorRed , styleLine +styleThick); 

Upcond= (C>bbmid AND bbdifup) ;
Dncond= C<bbmid ;

//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

//XXXXXXXXXX HEIKIN ASHI DERZI EXACT FORMULA BEGIN DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD

_SECTION_BEGIN("HA Looping ( no AMA() )");
SetChartOptions(0,chartShowArrows|chartShowDates);
///////////////////////////////////////////////////////////
//
// Heikin Ashi - Calculated Properly with no use of AMA
//
// JF Derzi, December 2012
//
//

HaClose[0] = (Open[0]+High[0]+Low[0]+Close[0]) / 4;
HaOpen[0]  = (HaClose[0] + Open[0]) / 2;
HaHigh[0]  = Max( High[0], Max( HaClose[0], HaOpen[0] ) );
HaLow[0]   = Min( Low[0], Min( HaClose[0], HaOpen[0] ) );

for (i=1; i<BarCount; i++)
	{
	HaClose[i] = (Open[i]+High[i]+Low[i]+Close[i]) / 4;
	Haopen[i]  = (HaClose[i-1] + HaOpen[i-1]) / 2; // Here is the problem when using Arrays: Haopen always uses its own previous value
	HaHigh[i]  = Max( High[i], Max( HaClose[i], HaOpen[i] ) );
	Halow[i]   = Min( Low[i], Min( HaClose[i], HaOpen[i] ) );
}

//PlotOHLC( HaOpen, HaHigh, HaLow, HaClose, "HA", colorBlack, styleCandle );


barcolorha = IIf(HaClose>=HaOpen,colorGreen,colorRed);
SetBarFillColor(IIf(HaClose>=HaOpen,colorGreen,colorRed ));
PlotOHLC( HaOpen, HaHigh, HaLow, HaClose, "\nHeikinAshiDerzi", barcolorha, styleCandle );


//Title = Name()+" "+Date()+" Heikin Ashi -- HaOpen:"+NumToStr(HaOpen,1.2,True)+" / HaHigh:"+NumToStr(HaHigh,1.2,True)+
//        " / HaLow:"+NumToStr(Halow,1.2,True)+" HaClose:"+NumToStr(Haclose,1.2, True);

_SECTION_END();

HAup= HaClose>=HaOpen ;
haDelta= HaClose-HaOpen ;
MAhaDelta= MA(haDelta,3) ;
haDeltaUpMA= haDelta>MA(haDelta,3) ;

//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXHEIKIN ASHI EXACT FORMULA END DDDDDDDDDDDDDDDDDDDDDDDD

//PRICE

_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%)Vol " +
            WriteVal( V, 1.0 ) + " {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 )) ));
//Plot( C, "", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 

//barcolorc= IIf(C>O AND C>Ref(C,-1), colorBlue,
//           IIf(C<O AND C<Ref(C,-1), colorRed, colorTan)); //MODEL MODEL MODEL 3 CULORI
//SetBarFillColor( IIf(C>O AND C>Ref(C,-1), colorBrightGreen,
//                 IIf(C<O AND C<Ref(C,-1), colorOrange, colorTan))); //MODEL MODEL MODEL 3 CULORI
//Plot( C, "", barcolorc, styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
//Plot( C, "", barcolorc, styleBar+styleThick );
_SECTION_END(); 

//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

//VSTOP 2

_SECTION_BEGIN("Volatility 2");

// Just Re-share
// E.M.Pottasch, Jul 2010
// from Metastock formula, link: http://stocata.org/metastock/stop_trail_atr.html
// added separate parameters for upward and downward market environment

function vstop_func(trBull,trBear)
{
	trailArray[ 0 ] = C[ 0 ]; // initialize
	for( i = 1; i < BarCount; i++ )
	{
		prev = trailArray[ i - 1 ];
 
		if (C[ i ] > prev AND C[ i - 1 ] > prev)
		{
			trailArray[ i ] = Max(prev,C[ i ] - trBull[ i ]);
		}
		else if (C[ i ] < prev AND C[ i - 1 ] < prev)
		{
			trailArray[ i ] = Min(prev,C[ i ] + trBear[ i ]);
		}
		else if (C[ i ] > prev)
		{
			trailArray[ i ] = C[ i ] - trBull[ i ];
		}
		else
		{
			trailArray[ i ] = C[ i ] + trBear[ i ];	
		}
	}
	return trailArray;
}

//trailLong= Support= SellStop ;
//trailShort= Resistance= BuyStop ;

//per = Param("per",20, 1, 150, 1);
//multBull = Param("multBull",2, 1, 4, 0.05);
//multBear = Param("multBear",2, 1, 4, 0.05);
per = Param("ATRper",14, 1, 150, 1);
multBear = Param("kRes",1.7, 0, 4, 0.05);
multBull = Param("kSup",1.7, 0, 4, 0.05);

trBull = multBull * ATR(per);
trBear = multBear * ATR(per);

trailArray = vstop_func(trBull,trBear);

//SetChartBkColor( ParamColor("ColorBG", ColorRGB( 0, 0, 0 ) ) );
GraphXSpace = 5;
//SetChartOptions(0, chartShowDates);
//Plot(IIf(trailArray > C,trailArray,Null),"\ntrailShort",ParamColor("ColorTrailShort",ColorRGB(255,0,0)),styleStaircase);
//Plot(IIf(trailArray < C,trailArray,Null),"\ntrailLong",ParamColor("ColorTrailLong",ColorRGB(0,255,0)),styleStaircase);
//Plot(IIf(trailArray > C,trailArray,Null),"\nBuyStop",colorRed,styleStaircase+styleThick);
//Plot(IIf(trailArray < C,trailArray,Null),"\nSellStop",colorBlue,styleStaircase+styleThick);
trailARRAYcolor= IIf(C>trailARRAY,colorBlue,colorRed) ;
//Plot(trailArray,"\nVSTOP",trailARRAYcolor,styleLine+styleThick) ;
//Plot(trailArray,"\nVSTOP",trailARRAYcolor,8+16) ;
//Plot(trailArray,"\nVSTOP",trailARRAYcolor,styledots) ;
//Plot( C, "\nCandle",colorWhite, styleCandle );

BuystopNew= C>trailARRAY ;

_SECTION_END();

//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

//CLEAR METHOD

//LISTING 1

upsw = 0; 
Hh = Lh = H[ 0 ]; 
Hl = Ll = L[ 0 ]; 

for( i = 0; i < BarCount; i++ ) 
{ 
  Ch = H[ i ]; 
  Cl = L[ i ]; 

  if( upsw == 1 ) 
  { 
    Hh = Max( Ch, Hh ); 
    hL = Max( Cl, Hl ); 
     
    if( Ch < Hl ) 
    { 
      upsw = 0; 
      Ll = Cl; 
      Lh = Ch; 
    } 
  } 
   
  if( upsw == 0 ) 
  { 
    Ll = Min( Cl, Ll ); 
    Lh = Min( Ch, Lh ); 

    if( Cl > Lh ) 
    { 
      upsw = 1; 
      Hh = Ch; 
      Hl = Cl; 
    } 
  } 

  Hla[ i ] = Hl; 
  Lha[ i ] = Lh; 
  upswa[ i ] = upsw; 
} 
   
//Plot( IIf( upswa == 1, Hla, Null ), "SwLine", ColorRGB( 64, 128, 128), styleThick ); 
//Plot( IIf( upswa == 0, Lha, Null ), "SwLine", ColorRGB( 128, 64, 128), styleThick  ); 
//Plot( IIf( upswa == 1, Hla, Null ), "\nSwLine", colorBlue  , styleDots ); 
//Plot( IIf( upswa == 0, Lha, Null ), "\nSwLine", colorRed , styleDots ); 


//Plot( C, "Price", IIf( upswa == 1, 
//      ColorBlend( colorGreen, colorWhite ), 
//      ColorBlend( colorRed, colorWhite )), styleBar+styleThick ); 
//Plot( C, "Price", IIf( upswa == 1, 
//      ColorBlend( colorLime , colorWhite ), 
//      ColorBlend( colorRed, colorWhite )), styleBar+styleThick );  

CpClear= upswa == 1 ;
VdClear= upswa == 0 ;

//Buy= Cross(upswa ,0) ;
//Sell= Cross(1,upswa) ;

//PlotShapes(IIf(Cross(upswa,0),shapeUpTriangle,shapeNone),colorBlue ,0,haLow,Offset=-20); //MUTATA LA FORMULE DIN CAUZA haLow
//PlotShapes(IIf(Cross(1,upswa),shapeDownTriangle,shapeNone),colorRed ,0,haHigh,Offset=-20); //MUTATA LA FORMULE DIN CAUZA haHigh   

//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

//TRAILING STOP LOSS WITH HIGH AND LOW
/*
// STAMP CODE NAME 
GfxSelectFont("Tahoma", 15, 700 ); 
GfxSetBkColor( colorGreen );
GfxSetTextColor(colorBlack);
GfxTextOut("High Low Trailing Stop",Status("pxwidth")/1.25,Status("pxheight")/50);
GraphXSpace=5; */

//====== Original TT by X ========
//------ Setting -----------------
SetOption("InitialEquity",1000000);
SetTradeDelays( 0, 0, 0, 0 );
RoundLotSize = 100;
BuyPrice=Close;
SellPrice=Close;
SetOption("maxopenpositions",1);
PositionSize=-100;

PcntOffset = 0;
function Hstop_func()
{
	trailHL[ 0 ] = L[ 0 ]; // initialize
	for( i = 1; i < BarCount; i++ )
	{
		prev = trailHL[ i - 1 ];
 
		if (C[ i ] >= prev AND C[ i - 1 ] >= prev)// Long Side This Day and Previous Day > Trailing
		{

			if(H[i]>H[i-1])// Make New High
				trailHL[ i ] = (Max(prev,L[i-1]))*(1-PcntOffset/100);
			else // No New high
				trailHL[ i ] = prev;
		}
		else if (C[ i ] < prev AND C[ i - 1 ] < prev)// Short Side This Day and Previous Day < Trailing
		{
			if(L[i]<L[i-1])// Make New Low
				trailHL[ i ] = (Min(prev,H[i-1]))*(1+PcntOffset/100);
			else
				trailHL[ i ] = prev;
		}
		else if (C[ i ] < prev AND C[ i - 1 ] >= prev)// Short Point
		{
			trailHL[ i ] = (Max(H[i],H[i-1]))*(1+PcntOffset/100);//C[ i ] - trBull[ i ];			
			stoploss[i-1]=1;
		}
		else //Long Point
		{
			trailHL[ i ] = (L[i])*(1-PcntOffset/100);//C[ i ] + trBear[ i ];	
			
		}
	}
	return trailHL;
}


trailHL = Hstop_func();
//Plot( trailHL,"\nStopLossHL",IIf(C<trailHL,colorRed,colorBlue),styleLine+styleThick);

CpHL= C>trailHL ;

//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

//COUNTBACK LINE

//* Stephane Carrasset's Countback Line (CBL) popularized by Daryl Guppy

//Refer to amibroker posting 30th December 2004 */

//nR=2;
nR= Param("nR",2,1,20,1,0) ;

Cbl[nR]=Null;

bCBL=False;

for( i=nR; i < BarCount; i++)

{

if( (Low[i-2]<Low[i-1]) && (Low[i-1]<Low[i]) )

{

Cbl[i] = Low[i-2];

bCBL = True;

}

else if (bCBL)

{

if (Low[i] < Cbl[i-1])

{

Cbl[i] = Cbl[i-1];

bCBL = False;

}

else

{

n = nR;

minval[i] = Low[i];

breakloop= False;

for (j = 1; NOT(breakloop) && j <= i; j++)

{

if (Low[i-j] < minval[i])

{

if (n>1)

{

minval[i] = Low[i-j];

n--;

}

else

{

Cbl[i] = Low[i-j];

breakloop=True;

}

}

}

if (Cbl[i] < Cbl[i-1])

Cbl[i] = Cbl[i-1];

}

}

else

{

Cbl[i] = Cbl[i-1];

}

if (Cbl[i]==0)

Cbl[i] = Cbl[i-1];

}

CBLcol= IIf(C>CBL,colorBlue,colorRed) ;
//Plot(Cbl,"\nCBL",colorRed,styleLine+styleThick);
//Plot(Cbl,"\nCBL",CBLcol,styleLine+styleThick);

//Plot(C,"",-1,64);

_SECTION_END();

CpCBL= C>CBL ;

//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

//TOMORROW'S PIVOTS

//Description:
//I had been struggling with the code to Plot todays pivots from yesterdays price
//when using an intraday database.There were none available in the Amibroker library
//which plotted correctly the pivots for tomorrow on a intraday database.
//I checked the Amibroker forum AND found the following. Thank you goes to sdebu_2k.
//If you wish to go to the forum search for "plotting tomorrow pivots".
//This routine provides todays quotes in the Title bar AND holds the todays pivots constant
//in the Title bar as well. The plotted pivots moves to the next Day
//when entering into the next Day. Absolutely brilliant! Thank you.
//PATRICK DOHERTY//
//SetChartOptions(0,chartShowArrows|chartShowDates);
//_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) Vol " +WriteVal( V, 1.0 ) +"
//{{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 )) ));
//Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );

//SetChartOptions(0,chartShowArrows | chartShowDates);

H1=SelectedValue( TimeFrameGetPrice( "H", inDaily, -1 ));
L1=SelectedValue(TimeFrameGetPrice( "L", inDaily, -1 ));
C1=SelectedValue(TimeFrameGetPrice( "C", inDaily, -1 ));
/*PIVOT Calculation*/

p = ( H1+ L1 + C1 )/3;
s1 = (2*p)-H1;
r1 = (2*p)-L1;
s2 = p -(H1 - L1);
s3 = S1 - (H1-L1);
r2 = p +(H1 - L1);
r3 = R1 +(H1-L1);


Plot (p,"\nPivot",25,styleDots+styleThick );
Plot (r1,"",12,1);
Plot (r2,"",12,1);
Plot (r3,"",12,1);
Plot (s1,"",3,1);
Plot (s2,"",3,1);
Plot (s3,"",3,1);
X=Cross(C,p);
Z=Cross(p,C);

//PlotShapes(IIf(X,shapeUpTriangle,shapeNone),colorAqua,0,Low,Offset=-20);
//PlotShapes(IIf(Z,shapeDownTriangle,shapeNone),colorPink,0,High,Offset=-20); 

PlotShapes(IIf(X,shapeUpTriangle,shapeNone),colorAqua,0,haLow,Offset=-20);
PlotShapes(IIf(Z,shapeDownTriangle,shapeNone),colorPink,0,haHigh,Offset=-20); 


//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx


//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

// RIBBON TMV BEGIN XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX


_SECTION_BEGIN("MultipleRibbon");
// You plot a Ribbon by calling the function as follows: MultiRibbon("Color", "Ribbon Number", "Name To Display");
// The "Ribbon Number" is simply the order of the ribbon, starting with 1 as the bottom Ribbon. You can add as many 
// ribbons as you want, until you run out of chart space. Just keep track of the 'Serial Number' (Ribbon Number). :-)


RibbonThickness	= Param("RibbonThickness", 5, 1, 15, 0.1);
Font				= ParamList("Font:","Arial|Calibri|Futura|Tahoma|Times New Roman");
"";
function GfxConvertBarToPixelX(Bar) 
{ 
 lvb = Status("lastvisiblebar"); fvb = Status("firstvisiblebar"); 
 pxchartleft = Status("pxchartleft"); pxchartwidth = Status("pxchartwidth"); 
 return pxchartleft + Bar  * pxchartwidth / (Lvb - fvb + 1); 
} 

procedure MultiRibbon(RibbonColor, Position, Label)
{
 LineColor	= colorLightGrey;
 Position	= RibbonThickness * Position;
 x2 = Status("pxchartright");
 y2 = Status("pxchartbottom");

 RibbonColor = IIf(GfxConvertBarToPixelX(BarIndex()-Status("firstvisiblebarindex")) > y2/1.5 * (RibbonThickness/100) * 18 ,
               RibbonColor, colorYellow);

 Plot(0, "", LineColor, styleOwnScale | styleNoLabel, 0, 100);
 Plot(Position, "", LineColor, styleOwnScale | styleNoLabel, 0, 100);
 Plot(Position, "", RibbonColor, styleArea | styleOwnScale | styleNoLabel, 0, 100);

 GfxSetTextColor(colorBlack); 
 GfxSelectFont(Font, y2/1.5 * (RibbonThickness/100), 400); 
 GfxDrawText(Label, 8, y2 * 1.001 -(y2 * Position/100) , y2/1.5 * (RibbonThickness/100) * 17, y2, 2 + 32 + 256);
 
}

//=================================================================================================================
//=================================================================================================================

//MACD

r1 = Param( "Fast avg", 12, 2, 200, 1 );
r2 = Param( "Slow avg", 26, 2, 200, 1 );
r3 = Param( "Signal avg", 9, 2, 200, 1 );
Hist= MACD()-Signal() ;
Histup= Hist>Ref(Hist,-1) ;
Histcolor= IIf(Hist>Ref(Hist,-1),colorLime,colorRed) ;
//Plot( MACD(),"MACD", colorLime,styleLine | styleThick) ;
//Plot( Signal(), "Signal", colorRed,styleLine|styleThick );
//Plot( hist, "Histogram", histcolor,styleHistogram|styleThick ) ;
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

//AROON OSCILLATOR

"The Aroon Oscillator indicates an upward trend when it is above zero and a downward trend when it is below zero.";
"The farther away the oscillator is from the zero line, the stronger the trend.";
/*
The Aroon indicator allows you to anticipate changes in security prices from trending to trading range.
The indicator uses two lines: Aroon Up AND Aroon Down. Aroon Down is a measure of how Close the current bar is
to the most recent Lowest Low bar found in the last N bars. Aroon Up is a measure of how Close the current bar is
to the most recent Highest High bar found in the last N bars. Additionally Aroon oscillator can be defined as
the difference between the Aroon Up AND Aroon Down indicators. 
Aroon indicator ranges from 0 to 100 AND it is drawn with additional 30/70 levels.
The default period is 14 days. The indicator works as follows: if a security makes a new 14-Day High,
the Aroon Up = 100; when the security makes a new 14-Day Low, the Aroon Down = 100;
when there was no new High in 14 days, the Aroon Up = 0; AND consequently 
when there was no new Low for 14 days, the Aroon Down = 0.
Aroon indicator is an another way (in addition to VHF AND ADX indicators) of detemining if market is trending OR NOT.
*/

AroonPer = Param("AroonPer",10,4,45,1);

AroonUp = 100 * (AroonPer - (HHVBars(H, AroonPer + 1))) / AroonPer;
AroonDn = 100 * (AroonPer - (LLVBars(L, AroonPer + 1))) / AroonPer;
AroonOsc = AroonUp - AroonDn;

//Plot(AroonOsc, "Aroon Oscillator("+AroonPer+")", IIf(AroonOsc > 0,colorLime,colorRed), styleHistogram| styleThick);
//PlotGrid(-50, colorBrown);
//PlotGrid(50, colorBrown);

AroonOscUp0= AroonOsc>0 ; 
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

//TRENDADVISOR

pointer[0] = 0;

/* Phase filter */

Cond1 = Close > MA(Close, 50)AND NOT(Close > MA(Close, 200))AND NOT(MA(Close, 50) > MA(Close, 200));
Cond2 = Close > MA(Close, 50)AND Close > MA(Close, 200)AND NOT(MA(Close, 50) > MA(Close, 200));
Cond3 = Close > MA(Close, 50)AND Close > MA(Close, 200)AND MA(Close, 50) > MA(Close, 200);
Cond4 = NOT(Close > MA(Close, 50))AND Close > MA(Close, 200)AND MA(Close, 50) > MA(Close, 200);
Cond5 = NOT(Close > MA(Close, 50))AND NOT(Close > MA(Close, 200))AND MA(Close, 50) > MA(Close, 200);
Cond6 = NOT(Close > MA(Close, 50))AND NOT(Close > MA(Close, 200))AND NOT(MA(Close, 50) > MA(Close, 200));

for (i = 1; i < BarCount; i++)
{

  if (Cond1[i])
    pointer[i] = 1;
  if (Cond2[i])
    pointer[i] = 2;
  if (Cond3[i])
    pointer[i] = 3;
  if (Cond4[i])
    pointer[i] = 4;
  if (Cond5[i])
    pointer[i] = 5;
  if (Cond6[i])
    pointer[i] = 6;

}

/* Plot Graphic */
//GraphXSpace= 15 ;
dynamic_color = IIf(pointer < 4, colorGreen, colorRed);
//Plot(pointer, "TrendAdv2", dynamic_color, styleHistogram | styleThick, Null, Null, 0);
//SetChartBkGradientFill(ParamColor("BgTop", colorWhite), ParamColor("BgBottom", colorLightYellow));

Cond= pointer<4 ;
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX HEIKIN ASHI EXACT FORMULA BEGIN DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD

_SECTION_BEGIN("HA Looping ( no AMA() )");
//SetChartOptions(0,chartShowArrows|chartShowDates);
///////////////////////////////////////////////////////////
//
// Heikin Ashi - Calculated Properly with no use of AMA
//
// JF Derzi, December 2012
//
//

HaClose[0] = (Open[0]+High[0]+Low[0]+Close[0]) / 4;
HaOpen[0]  = (HaClose[0] + Open[0]) / 2;
HaHigh[0]  = Max( High[0], Max( HaClose[0], HaOpen[0] ) );
HaLow[0]   = Min( Low[0], Min( HaClose[0], HaOpen[0] ) );

for (i=1; i<BarCount; i++)
	{
	HaClose[i] = (Open[i]+High[i]+Low[i]+Close[i]) / 4;
	Haopen[i]  = (HaClose[i-1] + HaOpen[i-1]) / 2; // Here is the problem when using Arrays: Haopen always uses its own previous value
	HaHigh[i]  = Max( High[i], Max( HaClose[i], HaOpen[i] ) );
	Halow[i]   = Min( Low[i], Min( HaClose[i], HaOpen[i] ) );
}

//PlotOHLC( HaOpen, HaHigh, HaLow, HaClose, "HA", colorBlack, styleCandle );

//barcolorha = IIf(HaClose>=HaOpen,colorGreen,colorRed);
//SetBarFillColor(IIf(HaClose>=HaOpen,colorGreen,colorRed));
//PlotOHLC( HaOpen, HaHigh, HaLow, HaClose, "\nHeikinAshiDerzi", barcolorha, styleCandle );

//Title = Name()+" "+Date()+" Heikin Ashi -- HaOpen:"+NumToStr(HaOpen,1.2,True)+" / HaHigh:"+NumToStr(HaHigh,1.2,True)+
//        " / HaLow:"+NumToStr(Halow,1.2,True)+" HaClose:"+NumToStr(Haclose,1.2, True);

_SECTION_END();

HAup= HaClose>=HaOpen ;
haDelta= HaClose-HaOpen ;
MAhaDelta= MA(haDelta,3) ;
haDeltaUpMA= haDelta>MA(haDelta,3) ;
MyHAup= (Hadelta>MA(Hadelta,3) OR MA(Hadelta,3)>0) ;

//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXHEIKIN ASHI EXACT FORMULA END DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD

//BB HISTOGRAM

_SECTION_BEGIN("BB Histogram");
bbhist=((C+2*StDev(C,20) - MA(C,18)) / ((4*StDev(C,18)))*4) - 2;
//Plot(bbhist, "BBands Histogram", IIf(bbhist > 0, colorLime, colorRed),styleHistogram + styleThick);
//Plot(0,"",colorBrown) ;
_SECTION_END();
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

//VOLATILITY RATIO

//n = Param("movn",10,1,50,1);
nTSM = Param("TSMper",9,5,34,1,0) ;
nMATSM = Param("MATSMper",3,3,17,1,0) ;
ratio = C / Ref(C,-1);
natlog = log(ratio);
TSMVolatilityRatio = MA(natlog, nTSM);
MATSM = MA(TSMVolatilityRatio,nMATSM) ;
//Plot(TSMVolatilityRatio, "VolatilityRatio", colorRed,styleLine);
//Plot(0,"",colorBrown) ;
//Plot(MATSM,"MATSM",colorBlue) ;
//TSMup= TSMVolatilityRatio>0 AND TSMVolatilityRatio>MA(TSMVolatilityRatio,nMATSM) ;
TSMup0= TSMVolatilityRatio>0 ;
TSMupMATSM= TSMVolatilityRatio>MA(natlog, nTSM);

//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 

//DISPARITY INDEX

_SECTION_BEGIN("DiparityIndex");
DI = ParamField("Price field",-1);
PdsDI = Param("Per", 10, 1, 200, 1, 10 );
//emadispper= Param("EMAPer",3,3,34,1,0) ;

DisparityIndex  = (DI - EMA(DI,pdsDI))/ EMA(DI,pdsDI);
//EMAdispindex= EMA(disparityindex,emadispper) ;
//Plot( DisparityIndex , _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") );
//Plot( DisparityIndex ,"\nDiparityIndex", colorRed, ParamStyle("Style") );
//Plot(EMAdispindex,"\nEMADispIndex",colorBlue) ;
//Plot(0,"",colorBrown) ;

DisparityIndexUp0  = (DI - EMA(DI,pdsDI))/ EMA(DI,pdsDI)>0 ;

//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

//GRAPHIC MODIFIED BULL&BEAR VOLUME CHYNTHIA

_SECTION_BEGIN("BullBearVolume");
 
C1 = Ref(C, -1);
uc = C > C1; dc = C <= C1;
ud = C > O; dd = C <= O;
 
green = 1; blue = 2; yellow = 3; red = 4; white = 5;

VType = IIf(ud,             
            IIf(uc, green, yellow),
         IIf(dd, 
            IIf(dc, red, blue), white));
 
 
gv = IIf(VType == green, V, 0); 
yv = IIf(VType == yellow, V, 0); 
rv = IIf(VType == red, V, 0); 
bv = IIf(VType == blue, V, 0); 
 
uv = gv + bv; uv1 = Ref(uv, -1); /* up volume */
dv = rv + yv; dv1 = Ref(dv, -1); /* down volume */
 
/* create moving average period parameters */
VolPer = Param("Adjust Vol. MA per.", 21, 1, 255, 1);
ConvPer = Param("Adjust Conv. MA per.", 7, 1, 255, 1);
 
/* create triple exponential moving avearges of separate up and down volume moving averages */
MAuv = TEMA(uv, VolPer ); mauv1 = Ref(mauv, -1);
MAdv = TEMA(dv, VolPer ); madv1 = Ref(madv, -1);
MAtv = TEMA(V, VolPer );//total volume
 
/* Switch for Horizontal lines indicating current level of positive and negative volume
    for ease in comparing to past highs/lows - toggle via parmameter window */
OscillatorOnly = Param("ShowOscillatorOnly", 0, 0, 1, 1);
CompareBullVolume = Param("ShowBullLevel", 1, 0, 1, 1);
if(CompareBullvolume AND !OscillatorOnly){
//Plot(SelectedValue(MAuv), "", colorGreen, styleLine);
}
 
CompareBearVolume = Param("ShowBearLevel", 1, 0, 1, 1);
if(CompareBearVolume AND !OscillatorOnly){
//Plot(SelectedValue(MAdv), "", colorRed, styleLine);
}
 
/* Volume Segment Switches - toggle via parameter window */
bullvolume = Param("ShowBullVolume", 1, 0, 1, 1);
bearvolume = Param("ShowBearVolume", 1, 0, 1, 1);
totalvolume = Param("ShowTEMA(TotalVolume)", 1, 0, 1, 1);
 
/* plot volume lines and histograms if toggled on: */
bearToFront = Param("ShowBearVolinFront", 0, 0, 1, 1);
if(bearToFront AND !OscillatorOnly){
//Plot(MAdv, "", colorRed, styleNoLabel);
}
if(bullvolume AND !OscillatorOnly){
//Plot(MAuv, "AverageBullVolume", colorGreen, styleThick+styleNoLabel);
}
if(bearvolume AND !OscillatorOnly){
//Plot(MAdv, "AverageBearVolume", colorRed, styleThick+styleNoLabel);
}
if(bearvolume AND !OscillatorOnly){
//Plot(MAdv, "", colorOrange, styleNoLabel);
//PlotOHLC( 0 , MAdv , 0 , MAdv , "", colorOrange, styleCloud | styleNoRescale|styleNoLabel);

}
if(bullvolume AND !OscillatorOnly){
//Plot(MAuv, "", colorLime, styleNoLabel);
//PlotOHLC( 0 , MAuv , O ,MAuv , "", colorLime, styleCloud | styleNoRescale|styleNoLabel);

}
if(totalVolume AND !OscillatorOnly){
//Plot(MAtv, "TEMA(TotalVolume)", colorLightBlue );
//PlotOHLC( 0 , MAtv , 0 , MAtv , "", colorLightBlue, styleCloud | styleNoRescale|styleNoLabel);
 
}

/*
Buy=Cross(MAuv,MAdv);
Sell=Cross(MAdv,MAuv);
PlotShapes(IIf(Buy,shapeUpArrow,shapeNone) ,colorBlue);
PlotShapes(IIf(Sell,shapeDownArrow,shapeNone),colorRed);
Filter=Buy OR Sell;
Buy=ExRem(Buy,Sell); Sell=ExRem(Sell,Buy);
*/

//AddColumn(Close,"Close");AddColumn(Volume,"Total Volume");AddColumn(Buy,"Buy"); AddColumn(Sell,"sell"); 
 
/* better visibility of zero line: */
//Plot(0, "", colorViolet, 1);
 
/* Rise/Fall Convergence variables:  */
Converge = (TEMA(MAuv - MAdv, ConvPer));
Converge1 = Ref(Converge, -1);
ConvergeUp = Converge > Converge1;
ConvergeOver = Converge > 0;
rising = ConvergeUp AND ConvergeOver;
falling = !ConvergeUp AND ConvergeOver;
 
/* Rise/Fall Convergence Oscillator Switch  - toggle via parameter window - (provides a better view
      of resulting combination of battling bull/bear volume forces) */
convergenceOscillator = Param("Show Oscillator", 0, 0, 1, 1);
if(convergenceOscillator OR OscillatorOnly){
//Plot(Converge, "AmimalsWar", colorBrown, 1|styleLeftAxisScale|styleNoLabel|styleThick);
//Plot(0,"", colorViolet, 1|styleLeftAxisScale|styleNoLabel);
}
 
/********************************************************
 Convergence Rise/Fall Shadows: 
 
 (provides a more easily visible display of rising and falling  bull/bear volume convergence) - toggle via parameter window 
 
-posiitive Volume exceeding negative Volume: Light shadow
-negative volume exceeding positive volume: dark shadow
-if you use standard gray background - best shadows are:
-my greys: 14 = (216, 216, 216); 15 = (168, 168, 168));
-best substitute? using AB color constants?
-light: colorpalegreen; dark: colorRose;? 
-(depends on your color scheme - customize to your tastes)
**********************************************************/
 
/* uncomment if you use my custom color greys: */
riseFallColor = IIf(rising, colorLime,colorOrange); //my custom shadow greys
 
/* comment out if you use my custom color gray shadows: */
/* riseFallColor = IIf(rising, colorPaleGreen,colorRose); */
 
/* Rise/Fall Convergence Plot Switch - toggle via parameter window */
riseFallShadows = Param("ShowRiseFallShadows", 0, 0, 1, 1);
if(riseFallShadows){
//Plot(IIf(rising OR falling, 1, 0), "", riseFallColor, styleArea|styleOwnScale|styleNoLabel);
}
GraphXSpace = 0.5;
_SECTION_END();

/*
_SECTION_BEGIN("Background");
	SetChartBkColor(ParamColor("Outer panel",colorBlack)); // color of outer border 
	SetChartBkGradientFill( ParamColor("Inner panel upper",colorBlack),ParamColor("Inner panel lower",colorBlack));
	tchoice=Param("Title Selection ",2,1,2,1);
_SECTION_END();
*/

BullV= MAuv>MAdv ;

mauvup= mauv>Ref(mauv,-1) ;
madvdn= madv<Ref(madv,-1) ;

mfiupma7= MFI()>MA(MFI(),7) ;

Vup= mfiupma7 AND bullv ;
Vorup= mfiupma7 OR bullv ;

Vdn= !mfiupma7 AND !bullv ;
Vordn= !mfiupma7 OR !bullv ;

Vtotup= mfiupma7 AND bullv AND mauvup AND madvdn ;
Vtotorup= (mfiupma7 OR bullv OR (mauvup AND madvdn)) ;

Vtotdn= !mfiupma7 AND !bullv AND !mauvup AND !madvdn ;
Vtotordn= (!mfiupma7 OR !bullv OR (!mauvup AND !madvdn)) ;

//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

//FORMULE
Uptrend= (MACD()>Signal() AND PDI()>MDI()) ; 
Dntrend= (MACD()<Signal() AND PDI()<MDI()) ;   
stochup= StochK()>StochD() ;
stochdn80= StochK()<80 ;
stochup20= StochK()>20 ;
MACDup= MACD()>Signal() ;
MACDup0= MACD()>0 ;
Hist= MACD()-Signal() ;
Histup= Hist>Ref(Hist,-1) ;
MFIupma7= MFI()>MA(MFI(),7) ;
MFIup25= MFI()>25 ;
MFIdn88= MFI()<88 ;
Cupo= C>O ;
CCIup0= CCI()>0 ;
CCIupMA7= CCI()>MA(CCI(),7) ;
CCIdn290= CCI()<290 ;
MA20up= MA(C,20)>=Ref(MA(C,20),-1) ;
MA50up= MA(C,50)>=Ref(MA(C,50),-1) ;
Cupma20= C>MA(C,20) ;
Cupma50= C>MA(C,50) ;
PDIupmdi= PDI()>MDI() ;
PDIdif= PDI()-MDI() ;
PDIdifup= pdidif>=Ref(pdidif,-1) ;
PDIup20= PDI()>20 ;
ADXup20= ADX()>20 ;
RSIup50= RSI()>50 ;
RSIupMA7= RSI()>MA(RSI(),7) ;
Cond= pointer<4 ;
haup= HaClose>=HaOpen ;
top1up= BBandTop(C,20,1)>=Ref(BBandTop(C,20,1),-1) ;
top2up= BBandTop(C,20,2)>=Ref(BBandTop(C,20,2),-1) ;
Cuptop1= C>BBandTop(C,20,1) ;
Vup= (MFI()>MA(MFI(),7) AND mauv>madv) ;
Vorup= (MFI()>MA(MFI(),7) OR mauv>madv) ;
Vdn= (MFI()<MA(MFI(),7) AND mauv<madv) ;
Vordn= (MFI()<MA(MFI(),7) OR mauv<madv) ;
ADXup18= ADX()>18 ;
ADXup= ADX()>=Ref(ADX(),-1) ;

//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx


//YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
//YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY

//RIBBONS TREND MOMENTUM VOLUME

//R8=========================== TREND ===============================================================

r1 = IIf( uptrend ,colorBrightGreen , 
     IIf( dntrend , colorPink ,colorLavender ) ) ;
//---------------------------------------------------------------------------------------------------

//R1=========================== MOMENTUM ============================================================

r2 = IIf( rsiupma7 AND RSIup50 OR cciupma7 AND cciup0 ,colorBrightGreen , 
     IIf( !rsiupma7 AND !rsiup50 AND stochdn80 OR !cciupma7 AND !cciup0 AND stochdn80, colorPink , colorLavender ) ) ;  

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


//R1=========================== VOLUME =======================================================================================================

r3 = IIf( mfiupma7 AND bullv ,colorBrightGreen , 
     IIf( !mfiupma7 AND !bullv, colorPink ,colorLavender ) ) ;      

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

tdverde= uptrend ;
tdrosu= dntrend ;
tdalb= NOT tdverde AND NOT tdrosu ;

momverde= rsiupma7 AND rsiup50 OR cciupma7 AND cciup0 ;
momrosu= ( !rsiupma7 AND !rsiup50 AND stochdn80 OR !cciupma7 AND !cciup0 AND stochdn80 ) ;
momalb= NOT momverde AND NOT momrosu ;

volumeverde= ( mfiupma7 AND bullv ) ;
volumerosu= ( !mfiupma7 AND !bullv ) ;
volumealb= NOT volumeverde AND NOT volumerosu ;

BuyRibbTMV= ((tdverde OR tdalb) AND (momverde OR momalb) AND (volumeverde OR volumealb)) ;
SellRibbTMV= ((tdrosu OR tdalb) AND (momrosu OR momalb) AND (volumerosu OR volumealb)) ;
             
//YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
//YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY



/*

//R8======================================== 1 EXCES ==========================================================

r1 = IIf( ADX()<49 AND ADX()>18 AND MFI()<88 AND MFI()>25 AND StochK()>20 AND CCI()<290  ,colorgreen, colorRed ) ;
//---------------------------------------------------------------------------------------------------------

//R1========================================== 2 BUYSTOP ===========================

r2 = IIf (buystopnew ,colorGreen,colorRed ) ;    

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

//R1========================================== 3 MACD ===========================

r3 = IIf (macdup ,colorGreen,colorRed) ;    

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

//R5======================================== 4 PDIupMDI ==============================

r4 = IIf(PDIupMDI ,colorGreen,colorRed); 
//-----------------------------------------------------------------------------------------------

//R7======================================== 5 AROON OSCILLATOR ==============================

r5= IIf(AroonOscUp0, colorGreen,colorRed);

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

//R10======================================== 6 TREND ADVISER ==============================

r6 = IIf(COND, colorGreen,colorRed);
//-------------------------------------------------------------------------------- 

//R2============================================ 7 STOCH =======================

r7 = IIf (stochup ,colorGreen, colorRed);

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

//R3======================================== 8 CCI ==============================

r8 = IIf(CCIupMA7 ,colorGreen,colorRed) ;
          
//-----------------------------------------------------------------------------------------------

//R5======================================== 9 RSI ==============================

r9 = IIf (RSIupMA7 ,colorGreen,colorRed); 
//-------------------------------------------------------------------------------------------

//R6======================================== 10 MFI =======================================

r10 = IIf ( MFIupMA7 ,colorGreen,colorRed);        
//--------------------------------------------------------------------------------

//R6======================================== 11 BULLBEARVOLUME =======================================

r11 = IIf (CpBullV ,colorGreen,colorRed);        
//--------------------------------------------------------------------------------

//R4======================================== 10 Volatility ==============================

//r10= IIf (TSMup0  ,colorGreen,colorRed);   

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

//R10======================================== 8 HEIKIN-ASHI ==============================

//r8 = IIf(HAup AND haDeltaUpMA3, colorGreen,colorRed);
//--------------------------------------------------------------------------------

//R6======================================== 12 TrendPVT =======================================

//r12 = IIf (Q>S ,colorGreen,colorRed);        
//--------------------------------------------------------------------------------

//R5============================================ TREND SCORE =======================

//r5 = IIf (TrendScore>7,colorGreen,
//     IIf(TrendScore<0,colorRed,colorTan)); 

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

//R9======================================== BuyVSTOP2 ==============================

//r9 = IIf(buystopnew AND macdup,colorGreen,colorRed); 
//--------------------------------------------------------------------------------

//R8======================================== BullBearVolume ==============================

//r8 = IIf(MAuv>MAdv,colorBrown,colorRose);
//------------------------------------------------------------------------------------

//R5======================================== UpTrend ==============================

//r5 = IIf (MACD()>Signal() AND PDI()>MDI() AND ADX()>16 AND ADX()<51,colorGreen,colorRed); 
//-------------------------------------------------------------------------------------------


//R10======================================== LimSup ==============================

//r10 = IIf(ADX()<50 AND CCI()<300 AND MFI()<90,colorGreen,colorRed);
//--------------------------------------------------------------------------------

//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

//MultiRibbon( r13,  1,  "Exces");
//MultiRibbon( r12,  2,  "TrendPVT"); 
MultiRibbon( r11,  1,  "BULLVOLUME");
MultiRibbon( r10,  2,  "MFI");
MultiRibbon( r9,   3,  "RSI"); 
MultiRibbon( r8,   4,  "CCI"); 
MultiRibbon( r7,   5,  "STOCH"); 
MultiRibbon( r6,   6,  "TRENDADVISER"); 
MultiRibbon( r5,   7,  "AROON"); 
MultiRibbon( r4,   8, "PDIupMDI"); 
MultiRibbon( r3,   9, "MACD");
MultiRibbon( r2,   10, "BUYSTOP"); 
MultiRibbon( r1,   11, "EXCES"); 
//MultiRibbon( r1,   9, "BuyVSTOP2(1)"); 

/*
//==================interpretation============================

WriteIf(EMA( Close,13)>EMA( Close,39),"EMA says : UP TREND \n EMA -50 SL of "+ WriteVal(EMA(Close,50)),
       "EMA says : DOWN TREND \n  EMA "+ WriteVal(EMA(Close,50)));
WriteIf (Trix( 9 ) > Ref( Trix( 9 ) , -1 ),"\n TRIX =" + WriteVal(Trix( 9 ))+ " : UP","\n TRIX =" + WriteVal(Trix( 9 ))+"   : DOWN");
WriteIf (MACD( 12, 26 ) > Ref( MACD( 12, 26 ) , -1 ), "MACD ="+ WriteVal(MACD( 12, 26 ))+ " :
        UP","MACD ="+ WriteVal(MACD( 12, 26 ))+ " : DOWN");
WriteIf(ADX( 9 ) > Ref( ADX( 9 ) , -1 ),"ADX ="+WriteVal (ADX(9))+"   :TREND-ING","ADX ="+WriteVal (ADX(9))+"   : ----");
WriteIf (RSI( 7 ) > Ref( RSI(7) , -1 ), "RSI ="+ WriteVal(RSI( 7))+ " : UP","RSI ="+ WriteVal(RSI( 7))+ " : DOWN");
WriteIf (CCI( 10 ) > Ref( CCI(10) , -1 ), "CCI ="+ WriteVal(CCI( 10))+ " : UP","CCI ="+ WriteVal(CCI( 10))+ " : DOWN");
WriteIf(StochK( 14)< Ref (StochK( 14),1) ,"stochastic ="+WriteVal (StochK(14))+" : UP " ,"stochastic =
        "+WriteVal (StochK( 14))+" : DOWN ");
"";
WriteIf (Close > SAR( 0.02, 0.2 ),"SAR says : go LONG at "+Close+" \n with a Stop-Loss = " + WriteVal(  SAR( 0.02, 0.2 )),
        "SAR says : go Short at "+Close+"\n with a Stop-Loss = " + WriteVal(  SAR( 0.02, 0.2 )));
*/
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

/* DUS JOS DE TOT
MultiRibbon( r3,   1, "VOLUME"); 
MultiRibbon( r2,   2, "MOMENTUM"); 
MultiRibbon( r1,   3, "TREND"); 
*/


//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

// RIBBON TMV END XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX


//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

//FORMULE
stochup=  StochK()>StochD()  ;
stochupmy= ( StochK()>StochD() OR StochK()>80) ;
stochmydn= ( StochK()<StochD() AND StochK()<80) ;
stochdn80= StochK()<80 ;
stochup19= StochK()>19 ;
MACDup= MACD()>Signal() ;
MACDup0= MACD()>0 ;
Hist= MACD()-Signal() ;
Histup= Hist>Ref(Hist,-1) ;
MFIupma7= MFI()>MA(MFI(),7) ;
MFIdn80= MFI()<80 ;
MFIup50= MFI()>50 ;
MFIup30= MFI()>30 ;
Cupo= C>O ;
Cup= ( C>=O AND C>Ref(C,-1) ) ;
CCIup0= CCI()>0 ;
CCIupMA7= CCI()>MA(CCI(),7) ;
CCIMA7up= MA(CCI(),7)>Ref(MA(CCI(),7),-1) ;
MA20up= MA(C,20)>=Ref(MA(C,20),-1) ;
MA10upMA15= MA(C,10)>MA(C,15) ;
MA5upma10= MA(C,5)>MA(C,10) ;
EMA50up= (EMA(C,50)>=Ref(EMA(C,50),-1) OR C>=EMA(C,50)) ;
Cupma20= C>MA(C,20) ;
Cupma50= C>MA(C,50) ;
PDIupmdi= PDI()>MDI() ;
PDIup20= PDI()>20 ;
PDIup18= PDI()>18 ;
Uptrend=  (MACD()>Signal() AND PDI()>MDI()) ;
Uportrend=  (MACD()>Signal() OR PDI()>MDI())   ;
Dntrend=  (MACD()<Signal() AND PDI()<MDI())   ;
Dnortrend=  (MACD()<Signal() OR PDI()<MDI())   ;
ADX50= ADX()<50 ;
ADXup18= ADX()>18 ;
LimADX= ( ADX()<49 AND ADX()>18 ) ;
HAup= haClose>=haOpen ;
CupSAR= C>SAR(0.02,0.2) ;
RSIup50= RSI()>50 ;
RSIupMA7= RSI()>MA(RSI(),7) ;
RSIMA7up= MA(RSI(),7)>Ref(MA(RSI(),7),-1) ;
CupSAR= C>SAR() ;

tsltotup= (buystopnew AND cpclear AND cpHL AND cpCBL) ;
tsltotorup= (buystopnew OR cpclear OR cpHL OR cpCBL) ;

tsltotdn= (!buystopnew AND vdclear AND !cpHL AND !cpcbl) ;
tsltotordn= (!buystopnew OR vdclear OR !cpHL OR !cpcbl) ;

tslcombup= (buystopnew AND (cpclear OR cpHL OR cpCBL) OR (cpclear AND cpHL AND cpCBL)) ;
tslcombdn= (!buystopnew AND (vdclear OR !cpHL OR !cpCBL) OR (vdclear AND !cpHL AND !cpCBL)) ;

tsl2up= (buystopnew AND (cpclear OR cpHL OR cpCBL) OR cpclear AND (cpHL OR cpCBL) OR cpHL AND cpCBL) ;
tsl2dn= (!buystopnew AND (vdclear OR !cpHL OR !cpCBL) OR vdclear AND (!cpHL OR !cpCBL) OR !cpHL AND !cpCBL) ;

BSor3up= (buystopnew OR (cpclear AND cpHL AND cpCBL)) ;
BSor3dn= (!buystopnew OR (vdclear AND !cpHL AND !cpCBL)) ;

buttdup= (macdup0 AND pdiupmdi AND ((cciup0 AND cciupma7) OR rsiup50 AND rsiupma7)) ;
momup= (cciup0 AND cciupma7 OR rsiup50 AND rsiupma7) ;

StrongUp= (Cross(MACD(),Signal()) OR Cross(C,trailARRAY) OR Cross(upswa ,0) OR Cross(C,trailHL) OR Cross(C,CBL) OR Cross(C,bbmid) OR
            Cross(upcond,dncond) OR Cross(upcond,NOT dncond) OR Cross(NOT upcond,dncond)) ;
StrongDn= (Cross(Signal(),MACD()) OR Cross(trailARRAY,C) OR Cross(1,upswa) OR Cross(trailHL,C) OR Cross(CBL,C) OR Cross(bbmid,C)) ;

CpSig= macdup AND histup AND (pdiup20 OR adxup18) AND (cciup0 OR rsiup50) AND (cciupma7 OR rsiupma7) ;
//PlotShapes(IIf(Cross(MACD(),Signal()) AND cpsig,shapeUpTriangle,shapeNone),colorGreen ,0,haLow,Offset=-20);

//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

/*
PlotShapes(IIf(stochdn80 AND tsltotordn AND !stochup AND !histup AND ( !macdup OR dnorv ),
           shapeDownTriangle,shapeNone),colorBlack ,0,haHigh,Offset=-20);
           */
               
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

//PARAMTOGGLE
/*
// This combines indicators into one timing Signal
//function ParamOptimize( description, default, minv, maxv, step )
//    { return Optimize(description, Param(description,default, minv, maxv, step ), minv, maxv, step ); }
tgl = ParamToggle("Result", "AND logic|Compare");
// switch test calculation and compare the results
if(tgl)
{
myBuy =  (upcond OR macdup AND NOT dncond) AND haup AND tsl2up ;
myShort = dncond OR
          tslcombdn AND (!macdup OR stochdn80) AND !haup AND vordn ; 
}
else
{

myBuy   = IIf( ((C>bbmid AND bbdifup) OR MACD()>Signal() AND NOT C<bbmid) AND haClose>=haOpen AND
                         (buystopnew AND (cpclear OR cpHL OR cpCBL) OR cpclear AND (cpHL OR cpCBL) OR cpHL AND cpCBL)    ,1,0); 
myShort = IIf( C<bbmid OR
               (!buystopnew AND (vdclear OR !cpHL OR !cpCBL) OR (vdclear AND !cpHL AND !cpCBL)) AND
                            (MACD()<Signal() OR StochK()<80) AND haClose<haOpen AND (MFI()<MA(MFI(),7) OR mauv<madv)    ,1,0);
} 

Buy = ExRem(myBuy, myShort) ;
Sell = ExRem(myShort, myBuy) ;
*/

//Buy= Cross(mybuy,myshort) ;
//Sell= Cross(myshort,mybuy) ;

Buy =  (upcond OR NOT dncond OR uptrend) AND macdup AND histup AND stochup AND haup AND hadeltaupma AND tslcombup ;
Sell = dncond OR
       tslcombdn AND (!macdup OR stochdn80) AND !haup AND vordn ; 

Buy = ExRem(Buy,Sell ) ;
Sell = ExRem(Sell,Buy ) ;

/*
StrongBuy = Buy AND (Cross(MACD(),Signal()) OR Cross(C,bbmid)) AND macdup AND vorup AND hadeltaupma AND stochup AND histup AND cupo OR
            Buy AND (Cross(CCI(),MA(CCI(),7)) AND cciup0 OR Cross(RSI(),MA(RSI(),7)) AND rsiup50) AND
                    macdup AND vorup AND hadeltaupma AND stochup AND histup AND cupo OR
            Buy AND (Cross(upcond,dncond) OR Cross((NOT dncond AND NOT upcond),dncond)) AND
                    macdup AND vorup AND hadeltaupma AND stochup AND histup AND cupo ;
MediumBuy = Buy AND macdup AND histup AND hadeltaupma AND stochup AND histup AND cupo ;   
WeakBuy = Buy ;

StrongSell = Sell AND (Cross(Signal(),MACD()) OR Cross(80,StochK()) AND !macdup) AND vordn AND NOT uptrend OR
             Sell AND (Cross(madv,mauv) OR Cross(MA(MFI(),7),MFI())) AND vdn AND !macdup AND NOT uptrend OR
             Sell AND Cross(bbmid,C) AND stochdn80 AND vordn OR
             Sell AND (Cross(trailARRAY,C) OR Cross(1,upswa) OR Cross(trailHL,C) OR Cross(CBL,C)) ;
MediumSell = Sell AND !histup AND (stochdn80 OR tslcombdn) AND NOT uptrend ;   
WeakSell = Sell ;
*/

StrongBuy = Buy AND momup AND vorup ;
MediumBuy = Buy AND momup ;   
WeakBuy = Buy ;

StrongSell = Sell AND stochdn80 AND vordn AND NOT uptrend ;
MediumSell = Sell AND (stochdn80 OR vordn) AND NOT uptrend ;   
WeakSell = Sell ;

PlotShapes(IIf(StrongBuy,shapeUpTriangle,shapeNone),colorBlue,0,haLow,Offset=-10);
PlotShapes(IIf(MediumBuy,shapeUpArrow,shapeNone),colorBlue,0,haLow,Offset=-10);
PlotShapes(IIf(WeakBuy,shapeHollowUpArrow,shapeNone),colorBlue,0,haLow,Offset=-10);
PlotShapes(IIf(StrongSell,shapeDownTriangle,shapeNone),colorRed,0,haHigh,Offset=-10);
PlotShapes(IIf(MediumSell,shapeDownArrow,shapeNone),colorRed,0,haHigh,Offset=-10);
PlotShapes(IIf(WeakSell,shapeHollowDownArrow,shapeNone),colorRed,0,haHigh,Offset=-10);


/*
PlotShapes(IIf(StrongBuy,shapeUpTriangle,shapeNone),colorBlue,0,Low,Offset=-20);
PlotShapes(IIf(MediumBuy,shapeUpArrow,shapeNone),colorBlue,0,Low,Offset=-20);
PlotShapes(IIf(WeakBuy,shapeHollowUpArrow,shapeNone),colorBlue,0,Low,Offset=-20);
PlotShapes(IIf(StrongSell,shapeDownTriangle,shapeNone),colorRed,0,High,Offset=-20);
PlotShapes(IIf(MediumSell,shapeDownArrow,shapeNone),colorRed,0,High,Offset=-20);
PlotShapes(IIf(WeakSell,shapeHollowDownArrow,shapeNone),colorRed,0,High,Offset=-20);
*/

//PlotShapes(IIf(Buy,shapeUpArrow,shapeNone),colorBlue,0,haLow,Offset=-10);
//PlotShapes(IIf(Sell,shapeDownArrow,shapeNone),colorRed,0,haHigh,Offset=-10);

//PlotShapes(IIf(Buy,shapeUpArrow,shapeNone),colorBlue,0,trailArray);
//PlotShapes(IIf(Sell,shapeDownArrow,shapeNone),colorRed,0,trailArray);

//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

// BB AREA COLOR
/*
bbcol= IIf( bdifup  ,colorAqua,colorPink) ;

//PlotOHLC( btop, btop, bbot, bbot, "", colorYellow,styleCloud );
PlotOHLC( btop, btop, bbot, bbot, "", bbcol,styleCloud );
*/

bbareacol= IIf(upcond ,colorAqua ,
           IIf(dncond,colorPink ,colorWhite ) ) ;
           
PlotOHLC( bbtop, bbtop, bbbot, bbbot, "", bbareacol,styleCloud );

//PlotShapes(IIf(Cross(NOT dncond,dncond) OR Cross(upcond,NOT dncond) OR Cross(upcond,dncond),shapeUpTriangle,shapeNone),colorBrown,0,haLow,Offset=-20);

//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

MultiRibbon( r3,   1, "VOLUME"); 
MultiRibbon( r2,   2, "MOMENTUM"); 
MultiRibbon( r1,   3, "TREND"); 

//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

















5. chetan ninganiya

@morgen thanks a lot, sir. Is there a way I can contact other then wisestocktrader ?

Leave Comment

Please login here to leave a comment.

Back