Ok thanks. I have an another startegy in my mind. Can you help in making that afl. I have an afl of avg trade price i.e vwap. Now we will take the avg trade price of 9.30 am or you can even say we will take avg trade price of 3rd candle on the 5 mint chart. Once the avg trade price of 9.30 am on 5 mint chart is decided, we will use this avg trade price for whole day.
Now We will put some Price levels in the afl, which could be edited anytime we want. For example , suppose I have some Fibonananci, gann, pivots or other important support resistance levels of nifty
A= 5180
B=5205
C= 5222
D= 5241
E= 5258 and so on
suppose avg trade price at 9.30 comes 5196. Now the first level above avg trade price is 5205 , so the long call will be initiated above 5205 ( not closing above 5205, even just on break). The stop loss and reverse call be initiated below the fisrt level that comes below avg tarde price i.e 5180.
The avg trade price AFL is
//
// NOTE: the code is SLOOOOWWWW...can someone help speed it up?
// I tried my best, but can't really do much with the two for-loops...
//
// LarryJR -
[email protected]
_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates,colorRed);
Plot(C,"Price",IIf(C>O,colorBrightGreen,colorBrown),styleCandle);
SetBarsRequired( 10000, 0 );
// this stores true/false based on a new day...
newday=Day() != Ref(Day(), -1);
SumPriceVolume=0;
totVolume=0;
Vwap2=0;
stddev=0;
newdayindex=0;
Variance =0;
for( i= 0; i < BarCount; i++ )
{
// only want to reset our values at the start of a new day
if (newday
==True)
{
SumPriceVolume=0;
totVolume=0;
newdayindex=i; // this is the index at the start of a new day
Variance=0;
//Vwap2=0;
}
AvgPrice=(O + H + L + C)/4;
// Sum of Volume*price for each bar
sumPriceVolume += AvgPrice * (Volume);
// running total of volume each bar
totVolume += (Volume);
if (totVolume >0)
{
Vwap2=Sumpricevolume / totVolume ;
Vwap2temp=Vwap2;
}
Variance=0;
for (j=newdayindex; j < i; j++)
{
AvgPrice=(O[j] + H[j] + L[j] + C[j])/4;
Variance += (Volume[j]/totVolume) *
(Avgprice-Vwap2temp)*(Avgprice-Vwap2temp);
}
}
Plot (Vwap2,"VWAP2",colorWhite, styleLine);
I will be very thankful if some1 helps me