Combining Trend-VWAP-Ranges - Pratap's method

wisp

Well-Known Member
#1
Hi all, am starting this thread to collect all the info related to Pratap's Combining Trend and VWAP thread. If Pratap decides to start a new thread on this topic, this thread can be deleted at that time. So until then, please post here all the info you have on this method so they can all be in one place.
 

wisp

Well-Known Member
#2
From Raghuveer's post here http://www.traderji.com/general-tra...68-general-trading-chat-2118.html#post1105857

In this thread will try to see how we can follow trend and also use VWAP ranges (like MP value ranges) for support / resistance.

Whatever I am saying here I am trading on Bank Nifty Intraday and am sure of it for bank nifty. for other scripts some finetuning may have to be done like 5min for NF instead of 3min for BNF, etc. Other than that the strategy should hold.

And in this my focus is mainly intraday

In intraday trading
1. We want to detect a trend and trail the trend until it exhausts. Trend will be when either the buyer or seller will dominate
2. we want to detect possible zones where both buyer and seller will have equal power so that we can then sell resistances and buy supports. Also this being 2 way moves we can also trade lighter that is say 1/2 our usual qty that we trade in trend
************************************************** **********
THE METHOD'S STRENGTH IS IN GIVING US A PRICE ACTION VIEW WHETHER SIDEWAYS OR TREND. ONCE WE KNOW THAT THERE ARE UMPTEEN WAYS ONE COULD TRADE THAT VIEW.
************************************************** **********

In intraday trading
1. We want to detect a trend and trail the trend until it exhausts. Trend will be when either the buyer or seller will dominate
2. we want to detect possible zones where both buyer and seller will have equal power so that we can then sell resistances and buy supports. Also this being 2 way moves we can also trade lighter that is say 1/2 our usual qty that we trade in trend.

The further posts explains how I differentiate between the two and keep changing my trading strategy accordingly.
==========================
TREND
==========================
I follow 13ema for trend. Only thing is my ema is not a single like of ema of close but a band created by ema of high and ema of low.

so trend following for intraday will be trading the 3min trend on 13ema band in the direction of 15min 13ema band
for trend and profit taking we can introduce one more higher TF 13ema. Say 60min 13ema. brown

SRSARTFtj is the main afl and you can set the params as desired to get different combo.
pale green is 3min 13ema band
tan band is 15min 13ema band
brown lines here denote the 60min 13ema band

blue is long
red is short
dotted is 1/2 qty
solid is full qty

When in brown band I have my sideways caution mode ON and will trade lighter and buy support and sell resistances.

================================================
Next Topic VWAP and its zones
================================================
VAH - +1SD level at close yday Horz RED Dotted Line
POC – VWAP level at close yday Horz Black Dotted line
VAL - -1SD level at close yday Horz Green Dotted Line
The above range is colored in yellow = YDAY RANGE where mkt is like to be sideways with both ways trading

Day before yesterday close value levels will be DBYVAH, DBYVAL, DBYPOC
Horz Red, Black and Green lines plain

Today’s building values are +2SD, +1SD, VWAP, -1SD, -2SD
Curved red, black and green lines

one Std Dev covers 68.2% of the trades around VWAP and two std dev covers 95.5%.

so if mkt sustains above or below +1SD and -1SD it means then one side is stronger and is able to extend the range = trend,
but around VWAP to +1SD to -1SD both buys and sellers will be fighting= sideways.

+2SD and -2SD being close to 95% of range becomes overbought and oversold zones for some pullback buy unless +1SD / -1SD is violated one side is still strong.

we can have a view based on where today's price is w.r.t to yday range and after the 1st hour (Note: today's values will take about 1 hr trading to firm up) what it is doing w.r.t today's developing ranges

Scenario 1:
today's price is above yday value range i.e. Above VAH
Bias is +ve as long as we don't break down (BD) below -1SD of today
so below -1SD we will look to take shorts...but above that = -1SD we are looking for supports to take longs.
if +1SD resists we will get out and buy again if it comes to -1SD. Above +1SD we will trail as Trend.

The band has been color light blue when today's VWAP is above VAH to show the +ve bias

The arrows are just an alert that the close of the bar is above +1SD (blue)
back below +1SD (black)
below -1SD (red)
back above +1SD (black)
It is NOT a trading signal. trading will be on pvts or whatever appropriate we decide like above 3min band etc

================================================
Next Topic
Combining the bias available from VWAP zones and trend of 3min in direction of 15min to take trades
================================================

++++++++++++++++++++++
Trades

1. Main Trade is 3min in the direction of 15min
2. in sideways - in yday range (yellow), in 15-13 band for some time, in 60-13 band for some time is switch to sell resistance and buy support
3. +1SD failure can be taken for scalp trade to next supp. At support if support comes in we get back into the main trend
4. -1SD failure can be taken for scalp trades to next resistance. At resistance if resistance comes in we get back into the main trend. e.g. 12pm longs of Sep 20th.

Personally I use all of the above on 1min chart and use 1min pvt beyond the bands to take trades, but all may not be comfortable with 1min. Note: I am not trading 1min. I am just using 1min chart to use a 1min pvt that is beyond the bands to confirm that the band is genuinely broken.

Exracts from post No 147 given below for the sake of better understanding of the application.:

to summarize from the vwap structure point of view we have 3 scenarios based on the prev day levels of VAH and VAL

Note day +1SD and -1SD are firmed up only after about 1 hr of trading.

1. in range between VAL and VAH
Neutral bias....buy VAL sell VAH.... or +1SD and -1SD of day until bias builds

2. above VAH
+ve bias above -1SD day level. Buy pbs upto -1SD day levels and 3min/15min bands.
BD of -1SD day could mean a pb to VAH and then depends what it does there.

