Better Volume Code |
Post Reply | Page 123> |
Author | |
jalna
Regular Joined: 31 Mar 2007 Posts: 95 |
Post Options
Quote Reply
Topic: Better Volume Code Posted: 09 Sep 2008 at 10:48pm |
Can anyone convert this Trade station code to BC. Its a
simple volume analysis. I got it from emini-watch.com. Intereting site
Inputs: Color(Cyan), LowColor(Yellow), ClimaxColor(Red), ChurnColor(Green), ClimaxChurnColor(Magenta), LowChurnColor(White), AvgColor(Red); |
|
jalna
Regular Joined: 31 Mar 2007 Posts: 95 |
Post Options Quote Reply Posted: 11 Sep 2008 at 9:39pm |
Oh no , has everyone left the building ? Volume spread analysis is becoming very popular and lots of codes are being written for different programs. There is a book out by Tom Williams called Master the Markets. It can be downloaded for free on the web . His thinking hails from Wyckoffs works
|
|
maximo
BullCharts Guru Joined: 02 Sep 2006 Location: Australia Posts: 232 |
Post Options Quote Reply Posted: 12 Sep 2008 at 11:56pm |
Haha funny one jalna, okay done! I had trouble finding what the 'Range' value was... Anyhow paste that link to Tom Williams book if you don't mind
{ Volume Spread Analysis }
[description="Better Volume Indicator - http://emini-watch.com/free-stuff/volume-indicator/"] Range := High - Low; Value1 := Volume; Value2 := Volume*Range; Value3 := If(Range<>0,Volume/Range,0); ma(Value1,100,S); [linestyle=Grounded Bar; width=4] [Color=Cyan] { Normal } Volume; [Color=Gold] { Low volume } If(Value1 = Lowest(Value1,20),V,undefined); [Color=Red] { Volume climax } If(Value2 = Highest(Value2,20),V,undefined); [Color=Lime Green] { High churn } If(Value3 = Highest(Value3,20),V,undefined); [Color=Magenta] { Climax & High churn } If(Value2 = Highest(Value2,20) and Value3 = Highest(Value3,20),V,undefined); [Color=Coral] { Low churn } If(Value3 = Lowest(Value3,20),V,undefined)
Edited by maximo - 13 Sep 2008 at 3:22am |
|
jalna
Regular Joined: 31 Mar 2007 Posts: 95 |
Post Options Quote Reply Posted: 13 Sep 2008 at 7:26am |
Thanks heaps Maximo
Here is the link http://www.tradethetruth.com/pics/mtmv3.pdf There are numerous forums that discuss these ideas, one in the US and one in India http://www.traderji.com/advanced-trading-strategies/23128-volume-spread-analysis-3.html http://www.traderslaboratory.com/forums/ Better volume is not really VSA code. They are much more complicated |
|
jalna
Regular Joined: 31 Mar 2007 Posts: 95 |
Post Options Quote Reply Posted: 13 Sep 2008 at 2:30pm |
Hi Maximo, here is the code for a version of VSA written for Amibroker.
What do you reckon ? Looks very complicated to me. Tim has been putting up some of his codes on the above forums. He is fine if we want to try and script it. I have posted some stuff at the bottom that he suggested might help for Bull script SECTION_BEGIN("Volume Analysis"); //////////////////////////////////////////////////////////////////////////////////// // // Volume Analysis Studies // // this code studies price/volume based on information from // // * Master the Markets, // * http://www.traderji.com/ // * http://www.traderslaboratory.com/ // // I do not claim responsibility or liability for how this code is used. // If you change the code in any way, please send me an updated copy of // the changes to: // // tcoates_au@hotmail.com // //////////////////////////////////////////////////////////////////////////////////// SetChartOptions(0,chartShowArrows|chartShowDates); //////////////////////////////////////////////////////////////////////////////////// // // constants // //////////////////////////////////////////////////////////////////////////////////// numDays = 30; dwWideSpread = 1.8; dwNarrowSpread = 0.8; dwSpreadMiddle = 0.5; dwHighClose = 0.7; dwLowClose = 0.3; volNumDays = 30; //numDays; dwUltraHighVol = 2; dwVeryHighVol = 2.2; // was 1.8 dwHighVol = 1.8; // was 1.8 dwAboveAvgVol = 1.5; // was 1.8 dwLowVol = 0.8; // was 0.8 //avgVolume = EMA(V, volNumDays); volSpeedUp = 1; //int(numDays * 0.33); avgVolume = EMA(EMA(V, volNumDays),volSpeedUp) ; //////////////////////////////////////////////////////////////////////////////////// longTermAvg = int(EMA(C, 200) * 100); medTermAvg = int(EMA(C, 50) * 100); shortTermAvg = int(EMA(C, 10) * 100); MAvgDir = EMA(C, 13); MAvgDirTestDays = 30; MAvgDirHigh = HHV(MAvgDir, MAvgDirTestDays); MAvgDirLow = LLV(MAvgDir, MAvgDirTestDays); MAvgDirTrend = IIf(MAvgDir > Ref(MAvgDirHigh, -1), 1, IIf(MAvgDir < Ref(MAvgDirLow,-1), -1, 0)); //////////////////////////////////////////////////////////////////////////////////// // // Classify each bar... // //////////////////////////////////////////////////////////////////////////////////// upBar = C > Ref(C,-1); downBar = C < Ref(C,-1); closeEqual = int(C*100) == int(Ref(C,-1)*100); spread = H-L; avgRange = Sum(spread, numDays) / numDays; wideRange = spread >= (dwWideSpread * avgRange); narrowRange = spread <= (dwNarrowSpread * avgRange); testHighClose = L + (spread * dwHighClose); testLowClose = L + (spread * dwLowClose); testCloseMiddle = L + (spread * dwSpreadMiddle); upClose = C > testHighClose; upClose12 = C >= testCloseMiddle; downClose = C < testLowClose; downClose12 = C < testCloseMiddle; middleClose = C >= testLowClose AND C <= testHighClose; aboveAvgVolume = V > (avgVolume * dwAboveAvgVol); highVolume = V > (avgVolume * dwHighVol); veryHighVolume = V > (avgVolume * dwVeryHighVol); ultraHighVolume = V > (avgVolume * dwUltraHighVol); LowVolume = V < (avgVolume * dwLowVol); markUpVol = (V > (avgVolume * dwLowVol)) AND (V <= (avgVolume * dwUltraHighVol)); markUpVol2 = markUpVol AND Ref(markUpVol,-1); narrowBar1 = spread < Ref(spread,-1); HH = H > Ref(H,-1); LL = L < Ref(L,-1); LH = H < Ref(H,-1); //////////////////////////////////////////////////////////////////////////////////// // // direction and title // //////////////////////////////////////////////////////////////////////////////////// ColorScheme = Param( "Color Scheme", 1, 0, 2, 1); Trend_U = ( LLV( L, 20 ) + 2 * ATR( 10 ) ); Trend_D = ( HHV( H, 20 ) - 2 * ATR( 10 ) ); TrendUp = C >= Trend_U; TrendDown = C < Trend_D; //////////////////////////////////////////////////////////////////////////////////// // // Basic patterns... // // //see also: // // http://www.traderslaboratory.com/forums/151/vsa-volume-spread-analysis-1369-28.html // http://www.traderslaboratory.com/forums/151/vsa-volume-spread-analysis-1369-7.html#post13343 // // older definitions... // // upThrustBar = downClose AND HH AND (NOT narrowRange); // AND (H > Ref(HHV(H,4),-1)) ; //(C == L) AND; //////////////////////////////////////////////////////////////////////////////////// testVolLow2 = (V < Ref(V,-1)) AND (V < Ref(V,-2)); testVolHigh2 = (V > Ref(V,-1)) AND (V > Ref(V,-2)); WRD = (spread > Ref(spread,-1)) AND (spread > Ref(spread,-2)) AND (spread > Ref(spread,-3)); //////////////////////////////////////////////////////////////////////////////////// // NO DEMAND basicNoDemandBar = narrowRange AND Lowvolume AND upBar AND (upClose OR middleClose); noDemandBar = basicNoDemandBar; // AND TrendUp; //////////////////////////////////////////////////////////////////////////////////// // NO SUPPLY basicNoSupplyBar = narrowRange AND LowVolume AND downBar AND (downclose OR middleClose); // It is also common to find these bars in an up trend which are indications // of continuation of the trend. They would also be found on consolidation bases. // During up moves a No supply could indicate non participation from SM. noSupplyBarUp = basicNoSupplyBar AND TrendUp; // The No Supply bar is a narrow range Low Volume down bar closing in the lower half. // The No Supply bars are found in the early Bottom reversals AND indicate strength. noSupplyBarDown = basicNoSupplyBar AND TrendDown; //////////////////////////////////////////////////////////////////////////////////// // // STOPPING VOLUME stoppingVolume1 = downBar AND upClose12 AND Highvolume; stoppingVolume2 = Ref(wideRange,-1) AND Ref(HighVolume,-1) AND Ref(downClose12,-1) AND upBar AND HH; // AND HighVolume;// AND upClose12; stoppingVolume3 = Ref(wideRange,-1) AND Ref(HighVolume,-1) AND Ref(downClose12,-1) AND upBar AND HighVolume AND upClose12; stoppingVolume = TrendDown AND (stoppingVolume1 OR StoppingVolume2 OR StoppingVolume3); //////////////////////////////////////////////////////////////////////////////////// // // TEST testBar = narrowRange AND lowvolume AND (C > testCloseMiddle); testBar = testBar AND (NOT NoDemandBar); //////////////////////////////////////////////////////////////////////////////////// // // upThrustBar - see // http://www.traderji.com/advanced-trading-strategies/23128-volume-spread-analysis-4.html#post202084 // upThrustBar = WRD AND testVolHigh2 AND TrendUp AND HH AND downClose12 AND NOT Ref(upBar,1); upThrustBarWithNoDemand = upThrustBar AND LowVolume; upThrustBarWithSupplyOverDemand = upThrustBar AND testVolHigh2; absorption = Ref(downbar, -1) AND Ref(highVolume, -1) AND upBar; support = Ref(downBar,-1) AND (NOT Ref(downClose,-1)) AND Ref(highVolume,-1) AND upBar; absorptionVolume1 = downBar AND downClose AND Highvolume AND Ref(upBar,1); absorptionVolume2 = downBar AND downClose12 AND Highvolume AND Ref(upBar,1); reverseUpThrust = TrendDown AND wideRange AND upClose AND Highvolume; //////////////////////////////////////////////////////////////////////////////////// // // Strength and Weakness // //////////////////////////////////////////////////////////////////////////////////// weakness1 = downBar AND downClose AND C < Ref(L,-1); weakness = upThrustBar OR noDemandBar; weaknessInUpTrend = weakness AND TrendUp; weaknessInDownTrend = weakness AND TrendDown; WideRangeAlert1 = wideRange AND aboveAvgVolume AND TrendUp AND (C < O); WideRangeAlert2 = wideRange AND downClose12 AND TrendUp; EffortToGoDown = wideRange AND aboveAvgVolume AND TrendUp AND downClose; MyMarkUp = markUpVol AND Ref(markUpVol,-1) AND (MAvgDirTrend > 0) AND V > Ref(V,-1); //////////////////////////////////////////////////////////////////////////////////// // // Display stuff goes here! // //////////////////////////////////////////////////////////////////////////////////// OffSet = 0; PlotShapes( shapeDownArrow*EffortToGoDown , colorIndigo , 0, H); Offset += IIf(EffortToGoDown, 25, 5); //Offset = abs(Offset); PlotShapes( shapeSmallSquare*(upThrustBarWithNoDemand OR upThrustBarWithSupplyOverDemand), IIf(upThrustBarWithSupplyOverDemand, colorRed, colorDarkRed), 0, H, Offset); Offset += IIf(upThrustBarWithNoDemand OR upThrustBarWithSupplyOverDemand, 25, 5); //Offset = abs(Offset); //PlotShapes( shapeHollowDownArrow*weaknessInDownTrend, colorBrown, 0, H, Offset); //Offset -= IIf(weaknessInDownTrend, 15, 0); PlotShapes( shapeSmallCircle*NoDemandBar, colorBlack,0, H, Offset); Offset += IIf(NoDemandBar, 15, 0); PlotShapes( shapeSmallUpTriangle*stoppingVolume, IIf(stoppingVolume, colorGreen, colorSeaGreen),0, L); PlotShapes( shapeSmallCircle*testBar , colorBlue,0, L); PlotShapes( shapeSmallUpTriangle*reverseUpThrust , colorDarkGreen, 0, L); PlotShapes( shapeSmallCircle*(noSupplyBarUp OR noSupplyBarDown), colorPink,0, L); //PlotShapes( shapeSmallUpTriangle*MyMarkUp , colorSeaGreen, 0, L); //Plot( testCloseMiddle, "", colorBlack, styleDots ); //PlotShapes( shapeSmallCircle*markUpVol2, colorBrown,0, L, negY); //Plot( TREND_U, "", colorRed); Color0 = colorBlack; Color1 = IIf(wideRange, colorBlue, IIf( narrowRange, colorLightBlue, IIf( upBar, colorDarkGreen, IIf( downBar, colorRed, colorDarkGrey)))); Color2 = IIf( TrendUp, colorDarkGreen, IIf( TrendDown, colorRed, colorBlack)); Color = IIf(ColorScheme == 0, Color0, IIf(ColorScheme == 1, Color1, Color2)); Plot( C, "Close", Color, styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); //////////////////////////////////////////////////////////////////////////////////// // // trend direction... // //////////////////////////////////////////////////////////////////////////////////// Dir = EncodeColor(colorBlack) + "Volume: " + WriteIf(ultraHighVolume , "Ultra High", WriteIf(veryHighVolume , "Very High", WriteIf(highVolume , "High", WriteIf(lowVolume , "Low", "Average")))) + " " + // spread EncodeColor(colorBlack) + "Spread: " + WriteIf(wideRange , EncodeColor(colorBlue) + "Wide", WriteIf(narrowRange , EncodeColor(colorLightBlue) + "Narrow", EncodeColor(colorBlack) + "Average")) + ", " + EncodeColor(colorBlack) + "Close: " + WriteIf(upClose , EncodeColor(colorGreen) + "Up", WriteIf(downClose , EncodeColor(colorRed) + "Down", EncodeColor(colorBlack) + "Middle")) + EncodeColor(colorBlack) + ",\n" + EncodeColor(colorBlack) + "Long Term: " + WriteIf(longTermAvg < Ref(longTermAvg,-1), EncodeColor(colorRed) + "Down", WriteIf(longTermAvg == Ref(longTermAvg ,-1), EncodeColor(colorBlack) + "Flat", EncodeColor(colorGreen) + "Up")) + EncodeColor(colorBlack) + ", " + "Med Term: " + WriteIf(medTermAvg < Ref(medTermAvg ,-1), EncodeColor(colorRed) + "Down", WriteIf(medTermAvg == Ref(medTermAvg ,-1), EncodeColor(colorBlack) + "Flat", EncodeColor(colorGreen) + "Up")) + EncodeColor(colorBlack) + ", " + "Short Term: " + WriteIf(shortTermAvg < Ref(shortTermAvg,-1), EncodeColor(colorRed) + "Down", WriteIf(shortTermAvg == Ref(shortTermAvg,-1), EncodeColor(colorBlack) + "Flat", EncodeColor(colorGreen) + "Up")) + EncodeColor(colorBlack) + "\n" + WriteIf(MAvgDirTrend == 1, "Up", "") + WriteIf(MAvgDirTrend == 0, "No Direction", "") + WriteIf(MAvgDirTrend == -1, "Down", ""); _N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%)", O, H, L, C, SelectedValue( ROC( C, 1 ) )) + "\n" + Dir); _SECTION_END(); TIP FOR Bullscript users... Keep in mind that it is still a work in progress. I am somewhat happy with it. Couple of suggestion though... Change assignment statements from = to := for example... X = Y; becomes X := Y; Since it (Bullscript) uses Pascal style assignments, you would probably change != to <> and == to = and call to Ref get convered to Hist. Another example (Joels script...) NoDemand = C>Ref(C,-1) AND V<Ref(V,-1) AND V<Ref(V,-2); NoDemand2 = C==Ref(C,-1) AND V<Ref(V,-1) AND V<Ref(V,-2) AND Ref(C,-1)>Ref(C,-2); NoSupply = C<Ref(C,-1) AND V<Ref(V,-1) AND V<Ref(V,-2); NoSupply2= C==Ref(C,-1) AND V<Ref(V,-1) AND V<Ref(V,-2) AND Ref(C,-1)<Ref(C,-2); The corresponding bullscript should (?) like NoDemand := C>Hist(C,1) AND V<Hist(V,1) AND V<Hist(V,2); NoDemand2 := C=Hist(C,1) AND V<Hist(V,1) AND V<Hist(V,2) AND Hist(C,1)>Hist(C,2); NoSupply := C<Hist(C,1) AND V<Hist(V,1) AND V<Hist(V,2); NoSupply2:= C=Hist(C,1) AND V<Hist(V,1) AND V<Hist(V,2) AND Hist(C,1)<Hist(C,2); Edited by jalna - 13 Sep 2008 at 2:36pm |
|
maximo
BullCharts Guru Joined: 02 Sep 2006 Location: Australia Posts: 232 |
Post Options Quote Reply Posted: 14 Sep 2008 at 4:53am |
OMG jalna that's a fair chunk of code! I can see a couple of functions there that I have no idea what they do.. like WriteIf( ), and EncodeColor() other than that it's a step by step process one line at a time. It's helpful if you can see what it's supposed to look like on the other platform, a picture says a 1000 words they say. Like the video for the better volume indicator, which also helps to make sure every step you've taken is a correct. Not sure if bullscript can do all those kinds of plots like PlotShapes( shapeSmallUpTriangle), might be able to substitute up arrows or something.
I will have a look at the links you've pasted, thanks!
|
|
jalna
Regular Joined: 31 Mar 2007 Posts: 95 |
Post Options Quote Reply Posted: 14 Sep 2008 at 6:44pm |
Hi guys, here is a link from Tim on how the code works and looks
http://s289.photobucket.com/albums/ll230/tcoates_au/ |
|
tcoates_au
Newbie Joined: 15 Sep 2008 Posts: 3 |
Post Options Quote Reply Posted: 15 Sep 2008 at 8:16am |
Hi,
My name is Tim Coates and I wrote the script above. The script itself is OK. You have to note there are 3 parts to the script above. The first part is volume analysis, and that is the top part of the script. The next part is direction and that is implemented quite simply using moving averages (though these are not plotted on the chart as such!). I also use a 13 day moving average to determine whether trend direction is flat or not using HHV and LLV. Its an idea from Trading for a living. Found it to be more effective than either the short or medium term averages. Finally there is the plotting of the chart and associated "alerts". I have 2 (or 3) coloring schemes - plain black, bars colored based on wide range, narrow range etc., and the last color scheme is an ATR based green and red. (On this last color scheme, you can find many links on the Internet to code for Jim Bergs volatility which you should be able to modify as necessary) The alerts are plotted as either dots or small up/down triangles. Amibroker gives you numerous choices here. The main reason why I used small up/down triangles is so they don't get in the way of the charts compared with a regular trianges. In the 2nd version I switched to dots as they are less intrusive - especially when you plot all types of alerts on a chart, either above the high or below the low. So you should be able to substitute arrow as you suggested. Hope that helps. (if you have any questions about the script, I don't mind if you send me an email) Cheers, Tim |
|
trev04
Newbie Joined: 15 Oct 2007 Location: Australia Posts: 7 |
Post Options Quote Reply Posted: 15 Sep 2008 at 7:31pm |
Hi Tim,
I have been reading and noting data from "Master The Markets" for a few weeks now and am fascinated with the concept! After reading from BullCharts forum, and comming across your post, I have become even more interested in utilizing the indicators more. So I have been attempting to copy and change aspects of the code to suit BC, yet am still unable to get it to work!!! Would you please be able to show me exactly how to get the code to work in BC? The first part is volume analysis: Is that from "SetChartOptions... to LH = H < Ref(H,-1);" The next part is direction: Is that from "ColorScheme = Param... to ?" There are so many parts of codes that you have showed, yet I cannot assertain how that all combine together!!! It is probably just me that is not following the code, yet I would appreciate very much If you could assist me in the following of your explanation. I have been thrilled with the information I have obtained of the whole concept, and am looking forward to utilising this in Bullcharts successfully. Thankyou again for any assistance you can give me. Best Regards Trevor Jones |
|
tcoates_au
Newbie Joined: 15 Sep 2008 Posts: 3 |
Post Options Quote Reply Posted: 16 Sep 2008 at 11:55am |
Not sure what code others have converted as yet. But here is the first bit...
numDays := 30; dwWideSpread := 1.8; dwNarrowSpread := 0.8; dwSpreadMiddle := 0.5; dwHighClose := 0.7; dwLowClose := 0.3; volNumDays := 30; dwUltraHighVol := 2; dwVeryHighVol := 2.2; dwHighVol := 1.8; dwAboveAvgVol := 1.5; dwLowVol := 0.8; volSpeedUp := numDays * 0.33; avgVolume := MA(MA(V, volNumDays, S),volSpeedUp, S) ; upClose := C > testHighClose; upClose12 := C >= testCloseMiddle; downClose := C < testLowClose; downClose12 := C < testCloseMiddle; middleClose := C >= testLowClose AND C <= testHighClose; aboveAvgVolume := V > (avgVolume * dwAboveAvgVol); highVolume := V > (avgVolume * dwHighVol); veryHighVolume := V > (avgVolume * dwVeryHighVol); ultraHighVolume := V > (avgVolume * dwUltraHighVol); LowVolume := V < (avgVolume * dwLowVol); Combine that with [Color=Cyan] { Normal } Volume; [Color=Gold] { Low volume } If(highVolume,V,undefined); (assuming you want to color volume bars) and you are off to a start?!? Tim PS. I dont have or use BullCharts so what I work out is partially guess work. Jalna asked me if he could post my code here. I said Yes. So whatever help I give is .... |
|
Post Reply | Page 123> |
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |