// Downloaded From https://www.WiseStockTrader.com
// Vortex Indicator 
// Concept By Etienne Botes and Douglas Siepman
// Coded by pipschart.com

_N(Title = StrFormat(FullName() + " - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 )) ));


p = Param("Time Period", 14, 2 ); 
PDM = Sum( abs( H - Ref( L, -1 ) ), p ); //Directional movement of current high wrt to previous bar low
NDM = Sum( abs( L - Ref( H, -1 ) ), p ); //Directional movement of current low wrt to previous bar high
S = Sum( ATR( 1 ), p); 

VortexP = PDM / S; 
VortexN = NDM / S; 

Plot( VortexP, "Positive Directional Momentum", colorBlue); 
Plot( VortexN, "Negative Directional Momentum", colorRed ); 

PositionSize = 2500000; 

Buy = (VortexP > VortexN) AND ((VortexP-VortexN)< 2) ;
Sell= (VortexP < VortexN)AND ((VortexN-VortexP)< 2);
//Buy=ExRem(Buy,Sell); Sell=ExRem(Sell,Buy);
Filter = (Buy OR Sell);

AddTextColumn(FullName(),"Name");
AddColumn( Buy, "BUY" );
AddColumn( Sell, "SELL" );
AddColumn(C,"close",1.2);
AddColumn(V, "Volome");