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

Double Weighted Moving Average for Amibroker (AFL)

Rating:
5 / 5 (Votes 1)
Tags:
moving average, amibroker

This is Double Weighted Moving Average (DWMA), like DEMA

DWMA can be used for Hull Moving Average Cross Over Strategies, like how Jurik is using DWMA for Cross Overs

Screenshots

Indicator / Formula

Copy & Paste Friendly

Apply to Price Chart

//////////////////////////////////////////////////////////////////

_SECTION_BEGIN("Chart Settings");
   
OUTcolor = ParamColor("Outer Panel Color",ColorRGB(25, 25, 25));
IINUPcolor = ParamColor("Inner Panel Upper",ColorRGB(45, 45, 45));  
INDNcolor = ParamColor("Inner Panel Lower",ColorRGB(45, 45, 45));
TitleColor = ParamColor("Title Color ",ColorRGB(25, 25, 25));

SetChartOptions(0,chartShowDates|chartShowArrows);

stn= Param("Digit Length",10,1,40,1);
td=1.2;//String Decimals
TickSz = 0.05; 

GraphXSpace=10;

_SECTION_END();

//////////////////////////////////////////////////////////////////

_SECTION_BEGIN("Background Text");

C11=ParamColor("up panel",ColorRGB(25, 25, 25));  
C12=ParamColor("dn panel",ColorRGB(25, 25, 25) );
C13=Param("fonts",20,10,50,1 );
C14=Param("left-right",2.1,1.0,5.0,0.1 );
C15=Param("up-down",8,1,30,1 );
Miny = Status("axisminy");
Maxy = Status("axismaxy");
lvb = Status("lastvisiblebar");
fvb = Status("firstvisiblebar");
pxwidth = Status("pxwidth");
pxheight = Status("pxheight");
GfxSetBkMode( 0 ); 
GfxSelectFont("Verdana", 12, 500, False, False, 0);
GfxSetTextColor(ColorRGB(34, 34, 34));
GfxSetTextAlign( 6 );

pricechange=(C-Ref(C,-1))*100/Ref(C,-1);
changeponit=C-Ref(C,-1);
Vlp=Param("Volume lookback period",15,10,300,10);
Vrg=MA(V,Vlp);
St = StDev(Vrg,Vlp); 
Vp3 = Vrg + 3*st; 
Vp2 = Vrg + 2*st;;
Vp1 = Vrg + 1*st;;
Vn1 = Vrg -1*st; 
Vn2 = Vrg -2*st; 

x=Param("xposn",1,0,1000,1);
y=Param("yposn",1,0,1000,1);
 
GfxGradientRect( 1, 1, 2000, 60, ColorRGB(25, 25, 25), ColorRGB(25, 25, 25));GfxSetBkMode(0);

_SECTION_END();

//////////////////////////////////////////////////////////////////

_SECTION_BEGIN("Name, Date & Time");

GfxSelectFont( "Verdana", 16, 600, False );
GfxSetTextColor( colorRGB(251,251,0));
GfxTextOut( Name(), x+150, y+10);

GfxSelectFont( "Verdana", 14, 600, False );
GfxSetTextColor(colorRGB(255,255,255));
GfxTextOut( Date(), x+400, y+10 );

_SECTION_END();

//////////////////////////////////////////////////////////////////

_SECTION_BEGIN("Time Left");

function GetSecondNum()
{
Time = Now( 4 );
Seconds = int( Time % 100 );
Minutes = int( Time / 100 % 100 );
Hours = int( Time / 10000 % 100 );
SecondNum = int( Hours * 60 * 60 + Minutes * 60 + Seconds );
return SecondNum;
}
RequestTimedRefresh( 1 );
TimeFrame = Interval();
SecNumber = GetSecondNum();
Newperiod = SecNumber % TimeFrame == 0;
SecsLeft = SecNumber - int( SecNumber / TimeFrame ) * TimeFrame;
SecsToGo = TimeFrame - SecsLeft;
 
GfxSelectSolidBrush( ColorRGB(0,0,0));
GfxSelectPen( ColorRGB(0,0,0) , 3 );
if ( NewPeriod )
{
GfxSelectSolidBrush( ColorRGB(0,0,0));
GfxSelectPen( colorRGB(0,0,0), 3 );
}

GfxSelectFont( "Verdana", 14, 600, False );
GfxSetTextColor( colorRGB(255, 119, 255) );
GfxTextOut( "Time Left:" +SecsToGo+"/" +NumToStr( TimeFrame, 1.0 ), x+650, y+10 );

_SECTION_END();

//////////////////////////////////////////////////////////////////

_SECTION_BEGIN("Current Market Price");

