// Downloaded From https://www.WiseStockTrader.com

//Vegas Tunnel Exploration for Daily/Hourly/15 Minute TimeFrames
// Developed by Sivakumar.C
// Used predominantly in Daily and Hourly TF.

_SECTION_BEGIN("Price");

SetChartOptions( 0, chartShowDates | chartShowArrows | chartLogarithmic | chartWrapTitle );

_N( Title = StrFormat( "{{NAME}} - " + SectorID( 1 ) + " - {{INTERVAL}}     Open %g, Hi %g, Lo %g, Close %g (%.2f%%) Vol " + WriteVal( V, 1.0 ) + " {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ) );

Plot( C, "Close", colorRose, styleCandle | styleNoTitle | ParamStyle( "Style" ) | GetPriceStyle() );

_SECTION_END();



_SECTION_BEGIN("EMA");

TimeFrameSet(inDaily);

DSP = Param("Daily Short Period", 124, 10, 200, 5);
DLP = Param("Daily Long Period", 193, 10, 200, 5);

DLEMA = EMA(C,DLP);
DSEMA = EMA(C,DSP);


AddColumn(Close, "Daily Vegas Tunnel",1.2, colorWhite, IIf(C<DLEMA OR C>DSEMA, colorlime, colorOrange ) );


TimeFrameRestore();

TimeFrameSet(inHourly);

HSP = Param("Hourly Short Period", 124, 10, 200, 5);
HLP = Param("Hourly Long Period", 193, 10, 200, 5);

HLEMA = EMA(C,HLP);
HSEMA = EMA(C,HSP);

AddColumn(Close, "Hourly Vegas Tunnel",1.2, colorWhite, IIf(C<HLEMA OR C>HSEMA,colorlime, colorOrange));
TimeFrameRestore();


TimeFrameSet(in15Minute);

MSP15 = Param("15 Minute Short Period", 124, 10, 200, 5);
MLP15 = Param("15 Minute Long Period", 193, 10, 200, 5);

MLEMA15 = EMA(C,MLP15);
MSEMA15 = EMA(C,MSP15);


AddColumn(Close, "15 Min Vegas Tunnel",1.2, colorWhite, IIf(C<MLEMA15 OR C>MSEMA15,colorlime, colorOrange));

TimeFrameRestore();

/*
TimeFrameSet(in5Minute);

MSP5 = Param("5 Minute Short Period", 124, 10, 200, 5);
MLP5 = Param("5 Minute Long Period", 193, 10, 200, 5);

MLEMA5 = EMA(C,MLP5);
MSEMA5 = EMA(C,MSP5);


AddColumn(Close, "5 Min Vegas Tunnel",1.2, colorWhite, IIf(C<MLEMA5 OR C>MSEMA5,colorlime, colorOrange));

TimeFrameRestore();*/


Buy = ((Close < DSEMA) AND (Close>DLEMA)) OR ((Close < HSEMA) AND (Close>HLEMA)) OR ((Close < MSEMA15) AND (Close > MLEMA15)) /* OR ((Close < MSEMA5) AND (Close > MLEMA5))*/ ;

Filter = Buy;

AlertIf(Buy,"SOUND c:\\Windows\\Media\\alarm10.wav","Audio Alert",1);

_SECTION_END();