2. below VAL
-ve bias below +1SD day level. Sell pbs upto +1SD day levels and 3min/15min bands.
BO of +1SD day could mean a pb to VAL and then depends what it does there.
+++++++++++++++++++++++++
*****************************************
just summarizing the Basic rules of VWAP

The 5 basics
1. above +1SDday is long trend
2. below -1SDday is short trend
3. above VAH / +1SD2day is LONG BIAS - so can exit +1SD and look to re-enter upto -1SD
4. below VAL / -1SD2day is SHORT bias - so can exit -1SD and look to re-enter upto +1SDday
5. between VAH-VAL or 60-13 range could become sideways

everything is how to take an entry and how to take profit or exit within this framework

look at the chart and/or e.g. charts put here with these basics in mind

EXCEPTIONS

1. when on news or major gap it goes beyond +/-2SD2day...... after initial move...good potential that it may do a pb (price or time correction=sideways) to 15min band / +/-1SD2day
18 Nov 2013 was a classic case of that
**************************
The AFLs are intentionally created as building block type so that they can be mixed and matched to created diff views
--------------------------------------------------------------
In a down trend, It is worth shorting the 1st pb to 15-13 high...but after that if 15-13 low gives support like it did 25 Sep 2013, then the it could becomes sideways in 15-13 or reverse the trend
--------------------------------------------------------------
ST ..how you book profit by VWAP?..is it same as Pratap said or any other method?
If I am short, I look at how market behaves at -1 SD in sideways trends and -2 SD in strong trends and if market showing supports there , I will book profits there. This is in addition to few other things I follow for profit booking.If -2SD line is falling rapidly , we know that market has to go lot more down.

Will book 50 % at B because on steep fall , I trail part profit taking at high of each bar.
Balance 50 % when market starts making overlapping moves.This shows the downward momentum is loosing.
--------------------------------------------------------------
1. What is the Stop loss for this method? Pivots on 3TF or 1TF?
2. Where to initiation of Anti-Trend trade in strong trend (e.g. say between -1SD & -2SD) per this method..
3. In sideways, I guess +1SD/-1SD failure as you mentioned in one of your msg..
4. any filter to get in?

It is ideally a 1min pvt beyond 3min band in trend but one could keep a safety SL of level +/- 15 (in BNF) to avoid getting trapped in pvtless move

+1SD / -1SD failures can be used to take counter trend trade with small qty.....and review at next s/r like VWAP / 15 min band etc

in BNF I use a filter of 5 on pvts

The method's strength is in giving us a price action view whether sideways or trend. Once we know that there are umpteen ways one could trade that view
--------------------------------------------------------------
The VWAP bands shows there it is two way trading around vwap or stretched and trend trading beyond +/-1SD and the TF bands shows what 3, 15, 60 etc whether they are aligned or in interference.

So we use the context of vwap to decide whether we have neutral bias/trend +ve bias / trend -ve bias and use the TF bands for entries/profit taking/re-entries on pb as required
--------------------------------------------------------------
to summarize from the vwap structure point of view we have 3 scenarios based on the prev day levels of VAH and VAL

Note day +1SD and -1SD are firmed up only after about 1 hr of trading.

1. in range between VAL and VAH
Neutral bias....buy VAL sell VAH.... or +1SD and -1SD of day until bias builds

2. above VAH
+ve bias above -1SD day level. Buy pbs upto -1SD day levels and 3min/15min bands.
BD of -1SD day could mean a pb to VAH and then depends what it does there.

2. below VAL
-ve bias below +1SD day level. Sell pbs upto +1SD day levels and 3min/15min bands.
BO of +1SD day could mean a pb to VAL and then depends what it does there.
--------------------------------------------------------------
4-5 times higher TF bands as reference

3 x 5 => 15 x 4 => 60 x 6.5 = daily....weekly can be referenced once in a while to keep track but I don't

Just watch the afl during market hours and see what price is doing at various places, the picture will get clear. If the too many lines are confusing, watch it just with vwap for a couple of days, just with tf bands for a few days and then add them both and watch. I am sure the time you spend watching live (or backtesting) will be worth it.
--------------------------------------------------------------
Long entry is pivot above red line..that is +1sd with the initial sl of pivot below green line...that is -1sd. Once trend confirms tsl will be below the green band.(of course pivot below the green band...). Trend is above +1sd and below -1sd. Vice versa for shorts.