GfxSelectFont("Verdana", 18, 600, False  );
GfxSetTextColor( colorRGB(161, 202, 241));
GfxTextOut("LTP:" +WriteVal(C,td), x+1200,y+35 );

_SECTION_END();

//////////////////////////////////////////////////////////////////

_SECTION_BEGIN("O,H,L,C,V");

GfxSelectFont( "Verdana", 14, 600, False );
GfxSetTextColor( ColorRGB(255,255,255) );
GfxTextOut( "Open:"+WriteVal(O,td), x+850, y+10 );

GfxSelectFont( "Verdana", 14, 600, False );
GfxSetTextColor( ColorRGB(0,255,0) );
GfxTextOut( "High:"+WriteVal(H,td), x+1050, y+10 );

GfxSelectFont( "Verdana", 14, 600, False );
GfxSetTextColor( colorRGB(255, 69, 0) );
GfxTextOut( "Low:"+WriteVal(L,td), x+1250, y+10 );

GfxSelectFont( "Verdana", 14, 600, False );
GfxSetTextColor( colorRGB(255,255,0) );
GfxTextOut( "Close:"+WriteVal(C,td), x+1450, y+10 );

td1 = 1.0; //String Decimals

GfxSelectFont( "Verdana", 14, 600, False );
GfxSetTextColor( colorRGB(255, 119, 255) );
GfxTextOut( "Vol:"+WriteVal(V,td1, stn), x+1650, y+10 );

_SECTION_END();

//////////////////////////////////////////////////////////////////

_SECTION_BEGIN("Heiken Ashi");

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] ) );
}

range = 3;

BarColor = IIf( PDI(range) > MDI(range), ColorRGB(222, 236, 255),ColorRGB(30, 144, 255));

PlotOHLC( HaOpen, HaHigh, HaLow, HaClose, " " , BarColor, styleCandle|styleNoLabel, Null, Null, 0, 0, 3);
 
_SECTION_END();

//////////////////////////////////////////////////////////////////

_SECTION_BEGIN("Price Line");

PriceLineColor=ColorRGB(161, 202, 241);
Barsback = 500; 
FirstBar = BarCount - BarsBack; 
YY = IIf(BarIndex() >= Firstbar,EndValue(C),Null); 

Plot(YY,"Current Price",PriceLineColor, styleLine|styleNoLabel|styleThick, 2); 

side = 1;

dist = 0; 

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

if(i+side== BarCount) PlotText( "\n " + C[ i ] ,  i, YY[ i ]-dist, ColorRGB(255, 8, 0)); 

_SECTION_END();

//////////////////////////////////////////////////////////////////

_SECTION_BEGIN("Double Weighted Moving Averages"); 

AP = (HaLow+HaHigh)/2;


// DWMA 9

function DWMA(price,periods)
{

e1=WMA(price,periods);
e2=WMA(e1,Periods);

DWMAi=2*e1-e2;
return DWMAi;
}

MA1 = DWMA(AP, 9);

Plot ( MA1, " ", ColorRGB(255, 0, 255) ,  styleNoLabel, Null, Null, 0 , 0, 2); 

// HMA 13

MA2 = HMA(AP, 13);

Plot ( MA2, " ", ColorRGB(255, 255, 0) , styleNoLabel, Null, Null, 0 , 0, 2);



_SECTION_END();

//////////////////////////////////////////////////////////////////

_SECTION_BEGIN("Mood");


BKswitch = ParamToggle("Mood","On,Off");
 
OUTcolor = ParamColor("Outer Panel Color",ColorRGB(25, 25, 25));
INUPcolor = ParamColor("Inner Panel Upper",ColorRGB(45, 45, 45));
INDNcolor = ParamColor("Inner Panel Lower",ColorRGB(45, 45, 45));
TitleColor = ParamColor("Title Color ",ColorRGB(25, 25, 25));
if (NOT BKswitch)
{
SetChartBkColor(OUTcolor); // color of outer border
SetChartBkGradientFill(INUPcolor,INDNcolor,TitleColor); // color of inner panel
}

_SECTION_END();

//////////////////////////////////////////////////////////////////

1 comments

1. Kenbk

Have some issue.

PlotOHLC( HaOpen, HaHigh, HaLow, HaClose, " " , BarColor, styleCandle|styleNoLabel, Null, Null, 0, 0, 3);

Plot ( MA1, " ", ColorRGB(255, 0, 255) ,  styleNoLabel, Null, Null, 0 , 0, 2); 

Plot ( MA2, " ", ColorRGB(255, 255, 0) , styleNoLabel, Null, Null, 0 , 0, 2);

Leave Comment

Please login here to leave a comment.

Back