The SD levels are firm only about an hour or atleast 1/2 hour of trading to establich day's levels.
The VWAP (average trade price) is still valid and the same can be seem on the broker terminal also.
if there is an existing trend then we can take a pvt beyond vwap in that direction early on.
1st is to decide whether there is a thrend or not
for us a trend will be when we are above +1SD or below -1SD. Some additional scenarios of above VAH and below VAL have been discussed earlier
Once we are in a trend the idea is to trail the SL. where? for longs below +1SD or 3-13 band and for shorts above -1SD or 3-13 band
for entries in trend we take above 3-13 and above +1SD for longs and below 3-13 and -1SD for shorts.
I use a 1min pvt beyond said level to confirm BO/BD.
But a I said for SL if it moves pvtless there could be a problem, so I keep a level +/- 15 (some space to allow pvt formation of 1min)
--------------------------------------------------------------
Happy_Singh: With the trend band (1SD//2SD) plotted on the chart, the trending and non-trending zones are very obvious and visually available for us to see. It makes sense to give the trade more room when the bands are sloping and expanding. We can actually treat the -/+1 SD lines as trend line. But When we are in a prolong sideways these bands are flat n horizontal, in this case, we can treat these lines as S/R lines.
--------------------------------------------------------------
Lets see how we go about taking trade during the day.
1st and foremost we need to decide whether we are in trend or not. So we have

1. In trend – SL trailing mode on 3min band and +/- 1SD levels ; some profit taking on extreme vertical moves may help on 1min band if you are aggressive in re-entering on pullbacks

2. Potential sideways – alert to sideways possibilities as it is resisting / taking support at key levels like +/-1SD, 15min band edges, 60min band edges

3. Confirmed sideways – sit out or play edges either in one direction (higher TF trend direction) or both ways depending on view
--------------------------------------------------------------
For trade BIAS we have 2 views
A. VWAP view

1. Price above VAH
Downtrend below -1SD, +ve bias above -1SD , uptrend above +1SD

2. Price below VAL
Uptrend above +1SD, -ve bias below +1SD and downtrend below -1SD

3. Price in range between VAH and VAL
Neutral bias

B. TF View – 3min in direction of 15min
We treat it as UT when 3min band is above 15min band and DT when 3min band is below 15min band

We will exit below 3min band but are looking for suitable re-entries upto 15min band in the trend direction. Maybe we can use 1min to decide if pullback is over and we re-enter

If 15min band breaks it will be reversal of trend

To get more of the above you need to imbibe the 1st 5 pages of theory in this tread completely
--------------------------------------------------------------
So based on above combining both views, we will at anytime be in following states

1. UT – taking a long trade and trailing on +1SD and/or 3min band. After exiting looking for re-entry upto 15min band

2. DT – taking a short trade and trailing on -1SD and/or 3min band. After exiting looking for re-entry upto 15min band

3. +ve bias – taking longs at support and booking at resistance (if not in trend mode)

4. –ve bias – taking shorts at resistance and booking at support (if not in trend mode)

5. Neutral bias – either SOH, or trading in 15min trend direction or both ways (this will come from experience) . Initially maybe not take both ways trades atleast

1 and 2 are the simplest trades ; 3 and 4 next level trades ; and 5 for the very experienced
--------------------------------------------------------------
Entries / exits – Highlighting the entries and exits for various scenarios as I take them ; if not using 1min band ignore the 1min band part
Note: for exits will have a safety net SL at a fixed pts above/below exit level (using 15pts for BNF)

1. UT – taking a long trade and trailing on +1SD and/or 3min band. After exiting looking for re-entry upto 15min band

Entry – enter above 1min pvt which is above 3min band low and 1min band high
initially we may take this trade with TF view even below +1SD as long as it is above -1SD, but if +1SD resists we will change our view to pt 3 below

Exits – 1min pvt below +1SD , if 3-13 band far else 1min pvt below 3-13 band

2. DT – taking a short trade and trailing on -1SD and/or 3min band. After exiting looking for re-entry upto 15min band

Entry – enter below 1min pvt which is below 3min band high and 1min band low
intially we may take this trade with TF view even above -1SD as long as it is below +1SD, but if -1SD supports we will change our view to pt 4 below

Exits – 1min pvt above -1SD , if 3-13 band far else 1min pvt above 3-13 band

3. +ve bias – taking longs at support and booking at resistance (if not in trend mode)

Entry – above 1min pvt above 1min band at support
Exits – part exit at resistance and rest on 1 bar / 1min band trail

4. –ve bias – taking shorts at resistance and booking at support (if not in trend mode)

Entry – below 1min pvt below 1min band at resistance
Exits – part exit at support and rest on 1 bar / 1min band trail

5. Neutral bias – either SOH, or trading in 15min trend direction or both ways (this will come from experience) . Initially maybe not take both ways trades atleast

Entries and exits similar to 3 and 4 but just uni direction or both ways
--------------------------------------------------------------
just summarizing the Basic rules of VWAP

The 5 basics
1. above +1SDday is long trend
2. below -1SDday is short trend
3. above VAH / +1SD2day is LONG BIAS - so can exit +1SD and look to re-enter upto -1SD
4. below VAL / -1SD2day is SHORT bias - so can exit -1SD and look to re-enter upto +1SDday
5. between VAH-VAL or 60-13 range could become sideways

everything is how to take an entry and how to take profit or exit within this framework
look at the chart and/or e.g. charts put here with these basics in mind

-1SDday is always short (pt 2 above) even if above VAH/+1SD2day (pt 3 above)....VAH / +1SD2day becomes potential review pts of PA
A comment by ST Da:
When the market is sideways on daily timeframe and if this sideways range is large enough or tradeable in smaller timeframes we dont have a trend bias. Near the low of the range, market reverses direction and goes up in uptrend in smaller timeframe and near the top of the range it reverses to down and then smaller timeframe downtrend takes over.

At the beginning of the day, our bias is always the trend in motion till now....as the day progresses, market opens its cards more and we get more visibility. Market is in a particular up or down trend till proved otherwise...and the trends can change during the day too. A daytrader should be alert to such changes occuring during the day. In sideways markets, VWAP bands will be of help...in trends pivots and higher tops/higher bottoms or lower tops/lower bottoms will help our trading decisions. There are many tell-a-tale signals which an alert trader can pick up from the market's behaviour before market reverses its trend.Market always gives us many signals before it makes its move.We either dont catch those signals or dont listen to them.

Smart_trade
 

wisp

Well-Known Member
#3
TREND

SRSARTFtj is the main afl and you can set the params as desired to get different combo.
pale green is 3min 13ema band
tan band is 15min 13ema band
brown lines here denote the 60min 13ema band
Here's a chart


SRSARTFtj afl
Please change the tf and color according to your needs

usetf = ParamToggle("Use TF", "No|Yes", 1) ;

// Author: Pratap Balakrishnan
// Copyright: All rights reserved. Not to be circulated or shared or posted on websites without the author's written permission.
// email id: [email protected]
//
/*
This creates a band of period-moving average for the given TF
(TF should be equal to or higher than current chart TF).

*/
alloff = ParamToggle("All off", "No|Yes", 0) ;

// Rh = ParamField("High", 1) ;
// Rl = ParamField("Low", 2) ;

tf = Param("TF", 3, 1, 100000, 1);
Periods = Param("Periods", 13, 2, 1000, 1 );
showzone = ParamToggle("Show Zone", "No|Yes", 1) ;
Layer = Param("Layer", -2, -5, 5, 1) ;
shift = Param("Shift", 0, -100, 100, 1) ;
showtitle = ParamToggle("Show Title", "No|Yes", 0) ;
showlabel = ParamToggle("Show Label", "No|Yes", 1) ;
isema = ParamToggle("MA Type", "MA|EMA", 1) ;
MAstyle = ParamStyle("MA Style", styleThick|styleDashed) ;
MAwidthper = Param("MA Width %", 0, 0, 10, 1) ;
MAwidth = SelectedValue(C) * MAwidthper /100 ;
Clrup = ParamColor( "Color Up", colorPaleGreen);
Clrdown = ParamColor( "Color Down", colorPaleGreen);
Clrsw = ParamColor( "Color SW", colorPaleGreen);
isexpandLast = ParamToggle("Expand Mode", "First|Last", 0);

styledisp = 0 ;
if (NOT showtitle)
styledisp |= styleNoTitle ;

if (NOT showlabel)
styledisp |= styleNoLabel ;

expandmode = expandFirst ;
if (isexpandLast)
expandmode = expandLast ;

if (NOT alloff)
{
Oldintrvl = Interval() ;

if (usetf)
{
tfs = tf *in1Minute ;
TimeFrameSet(tfs) ;
}
else
tfs = Interval() ;

if (isema)
MAhtf = EMA(H, Periods) ;
else
MAhtf = MA(H, Periods) ;

if (isema)
MAltf = EMA(L, Periods) ;
else
MAltf = MA(L, Periods) ;

str = NumToStr(tf, 1.0)+"Min"+"-P"+NumToStr(Periods, 1.0) ;
Clr = IIf(MAltf > Ref(MAltf, -1 ), ClrUp,
IIf(MAhtf < Ref(MAhtf, -1 ), ClrDown,
Clrsw)) ;

if (usetf)
TimeFrameRestore() ; //TimeFrameSet(Oldintrvl) ;

if (usetf)
MAhtfe = TimeFrameExpand(MAhtf, tfs, expandmode ) ;
else
MAhtfe = MAhtf ;

if (usetf)
MAltfe = TimeFrameExpand(MAltf, tfs, expandmode ) ;
else
MAltfe = MAltf ;

if (usetf)
Clre = TimeFrameExpand(Clr, tfs, expandmode ) ;
else
Clre = Clr ;

RefMAhtfe = MAhtfe ;
RefMAltfe = MAltfe ;
RefClre = Clre ;

Plot( RefMAhtfe, str+" High", RefClre, MAstyle|styledisp|styleNoRescale, 0, 0, shift, 1 );
Plot( RefMAltfe, str+" Low", RefClre, MAstyle|styledisp|styleNoRescale, 0, 0, shift, 1 );
if (showzone)
PlotOHLC(RefMAhtfe, RefMAhtfe, RefMAltfe, RefMAltfe, "", RefClre, styleCloud|styleNoLabel|styledisp|styleNoRescale,Null, Null, shift, Layer) ;
if (MAwidth > 0)
{
PlotOHLC(RefMAhtfe+MAwidth, RefMAhtfe+MAwidth, RefMAhtfe-MAwidth, RefMAhtfe-MAwidth, "", RefClre, styleCloud|styleNoLabel|styledisp|styleNoRescale,Null, Null, shift) ;
PlotOHLC(RefMAltfe+MAwidth, RefMAltfe+MAwidth, RefMAltfe-MAwidth, RefMAltfe-MAwidth, "", RefClre, styleCloud|styleNoLabel|styledisp|styleNoRescale,Null, Null, shift) ;
}
showext = ParamToggle("Show Extension", "No|Yes", 1) ;
showextband = ParamToggle("Show Extension Band", "No|Yes", 1) ;
extend = Param("Extend", 20, 0, 100, 1) ;
showparam = ParamToggle("Show Key Param", "No|Yes", 1) ;

if (showext)
{
x0 = BarCount - (extend+1) ;
x1 = BarCount -1 ;

Hdlast = SelectedValue(RefMAhtfe) ;
Ldlast = SelectedValue(RefMAltfe) ;

Hplot = LineArray(x0, Hdlast, x1, Hdlast) ;
Plot(Hplot, "", RefClre, styleLine|styleNoLabel|styledisp|styleNoRescale, 0,0,extend) ;
LPlot = LineArray(x0, Ldlast, x1, Ldlast) ;
Plot(LPlot, "", RefClre, styleLine|styleNoLabel|styledisp|styleNoRescale, 0,0,extend) ;

if (showextband)
PlotOHLC(HPlot, HPlot, LPlot, LPlot, "", RefClre, styleCloud|styleNoLabel|styledisp|styleNoRescale, 0,0,extend,Layer ) ;

}

showparam = ParamToggle("Show Key Param", "No|Yes", 0) ;

if (showparam)
{
y = (SelectedValue(RefMAhtfe)+ SelectedValue(RefMAltfe)) /2 ;
tfsd = tfs ;
if (tfsd < Interval())
tfsd = Interval() ;

str = "TF = " + NumToStr(tfsd/in1Minute, 1.0) + " P = " + NumToStr(Periods, 1.0) ;
PlotText(str, BarCount+2, y, colorBlack) ;
}


}
 
Last edited:

wisp

Well-Known Member
#4
Next Topic VWAP and its zones
================================================
VAH - +1SD level at close yday Horz RED Dotted Line
POC – VWAP level at close yday Horz Black Dotted line
VAL - -1SD level at close yday Horz Green Dotted Line
The above range is colored in yellow = YDAY RANGE where mkt is like to be sideways with both ways trading

Day before yesterday close value levels will be DBYVAH, DBYVAL, DBYPOC
Horz Red, Black and Green lines plain

Today’s building values are +2SD, +1SD, VWAP, -1SD, -2SD
Curved red, black and green lines

one Std Dev covers 68.2% of the trades around VWAP and two std dev covers 95.5%.
Charts........




 

wisp

Well-Known Member
#5
VWAP afl.......

Code:
//VWAP CODE - updated
SetChartOptions(2,chartWrapTitle);
SetChartBkColor(ParamColor("Background", colorLightGrey)) ;
// Author: Pratap Balakrishnan
// Copyright: All rights reserved. Not to be circulated or shared or posted on websites without the author's written permission.
// email id: [email][email protected][/email]
//
/*
The VWAP for a stock is calculated by adding the dollars traded for every
transaction in that stock ("price" x "number of 
      shares traded") and dividing the total shares traded. A VWAP is computed
from the Open of the market to the market Close, AND is 
      calculated by Volume weighting all transactions during this time period

*/
Layer = Param("Layer", 0, -5, 5, 1) ;
showprice = ParamToggle("Show Price", "No|Yes", 0) ;
if (showprice)
{
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} " + EncodeColor( colorGreen ) + " Open %g," + EncodeColor( colorBlue ) + " Hi %g,  " + EncodeColor( colorRed ) + " Lo %g,  " + EncodeColor( colorBlack ) + " Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close",  colorBlack, styleNoTitle | styleCandle,0,0,0,Layer ); 
//Peaking Volumes
HiVolume = IIf(V > (2 * MA(V,10)), True, False); 
PlotShapes(shapeSmallCircle * HiVolume, IIf(C > O, colorBlack, colorWhite), 0, (O+C)/2, 0);
ToolTip = "Open = " + O + "\nHigh = " + H + "\nLow = " + L + "\nClose = " + C ;
}

SetChartBkColor(colorLightGrey) ;

turnvwapoff = ParamToggle("VWAP All OFF", "No|Yes", 0) ;
showintitle = ParamToggle("Show in Title", "No|Yes", 0) ;
Filterdaych = ParamToggle("Filter Day Change Connections", "No|Yes", 1) ;
Vwapmode = ParamList("VWAP mode", "As Per Param|Only VWAP|VWAP+SD|VWAP+2SD", 0) ;
showvwap = ParamToggle("Show VWAP", "No|Yes", 1) ;
showvwap1sd = ParamToggle("Show VWAP 1SD", "No|Yes", 1) ;
showvwap2sd = ParamToggle("Show VWAP 2SD", "No|Yes", 1) ;
showvwap3sd = ParamToggle("Show VWAP 3SD", "No|Yes", 0) ;
showvwapband = ParamToggle("Show VWAP Trend Bands", "No|Yes", 0) ;
showvwapswband = ParamToggle("Show VWAP Sideways Bands", "No|Yes", 1) ;
showprevdayvals = ParamToggle("Show Prev Day Values", "No|Yes", 1) ;
showprev2dayvals = ParamToggle("Show Prev 2 Day Values", "No|Yes", 1) ;
showprevdayband = ParamToggle("Show Prev Day Bands", "No|Yes", 1) ;
showextprevday = ParamToggle("Show Extension", "No|Yes", 1)  ;
showextbandprevday = ParamToggle("Show Extension Band", "No|Yes", 1)  ;
extend = Param("Extend", 10, 0, 100, 1) ;


Vwaplayer = Param("VWAP Layer", -3, -5, 5, 1) ;
extlayer = Param("Extend Layer", -2, -5, 5, 1) ;

MAwidthper = Param("MA Width %", 0.005, 0, 10, 1) ;
SDwidthper = Param("SD Width %", 0.005, 0, 10, 1) ;
MAwidth = SelectedValue(C) * MAwidthper /100 ;
SDwidth = SelectedValue(C) * SDwidthper /100 ;


showtradearr = ParamToggle("Trade Arrow", "No|Yes", 1) ;

showtext = ParamToggle("Show Text", "No|Yes", 1) ;
Clrtext = ParamColor("Color Text", colorBlack) ;
showvahvaltext = ParamToggle("Show VAH-VAL Text", "No|Yes", 1) ;

Onlyvwap = False ;
withsd = False ;
with2sd = False ;

switch (Vwapmode)
{
//	case "As Per Param":
//		break ;
	case "Only VWAP" :
		Onlyvwap = True ;
		break ;
	case "VWAP+SD" :
		Onlyvwap = True ;
		withsd = True;
		break ;
	case "VWAP+2SD" :
		Onlyvwap = True ;
		withsd = True;
		with2sd = True;
		break ;
}

if (Onlyvwap)
{	
	if (withsd)
		showvwap1sd = True;
	else
		showvwap1sd = False ;
	if (with2sd)
		showvwap2sd = True;
	else
		showvwap2sd = False ;
	showvwap3sd = False ;
	showvwapband = False ;
	showvwapswband = False ;
	showprevdayvals = False ;
	showprev2dayvals = False ;
	showprevdayband = False ;
	showvwapband = False ;

//	showtradearr = False ;
	showcomm = False ;
	showtext = withsd ;
}

stylelabel = 0 ;
if (showtext)
	stylelabel = styleNoLabel ;

styletitle = 0 ;
if (NOT showintitle)
	styletitle = styleNoTitle ;


if (NOT turnvwapoff)
{
	P = (H + L + C) / 3;
	nd = Day() != Ref(Day(),-1) ;
	Bars_so_far_today = 1 + BarsSince( nd);

	TodayVolume = Sum(V,Bars_so_far_today);
	CumV = Sum(V,Bars_so_far_today);
	CumVWP = Sum (P * V, Bars_so_far_today  );
	   VWAP = CumVWP / CumV;

	VWAPsd = IIf(Ref(nd, 1), 0, VWAP);
	CumVsd = IIf(Ref(nd, 1), 0, CumV);

	S = Sum(Ref(CumVsd, -1) * V * (P - Ref(VWAPsd, -1))^2 / CumV,Bars_so_far_today);
	Variance = S / CumV;
	 SD = sqrt(Variance);

	Vwapm1 = VWAP - SD ;
	Vwapp1 = VWAP + SD ;
	Vwapm2 = VWAP -2*SD ;
	Vwapp2 = VWAP +2*SD ;
	Vwapm3 = VWAP -3*SD ;
	Vwapp3 = VWAP +3*SD ;

	dt = DateTime() ;

	dtnum = DateTimeConvert(0, dt) ;
	newdt = dtnum != Ref(dtnum, -1) ;

	Lastbar = H-H ;
	if (Filterdaych)
		Lastbar = dtnum != Ref(dtnum, 1) ;

	RefVWAP = VWAP;
	RefVwapm1 = Vwapm1;
	RefVwapp1 = Vwapp1 ;
	RefVwapm2 = Vwapm2;
	RefVwapp2 = Vwapp2;
	RefVwapm3 = Vwapm3;
	RefVwapp3 = Vwapp3;

	Clrvwap =  ParamColor("Color VWAP",colorBlack) ;
	Clrvwapm1 = ParamColor("Color VWAP -1SD", colorGreen) ;
	Clrvwapp1 = ParamColor("Color VWAP +1SD", colorRed) ;

	strnday = "day";
	if (showvwap)
	{
//		Vwapstyle = 0 ;
//		if (ndays > 1)
			Vwapstyle = styleNoRescale ;
		Plot(IIf(Lastbar, Null, RefVWAP), "VWAP"+strnday, Clrvwap , styleThick|stylelabel|Vwapstyle, Null, Null, 0, 1);
		if (MAwidth > 0)
			PlotOHLC(IIf(Lastbar, Null, RefVWAP+MAwidth), IIf(Lastbar, Null, RefVWAP+MAwidth), IIf(Lastbar, Null, RefVWAP-MAwidth), IIf(Lastbar, Null, RefVWAP-MAwidth), "",Clrvwap, styleCloud|styleNoLabel|styleNoRescale, 0, 0, 0, 1 ) ;
	}

	Plot(SD, "SD", colorBlack, styleNoDraw|styleNoLabel|styleNoRescale) ;
	if (showvwap1sd)
	{
		Plot(IIf(Lastbar, Null, RefVwapm1), "-1SD"+strnday, Clrvwapm1,  styleThick  + styleTitle + stylelabel+styleNoRescale, Null, Null, 0, 1);
		Plot(IIf(Lastbar, Null, RefVwapp1), "+1SD"+strnday, Clrvwapp1, styleThick  + styleTitle + stylelabel+styleNoRescale, Null, Null, 0, 1);
		if (SDwidth > 0)
			PlotOHLC(IIf(Lastbar, Null, RefVWAPm1+SDwidth), IIf(Lastbar, Null, RefVWAPm1+SDwidth), IIf(Lastbar, Null, RefVWAPm1-SDwidth), IIf(Lastbar, Null, RefVWAPm1-SDwidth), "",Clrvwapm1, styleCloud|styleNoLabel|styleNoRescale, 0, 0, 0, 0 ) ;

		if (SDwidth > 0)
			PlotOHLC(IIf(Lastbar, Null, RefVWAPp1+SDwidth), IIf(Lastbar, Null, RefVWAPp1+SDwidth), IIf(Lastbar, Null, RefVWAPp1-SDwidth), IIf(Lastbar, Null, RefVWAPp1-SDwidth), "",Clrvwapp1, styleCloud|styleNoLabel|styleNoRescale, 0, 0, 0, 0 ) ;

	}

	if (showvwap2sd)
	{
		Plot(IIf(Lastbar, Null, RefVwapm2), "-2SD"+strnday, ParamColor("Color VWAP -2SD", colorSeaGreen), styleThick  + styleTitle + stylelabel+styleNoRescale, Null, Null, 0, 1);
		Plot(IIf(Lastbar, Null, RefVwapp2), "+2SD"+strnday, ParamColor("Color VWAP +2SD", colorOrange), styleThick  + styleTitle + stylelabel+styleNoRescale, Null, Null, 0, 1);
		if (SDwidth > 0)
			PlotOHLC(IIf(Lastbar, Null, RefVWAPm2+SDwidth), IIf(Lastbar, Null, RefVWAPm2+SDwidth), IIf(Lastbar, Null, RefVWAPm2-SDwidth), IIf(Lastbar, Null, RefVWAPm2-SDwidth), "",ParamColor("Color VWAP -2SD", colorSeaGreen), styleCloud|styleNoLabel|styleNoRescale, 0, 0, 0, 0 ) ;

		if (SDwidth > 0)
			PlotOHLC(IIf(Lastbar, Null, RefVWAPp2+SDwidth), IIf(Lastbar, Null, RefVWAPp2+SDwidth), IIf(Lastbar, Null, RefVWAPp2-SDwidth), IIf(Lastbar, Null, RefVWAPp2-SDwidth), "",ParamColor("Color VWAP +2SD", colorOrange), styleCloud|styleNoLabel|styleNoRescale, 0, 0, 0, 0 ) ;
	}

	if (showvwap3sd)
	{
		Plot(IIf(Lastbar, Null, RefVwapm3), "-3SD"+strnday, ParamColor("Color VWAP -3SD", colorRed), styleThick  + styleNoTitle + stylelabel+styleNoRescale, Null, Null, 0, 1);
		Plot(IIf(Lastbar, Null, RefVwapp3), "+3SD"+strnday, ParamColor("Color VWAP +3SD", colorBlue), styleThick  + styleNoTitle + stylelabel+styleNoRescale, Null, Null, 0, 1);
	}


	if (showvwapband)
	{
		PlotOHLC(IIf(Lastbar, Null, RefVwapm1), IIf(Lastbar, Null, RefVwapm1), IIf(Lastbar, Null, RefVwapm2), IIf(Lastbar, Null, RefVwapm2), "",ParamColor("Down Trend", colorRose), styleCloud|styleNoLabel|styleNoRescale, 0, 0, 0, Vwaplayer ) ;
		PlotOHLC(IIf(Lastbar, Null, RefVwapp1), IIf(Lastbar, Null, RefVwapp1), IIf(Lastbar, Null, RefVwapp2), IIf(Lastbar, Null, RefVwapp2), "",ParamColor("Up Trend", colorSkyblue), styleCloud|styleNoLabel|styleNoRescale, 0, 0, 0, Vwaplayer ) ;
	}

//	if (showvwapswband)
//	{
//		PlotOHLC(RefVwapm1, RefVwapm1, RefVwapp1, RefVwapp1, "",ParamColor("Sideways Color", colorLavender), styleCloud|styleNoLabel|styleNoRescale, 0, 0, 0, Vwaplayer ) ;
//	}


	Avgp = (H+L+C)/3 ;

	if (showtradearr)
	{

		Buy = Avgp >= Refvwapp1 ;
		Short = Avgp <= Refvwapm1 ;

		Sell =  Avgp <= Refvwapp1 ;
		Cover = Avgp >= Refvwapm1 ;

		Buy = ExRem(Buy, Short OR Sell) ;
		Short = ExRem(Short, Buy OR Cover) ;

		sdp1touch = False ; // Ht >= Refvwapp1 ;
		sdm1touch = False ; //Lt >= Refvwapm1 ;

		Sell = ExRem(Sell, Buy OR sdp1touch ) ;
		Cover = ExRem(Cover, Short OR sdm1touch ) ;

		PlotShapes(Buy*shapeUpArrow, colorBlue, 0, H, 12) ;
		PlotShapes(Short*shapeDownArrow, colorRed, 0, L, 12) ;

		PlotShapes(Cover*shapeUpArrow, colorBlack, 0, H, 12) ;
		PlotShapes(Sell*shapeDownArrow, colorBlack, 0, L, 12) ;

	}

	shift = Param("Shift", 0, -1, 0, 1) ;

	prevdayvalue = prevdayvwap = ValueWhen(Ref(newdt,1), RefVWAP, 1) ;
	prevdayvaluelow = prevdayvwapm1 = ValueWhen(Ref(newdt,1), RefVwapm1, 1) ;
	prevdayvaluehigh = prevdayvwapp1 = ValueWhen(Ref(newdt,1), RefVwapp1, 1) ;
	prevdayvwapm2 = ValueWhen(Ref(newdt,1), RefVwapm2, 1) ;

	if (showvwapswband)
	{
		swclr = ParamColor("Sideways Color", colorLavender) ;
		upclr =  ParamColor("Bull Bias Color", colorSkyblue) ;
		dnclr =  ParamColor("Bear Bias Color", colorRose) ;

		bandclr = IIf(Refvwap < prevdayvaluelow, dnclr, IIf(Refvwap > prevdayvaluehigh, upclr, swclr)) ;
			
		PlotOHLC(IIf(Lastbar, Null, RefVwapp1), IIf(Lastbar, Null, RefVwapp1), IIf(Lastbar, Null, RefVwap), IIf(Lastbar, Null, RefVwap), "",bandclr, styleCloud|styleNoLabel|styleNoRescale, 0, 0, 0, Vwaplayer ) ;
		PlotOHLC(IIf(Lastbar, Null, RefVwap), IIf(Lastbar, Null, RefVwap), IIf(Lastbar, Null, RefVwapm1), IIf(Lastbar, Null, RefVwapm1), "",bandclr, styleCloud|styleNoLabel|styleNoRescale, 0, 0, 0, Vwaplayer ) ;
	}

	if (showprevdayvals OR showextprevday)
	{
		if (shift == -1)
		{
			prevdayvaluehigh = prevdayvwap;
			prevdayvalue = prevdayvwapm1 ;
			prevdayvaluelow = prevdayvwapm2 ;
		}

		if (showprevdayvals) //(NOT showextprevday)
		{
		Plot(IIf(Lastbar, Null, prevdayvalue), "Prev VWAP", Clrvwap, styleDots|styleNoRescale+stylelabel|styleNoTitle) ;
		Plot(IIf(Lastbar, Null, prevdayvaluelow), "VAL"+strnday, Clrvwapm1, styleDots|styleNoRescale+stylelabel+styleNoTitle) ;
		Plot(IIf(Lastbar, Null, prevdayvaluehigh), "VAH"+strnday, Clrvwapp1, styleDots|styleNoRescale+stylelabel+styleNoTitle) ;
		}

		Clrprevdayband = ParamColor("Prev Day Band Color", colorLightYellow);
		if (showprevdayband)
		{
//			if (NOT showextprevday)
				PlotOHLC(IIf(Lastbar, Null, prevdayvaluelow), IIf(Lastbar, Null, prevdayvaluelow), IIf(Lastbar, Null, prevdayvaluehigh), IIf(Lastbar, Null, prevdayvaluehigh), "",Clrprevdayband, styleCloud|styleNoLabel|styleNoRescale, 0, 0, 0, Vwaplayer ) ;
		}

		if (showprev2dayvals)
		{
			prev2dayvalue = prev2dayvwap = ValueWhen(Ref(newdt,1), RefVWAP, 2) ;
			prev2dayvaluelow = prev2dayvwapm1 = ValueWhen(Ref(newdt,1), RefVwapm1, 2) ;
			prev2dayvaluehigh = prev2dayvwapp1 = ValueWhen(Ref(newdt,1), RefVwapp1, 2) ;
			prev2dayvwapm2 = ValueWhen(Ref(newdt,1), RefVwapm2, 2) ;

//			if (NOT showextprevday)
			{
			Plot(IIf(Lastbar, Null, prev2dayvalue), "2day prev VWAP"+strnday, Clrvwap, styleStaircase|styleThick|stylelabel|styleNoRescale+styleNoTitle) ;
			Plot(IIf(Lastbar, Null, prev2dayvaluelow), "2day VAL"+strnday, Clrvwapm1, styleStaircase|styleThick|stylelabel|styleNoRescale+styleNoTitle) ;
			Plot(IIf(Lastbar, Null, prev2dayvaluehigh), "2day VAH"+strnday, Clrvwapp1, styleStaircase|styleThick|stylelabel|styleNoRescale+styleNoTitle) ;
			}
		}

	if (showextprevday)
	{
		x0 = BarCount - (extend+1) ;
		x1 = BarCount -1 ;

		Hdlast = SelectedValue(prevdayvaluehigh ) ;
		Ldlast = SelectedValue(prevdayvaluelow ) ;

		Hplot = LineArray(x0, Hdlast, x1, Hdlast) ;
		Plot(Hplot, "", colorOrange, styleLine|styleNoLabel|styleNoRescale, 0,0,extend, extlayer) ;
		LPlot = LineArray(x0, Ldlast, x1, Ldlast) ;
		Plot(LPlot, "", colorGreen, styleLine|styleNoLabel|styleNoRescale, 0,0,extend, extlayer) ;

		if (showextbandprevday)
			PlotOHLC(HPlot, HPlot, LPlot, LPlot, "", Clrprevdayband, styleCloud|styleNoLabel|styleNoRescale, 0,0,extend,extlayer ) ;

	}

	}

	
	if (showtext)
	{
		PlotText(NumToStr(RefVwapp1[BarCount-1], 1.1), BarCount+1, RefVwapp1[BarCount-1],Clrtext) ;
		PlotText(NumToStr(RefVwapm1[BarCount-1], 1.1), BarCount+1, RefVwapm1[BarCount-1],Clrtext) ;
		PlotText(NumToStr(RefVwap[BarCount-1], 1.1), BarCount+1, RefVwap[BarCount-1],Clrtext) ;
		PlotText(NumToStr(RefVwapp2[BarCount-1], 1.1), BarCount+1, RefVwapp2[BarCount-1],Clrtext) ;
		PlotText(NumToStr(RefVwapm2[BarCount-1], 1.1), BarCount+1, RefVwapm2[BarCount-1],Clrtext) ;
	}

	if (showvahvaltext)
	{
		PlotText(NumToStr(prevdayvalue[BarCount-1], 1.1), BarCount+1, prevdayvalue[BarCount-1],Clrtext) ;
		PlotText(NumToStr(prevdayvaluelow[BarCount-1], 1.1), BarCount+1, prevdayvaluelow[BarCount-1],Clrtext) ;
		PlotText(NumToStr(prevdayvaluehigh[BarCount-1], 1.1), BarCount+1, prevdayvaluehigh[BarCount-1],Clrtext) ;
	}

}
 
#6
anybody help me FOR AFL CODING.

I need MACD WHILE CROSSING "0" line from (negetive to positive zone) BUY SINGNAL and positive to negetive SELL SIGNAL.
( MACD value- EMA 11 - EMA-50 - EMA-100 )
thanks in advance.
please help.
 

XRAY27

Well-Known Member
#7

niftytaurus

Well-Known Member
#8
Dear Wisp
Its good intiative to start this thread..thanks for this thread.
All the traders who use this method can contribute..
it would be more benefiical if trader who trades this method can post charts & trades to discuss further..so we can give more positive contribution
thanks
 

XRAY27

Well-Known Member
#9
Pratap bhai in my old thread contributed another study which he uses 13-60min afl

For noting BO/BD levels in Higher time frame...this is very long back setting..

I don't follow any of this as if now....just for thread purpose i have contributed this ..

 
Last edited:

_Rajesh_

Well-Known Member
#10
Dear TJ members,

I made a PDF of Pratapbhai's VWAP thread some time back. Given that the thread cannot be recovered, I have uploaded the PDF on dropbox and the link is shared below. Hope it helps. All credit to Pratapbhai who selflessly spent months explaining this method on TJ.

The AFLs are posted above by Wisp. If required, I have the AFLs and can post them here. A word of caution for those who are new to this method. As Pratapbhai had said in his thread, please go through the theory and examples and understand the method before trying to trade with the AFLs.

Pratapbhai, if there is any objection, please let me know and I will delete.

Link to PDF:

https://www.dropbox.com/s/xnv9loj1hqvm8by/Pratap.pdf?dl=0

Regards,

Rajesh
 

Similar threads