NexusFi: Find Your Edge


Home Menu

 





Outside Volume indicator


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one Big Mike with 9 posts (6 thanks)
    2. looks_two Jura with 7 posts (5 thanks)
    3. looks_3 SPTrading with 2 posts (2 thanks)
    4. looks_4 Quick Summary with 1 posts (0 thanks)
    1. trending_up 8,088 views
    2. thumb_up 13 thanks given
    3. group 2 followers
    1. forum 19 posts
    2. attach_file 4 attachments




 
Search this Thread

Outside Volume indicator

  #1 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,442 since Jun 2009
Thanks Given: 33,215
Thanks Received: 101,603

I wanted to build an indicator that would visualize the volume of the current bar relative to the prior bar, in this way:

- how much volume of current bar is above the prior bar high?
- how much volume of current bar is below the prior bar low?
- how much volume of current bar remains as 'inside' volume relative to prior bar?

But I admit I am having a hard time getting the logic right to do this.

// current price higher than prior bar high
if C > H[1] then begin

outside_volume = ???;

end;

My issue is with tracking the outside volume amount. I'm using intrabarpersist on the var: definition, but the values are coming out as cumulative which is not what I want. So then I tried adding a BarStatus(1) = 2 check to reset the value at the close of each bar, but again desired effect is not happening.

Maybe someone can see an easier way.

Mike

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Started this thread Reply With Quote
Thanked by:

Can you help answer these questions
from other members on NexusFi?
Better Renko Gaps
The Elite Circle
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
PowerLanguage & EasyLanguage. How to get the platfor …
EasyLanguage Programming
MC PL editor upgrade
MultiCharts
Trade idea based off three indicators.
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
29 thanks
Just another trading journal: PA, Wyckoff & Trends
24 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
21 thanks
GFIs1 1 DAX trade per day journal
17 thanks
  #3 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,442 since Jun 2009
Thanks Given: 33,215
Thanks Received: 101,603


Here is code and a screen shot. Doesn't work as-is, I need to step away and think apparently

 
Code
vars:

	IntraBarPersist outsidev	( 0 ),
	IntraBarPersist outsideupv	( 0 ),
	IntraBarPersist outsidednv	( 0 );
	
//if BarStatus(1) = 2 then outsidev = V;
outsidev = iff(C > H[1] or C < L[1], outsidev[1] - outsidev + V, outsidev);
//outsideupv = iff(C > H[1], outsidev - V, outsideupv);
//outsidednv = iff(C < L[1], V - outsidev, outsidednv);

Plot1(outsidev, "Outside Volume");
//Plot1(outsideupv, "Outside Up Volume");
//Plot2(outsidednv, "Outside Dn Volume");
You can see the couple different ways I've tried it.

Mike

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Attached Thumbnails
Click image for larger version

Name:	6-27-2011 6-39-47 PM.png
Views:	391
Size:	24.9 KB
ID:	42153  
Follow me on Twitter Visit my NexusFi Trade Journal Started this thread Reply With Quote
Thanked by:
  #4 (permalink)
 
Jura's Avatar
 Jura   is a Vendor
 
Posts: 775 since Apr 2010
Thanks Given: 2,352
Thanks Received: 690


Big Mike View Post
I wanted to build an indicator that would visualize the volume of the current bar relative to the prior bar, in this way:

- how much volume of current bar is above the prior bar high?
- how much volume of current bar is below the prior bar low?
- how much volume of current bar remains as 'inside' volume relative to prior bar?

[..]

....the values are coming out as cumulative which is not what I want.

This is a great idea Mike. I've tried to make it work, but ironically I can't get the right cumulative values. My problem is that the first tick of the bar seems to get missed, though I've no idea why. If you, or someone else, can spot the error in my code, that would be a great help (and potentially 'solving' this problem).

Here's the output, note the line with error:

 
Code
1110516 100155 Price: 107.445 prevBarClose:107.435 UPvolume: 1 totalUpVolBar: 30518 volThisBar: 31358
1110516 100155 Price: 107.445 prevBarClose:107.435 UPvolume: 0 totalUpVolBar: 30518 volThisBar: 31358
 -8770      0 Price: 107.450 prevBarClose:107.445 UPvolume: 0 totalUpVolBar: 0 volThisBar: 0
1110516 102043 Price: 107.450 prevBarClose:107.445 UPvolume: 0 totalUpVolBar: 0 volThisBar: 0
1110516 102043 Price: 107.450 prevBarClose:107.445 UPvolume: 1 totalUpVolBar: 1 volThisBar: 1
1110516 102043 Price: 107.445  prevBarClose: 107.445 DOWNvolume: 4 totalDownVolBar: 4 volThisBar: 5
1110516 102043 Price: 107.450 prevBarClose:107.445 UPvolume: 1 totalUpVolBar: 2 volThisBar: 6
1110516 102043 Price: 107.450 prevBarClose:107.445 UPvolume: 1 totalUpVolBar: 3 volThisBar: 7
1110516 102043 Price: 107.450 prevBarClose:107.445 UPvolume: 250 totalUpVolBar: 253 volThisBar: 257
1110516 102043 Price: 107.450 prevBarClose:107.445 UPvolume: 1 totalUpVolBar: 254 volThisBar: 258
1110516 102043 Price: 107.450 prevBarClose:107.445 UPvolume: 1000 totalUpVolBar: 1254 volThisBar: 1258
1110516 102043 Price: 107.450 prevBarClose:107.445 UPvolume: 50 totalUpVolBar: 1304 volThisBar: 1308
1110516 102043 Price: 107.450 prevBarClose:107.445 UPvolume: 12 totalUpVolBar: 1316 volThisBar: 1320
1110516 102043 Price: 107.450 prevBarClose:107.445 UPvolume: 15 totalUpVolBar: 1331 volThisBar: 1335
1110516 102043 Price: 107.450 prevBarClose:107.445 UPvolume: 1 totalUpVolBar: 1332 volThisBar: 1336
1110516 102043 Price: 107.450 prevBarClose:107.445 UPvolume: 1 totalUpVolBar: 1333 volThisBar: 1337
1110516 102043 Price: 107.450 prevBarClose:107.445 UPvolume: 10 totalUpVolBar: 1343 volThisBar: 1347
1110516 102043 Price: 107.450 prevBarClose:107.445 UPvolume: 1 totalUpVolBar: 1344 volThisBar: 1348
1110516 102043 Price: 107.450 prevBarClose:107.445 UPvolume: 1 totalUpVolBar: 1345 volThisBar: 1349
1110516 102043 Price: 107.450 prevBarClose:107.445 UPvolume: 2 totalUpVolBar: 1347 volThisBar: 1351
1110516 102043 Price: 107.450 prevBarClose:107.445 UPvolume: 2 totalUpVolBar: 1349 volThisBar: 1353
1110516 102043 Price: 107.450 prevBarClose:107.445 UPvolume: 19 totalUpVolBar: 1368 volThisBar: 1372
1110516 102043 Price: 107.450 prevBarClose:107.445 UPvolume: 5 totalUpVolBar: 1373 volThisBar: 1377
1110516 102043 Price: 107.450 prevBarClose:107.445 UPvolume: 5 totalUpVolBar: 1378 volThisBar: 1382
1110516 102043 Price: 107.450 prevBarClose:107.445 UPvolume: 5 totalUpVolBar: 1383 volThisBar: 1387
1110516 102043 Price: 107.450 prevBarClose:107.445 UPvolume: 10 totalUpVolBar: 1393 volThisBar: 1397
1110516 102043 Price: 107.450 prevBarClose:107.445 UPvolume: 1 totalUpVolBar: 1394 volThisBar: 1398
1110516 102043 Price: 107.445  prevBarClose: 107.445 DOWNvolume: 50 totalDownVolBar: 54 volThisBar: 1448
1110516 102043 Price: 107.445  prevBarClose: 107.445 DOWNvolume: 70 totalDownVolBar: 124 volThisBar: 1518
1110516 102043 Price: 107.445  prevBarClose: 107.445 DOWNvolume: 131 totalDownVolBar: 255 volThisBar: 1649
1110516 102043 Price: 107.445  prevBarClose: 107.445 DOWNvolume: 10 totalDownVolBar: 265 volThisBar: 1659
1110516 102043 Price: 107.445  prevBarClose: 107.445 DOWNvolume: 3 totalDownVolBar: 268 volThisBar: 1662
1110516 102043 Price: 107.445  prevBarClose: 107.445 DOWNvolume: 1 totalDownVolBar: 269 volThisBar: 1663
1110516 102043 Price: 107.445  prevBarClose: 107.445 DOWNvolume: 1 totalDownVolBar: 270 volThisBar: 1664
1110516 102043 Price: 107.445  prevBarClose: 107.445 DOWNvolume: 1 totalDownVolBar: 271 volThisBar: 1665
1110516 102043 Price: 107.445  prevBarClose: 107.445 DOWNvolume: 1 totalDownVolBar: 272 volThisBar: 1666
1110516 102043 Price: 107.445  prevBarClose: 107.445 DOWNvolume: 1 totalDownVolBar: 273 volThisBar: 1667
1110516 102043 Price: 107.445  prevBarClose: 107.445 DOWNvolume: 1 totalDownVolBar: 274 volThisBar: 1668
1110516 102043 Price: 107.445  prevBarClose: 107.445 DOWNvolume: 1 totalDownVolBar: 275 volThisBar: 1669
1110516 102043 Price: 107.445  prevBarClose: 107.445 DOWNvolume: 1 totalDownVolBar: 276 volThisBar: 1670
1110516 102043 Price: 107.445  prevBarClose: 107.445 DOWNvolume: 2 totalDownVolBar: 278 volThisBar: 1672
1110516 102043 Price: 107.445  prevBarClose: 107.445 DOWNvolume: 75 totalDownVolBar: 353 volThisBar: 1747
1110516 102043 Price: 107.445  prevBarClose: 107.445 DOWNvolume: 2 totalDownVolBar: 355 volThisBar: 1749
1110516 102043 Price: 107.445  prevBarClose: 107.445 DOWNvolume: 2 totalDownVolBar: 357 volThisBar: 1751
1110516 102043 Price: 107.445  prevBarClose: 107.445 DOWNvolume: 16 totalDownVolBar: 373 volThisBar: 1767
1110516 102043 Price: 107.445  prevBarClose: 107.445 DOWNvolume: 25 totalDownVolBar: 398 volThisBar: 1792
1110516 102043 Price: 107.445  prevBarClose: 107.445 DOWNvolume: 24 totalDownVolBar: 422 volThisBar: 1816
1110516 102043 Price: 107.445  prevBarClose: 107.445 DOWNvolume: 5 totalDownVolBar: 427 volThisBar: 1821
1110516 102043 Price: 107.445  prevBarClose: 107.445 DOWNvolume: 7 totalDownVolBar: 434 volThisBar: 1828
1110516 102043 Price: 107.445  prevBarClose: 107.445 DOWNvolume: 1 totalDownVolBar: 435 volThisBar: 1829
Note the volume in the variable 'volThisBar' of 1829... the volume in MultiCharts playback is 1828. One (!) missing tick makes this code incorrect. I don't mean that obsessive - if that one trade had a volume of 200 contracts the difference would be quite huge, so this error needs to be corrected.

Btw, I know that I can use 'volume' instead of custom calculating the volume of the bar (in the 'volThisBar' variable), but there shouldn't be any difference between the 'Up volume this bar' and 'Down volume this bar', given the conditional statements in the code.

Btw: I haven't incorporated your idea yet in the code Mike, since this version is a test to see if the underlying calculations/assumptions are correct. If they are, the logic can be easily changed to any condition.

And the code:
 
Code
                            
vars
    
intrabarpersist thisBarVolume(0),
    
intrabarpersist volumeUp(0),
    
intrabarpersist totalUpVolBar(0),
    
intrabarpersist volumeDown(0),
    
intrabarpersist totalDownVolBar(0),
    
intrabarpersist prevCloseBar(0),
    
intrabarpersist volumeLastUpdate(0)
    ;
        
if 
BarStatus(1) = 0 then begin        // save prev close on opening tick
    
prevCloseBar Close[1];
end;

if 
prevCloseBar <> 0 then begin         // wait till there is a prevClose value
    
    // Calculate volume if close is higher than previous close
    
if Close prevCloseBar then begin            // latest tick is higher then close of previous bar
    
        // Get volume of latest trade
        
if totalUpVolBar 1 then                        // checks for invalid values if tick is first of bar
            
volumeUp volume
        
else
            
volumeUp volume volumeLastUpdate// totalUpVolBar; // volumeLastUpdate;
            
        // Total up volume for this bar
        
totalUpVolBar totalUpVolBar volumeUp;
        
        
// Total volume for bar
        
thisBarVolume totalUpVolBar totalDownVolBar;
        
        Print(
date:6:0" "time_s:6:0" Price: "Close:0:3" prevBarClose:"prevCloseBar:0:3" UPvolume: ",
            
volumeUp:0:0" totalUpVolBar: "totalUpVolBar:0:0" volThisBar: "thisBarVolume:0:0);
            
    
end else begin

        
// Get volume of latest trade
        
if totalDownVolBar 1 then
            volumeDown 
volume
        
else
            
volumeDown volume volumeLastUpdate//totalDownVolBar; // volumeLastUpdate;
        
        // Total down volume for this bar
        
totalDownVolBar totalDownVolBar volumeDown;
        
        
// Total volume for bar
        
thisBarVolume totalUpVolBar totalDownVolBar;
        
        Print(
date:6:0" "time_s:6:0" Price: "Close:0:3"  prevBarClose: "prevCloseBar:0:3,
            
" DOWNvolume: "volumeDown:0:0" totalDownVolBar: "totalDownVolBar:0:0" volThisBar: "thisBarVolume:0:0);
            
    
end;
    
    
// save total volume of this tick
    
volumeLastUpdate volume;
end;
    
if 
BarStatus(1) = 2 then begin
    Plot1
(thisBarVolume"Volume");
    
Plot2(volumeUp" UpVol");
    
Plot3(-volumeDown"DownVolume");
    
    
// Reset variables
    
thisBarVolume 0;
    
volumeUp 0;
    
volumeDown 0;
    
totalDownVolBar 0;
    
totalUpVolBar 0;
    
volumeLastUpdate 0;
end

Reply With Quote
Thanked by:
  #5 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,442 since Jun 2009
Thanks Given: 33,215
Thanks Received: 101,603

Thanks for your help, I will take a look this weekend and get back to you.



Mike

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Started this thread Reply With Quote
  #6 (permalink)
 
Jura's Avatar
 Jura   is a Vendor
 
Posts: 775 since Apr 2010
Thanks Given: 2,352
Thanks Received: 690

Thanks Mike, have a great 4th July weekend.

Reply With Quote
  #7 (permalink)
 
Jura's Avatar
 Jura   is a Vendor
 
Posts: 775 since Apr 2010
Thanks Given: 2,352
Thanks Received: 690

I think I've got it fixed (will need to do more testing to know for sure).

I've added the following in the BarStatus(1) = 2 section:
 
Code
                            
    Print(date:6:0" "time_s:6:0" upVol: "totalUpVolBar:0:0" downVol: "totalDownVolBar:0:0
        
" volumeOfBar: "thisBarVolume:0:0" defaultVolume: "Volume:0:0); 
If the code should be correct, the 'volumeOfBar' should equal the 'defaultVolume', which uses the volume provided by MultiCharts.

Here's the output of that statement:
 
Code
1110516 100155 upVol: 30518 downVol: 740 volumeOfBar: 31258 defaultVolume: 31258
1110516 102043 upVol: 1471 downVol: 1969 volumeOfBar: 3440 defaultVolume: 3440
1110516 102543 upVol: 0 downVol: 4074 volumeOfBar: 4074 defaultVolume: 4074
1110516 102755 upVol: 2634 downVol: 2982 volumeOfBar: 5616 defaultVolume: 5616
1110516 104122 upVol: 507 downVol: 16874 volumeOfBar: 17381 defaultVolume: 17381
1110516 110041 upVol: 1958 downVol: 1371 volumeOfBar: 3329 defaultVolume: 3329
1110516 110236 upVol: 1631 downVol: 1028 volumeOfBar: 2659 defaultVolume: 2659
1110516 110403 upVol: 2 downVol: 4039 volumeOfBar: 4041 defaultVolume: 4041
1110516 110624 upVol: 987 downVol: 2357 volumeOfBar: 3344 defaultVolume: 3344
1110516 110744 upVol: 478 downVol: 1119 volumeOfBar: 1597 defaultVolume: 1597
1110516 110937 upVol: 2575 downVol: 19429 volumeOfBar: 22004 defaultVolume: 22004
1110516 112639 upVol: 215 downVol: 7829 volumeOfBar: 8044 defaultVolume: 8044
1110516 113901 upVol: 625 downVol: 1847 volumeOfBar: 2472 defaultVolume: 2472
1110516 114657 upVol: 3912 downVol: 869 volumeOfBar: 4781 defaultVolume: 4781
1110516 115645 upVol: 1600 downVol: 6211 volumeOfBar: 7811 defaultVolume: 7811
1110516 122043 upVol: 1 downVol: 3156 volumeOfBar: 3157 defaultVolume: 3157
1110516 122937 upVol: 3177 downVol: 3497 volumeOfBar: 6674 defaultVolume: 6674
1110516 124401 upVol: 3555 downVol: 96 volumeOfBar: 3651 defaultVolume: 3651
1110516 124926 upVol: 1072 downVol: 1549 volumeOfBar: 2621 defaultVolume: 2621
1110516 125943 upVol: 1177 downVol: 2019 volumeOfBar: 3196 defaultVolume: 3196
1110516 130334 upVol: 61 downVol: 2098 volumeOfBar: 2159 defaultVolume: 2159
1110516 130817 upVol: 472 downVol: 810 volumeOfBar: 1282 defaultVolume: 1282
1110516 131308 upVol: 2651 downVol: 3105 volumeOfBar: 5756 defaultVolume: 5756
1110516 133135 upVol: 1 downVol: 1641 volumeOfBar: 1642 defaultVolume: 1642
1110516 133627 upVol: 36 downVol: 3535 volumeOfBar: 3571 defaultVolume: 3571
1110516 135455 upVol: 1557 downVol: 7531 volumeOfBar: 9088 defaultVolume: 9088
1110516 141112 upVol: 0 downVol: 3968 volumeOfBar: 3968 defaultVolume: 3968
1110516 142108 upVol: 0 downVol: 1914 volumeOfBar: 1914 defaultVolume: 1914
1110516 142314 upVol: 1 downVol: 1293 volumeOfBar: 1294 defaultVolume: 1294
1110516 142629 upVol: 0 downVol: 3018 volumeOfBar: 3018 defaultVolume: 3018
1110516 142815 upVol: 3375 downVol: 59 volumeOfBar: 3434 defaultVolume: 3434
1110516 143019 upVol: 1119 downVol: 2048 volumeOfBar: 3167 defaultVolume: 3167
1110516 143349 upVol: 1285 downVol: 1319 volumeOfBar: 2604 defaultVolume: 2604
1110516 143822 upVol: 28 downVol: 6772 volumeOfBar: 6800 defaultVolume: 6800
1110516 144914 upVol: 28 downVol: 4808 volumeOfBar: 4836 defaultVolume: 4836
No differences anymore!

And the code:
 
Code
                            
vars
    
intrabarpersist thisBarVolume(0),
    
intrabarpersist volumeUp(0),
    
intrabarpersist totalUpVolBar(0),
    
intrabarpersist volumeDown(0),
    
intrabarpersist totalDownVolBar(0),
    
intrabarpersist prevCloseBar(0),
    
intrabarpersist volumeLastUpdate(0)
    ;
        
if 
BarStatus(1) = 0 then begin        // save prev close on opening tick
    
prevCloseBar Close[1];
end;

if 
prevCloseBar <> 0 then begin         // wait till there is a prevClose value
    
    // Calculate volume if close is higher than previous close
    
if Close prevCloseBar then begin            // latest tick is higher then close of previous bar
        
volumeUp volume volumeLastUpdate
            
        
// Total up volume for this bar
        
totalUpVolBar totalUpVolBar volumeUp;
        
        
// Total volume for bar
        
thisBarVolume totalUpVolBar totalDownVolBar;

{        
        Print(
date:6:0" "time_s:6:0" Price: "Close:0:3" prevBarClose:"prevCloseBar:0:3" UPvolume: ",
            
volumeUp:0:0" totalUpVolBar: "totalUpVolBar:0:0" volThisBar: "thisBarVolume:0:0);
}
            
    
end else begin
        volumeDown 
volume volumeLastUpdate;
                
        
// Total down volume for this bar
        
totalDownVolBar totalDownVolBar volumeDown;
        
        
// Total volume for bar
        
thisBarVolume totalUpVolBar totalDownVolBar;
{        
        Print(
date:6:0" "time_s:6:0" Price: "Close:0:3"  prevBarClose: "prevCloseBar:0:3,
            
" DOWNvolume: "volumeDown:0:0" totalDownVolBar: "totalDownVolBar:0:0" volThisBar: "thisBarVolume:0:0);
}
    
end;
    
    
// save total volume of this tick
    
volumeLastUpdate volume;
end;
    
if 
BarStatus(1) = 2 then begin

    
// Print data to verify
    
Print(date:6:0" "time_s:6:0" upVol: "totalUpVolBar:0:0" downVol: "totalDownVolBar:0:0
        
" volumeOfBar: "thisBarVolume:0:0" defaultVolume: "Volume:0:0);

    
//Plot1(thisBarVolume, "Volume");
    
Plot2(totalUpVolBar" UpVol");
    
Plot3(-totalDownVolBar"DownVolume");
    
    
// Reset variables
    
thisBarVolume 0;
    
volumeUp 0;
    
volumeDown 0;
    
totalDownVolBar 0;
    
totalUpVolBar 0;
    
volumeLastUpdate 0;
end
I'm wondering how this might be added for historical charts - the current version only works on real-time data or Playback. Adding a data series with a 1 tick resolution messes up the layout of the primary data series, which makes this not a viable solution. Anyone got an idea?

Regards,

Reply With Quote
Thanked by:
  #8 (permalink)
 
Jura's Avatar
 Jura   is a Vendor
 
Posts: 775 since Apr 2010
Thanks Given: 2,352
Thanks Received: 690

See attached nexusfi.com (formerly BMT) Outside Volume indicator. Usable on real-time data or PlayBack data.

Perhaps the plot style can use some further styling (I'm not sure this is the most clearly visible style). Any other feedback is off course highly welcomed.

Regards,


---
Code:
 
Code
                            
nexusfi.com (formerly BMTOutside Volume Indicator
    Based on an idea from BigMike

    
https://nexusfi.com/tradestation-multicharts-easylanguage-programming/11768-outside-volume-indicator.html
}

//Inputs:
    // none yet
    
Variables:
    
// Variables for volume calculations
    
intrabarpersist thisBarVolume(0),
    
intrabarpersist highPrevBar(0),
    
intrabarpersist lowPrevBar(0),
    
intrabarpersist volumeLastUpdate(0),
    
// Variables needed for the volume above prev high, below previous low, and inside
    
intrabarpersist volAbovePrevHigh(0),
    
intrabarpersist totalVolAbove(0),
    
intrabarpersist volBelowPrevLow(0),
    
intrabarpersist totalVolBelow(0),
    
intrabarpersist volInsideHighLow(0),
    
intrabarpersist totalVolInside(0)
    ;
    
// Save the values from the previous bar
if BarStatus(1) = 0 then begin
    highPrevBar 
High[1];
    
lowPrevBar Low[1];
end;

// Start volume calculations 
if highPrevBar <> and lowPrevBar <> 0 then begin            // just to prevent scaling issues on the first (real-time) bar

    // Calculate the volume that's *above* the previous high
    
if Close highPrevBar then begin
        volAbovePrevHigh     
volume volumeLastUpdate;                // Volume on this bar
        
totalVolAbove         volAbovePrevHigh totalVolAbove;        // Total above volume for this bar
    
end else if Close lowPrevBar then begin
        volBelowPrevLow    
volume volumeLastUpdate;
        
totalVolBelow        volBelowPrevLow totalVolBelow;
    
end else    begin    // for inside volume
        
volInsideHighLow     volume volumeLastUpdate;
        
totalVolInside        volInsideHighLow totalVolInside;    
    
end;

    
thisBarVolume        volAbovePrevHigh volBelowPrevLow volInsideHighLow;        // Total volume for this bar    
    
volumeLastUpdate     volume;        // Saves volume of last tick
end;

// Start plotting
if BarStatus(1) = 2 then begin

    Plot1
(totalVolAbove"Up Volume");            // Total volume of this bar above the previous high
    
Plot2(totalVolBelow"Below Volume");        // Total volume of this bar below previous low
    
Plot3(totalVolInside"Inside volume");    // Total volume of this bar inside the previous low and high

    // Reset the variables
    
thisBarVolume            0;
    
volumeLastUpdate        0;
    
volAbovePrevHigh        0;
    
totalVolAbove            0;
    
volBelowPrevLow        0;
    
totalVolBelow            0;
    
volInsideHighLow        0;
    
totalVolInside            0;
end

Attached Thumbnails
Click image for larger version

Name:	BMTOutsideVolumeExample.PNG
Views:	361
Size:	52.0 KB
ID:	42457  
Attached Files
Elite Membership required to download: BMT Outside Volume.pla
Reply With Quote
Thanked by:
  #9 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,442 since Jun 2009
Thanks Given: 33,215
Thanks Received: 101,603

Very nice, Jura. Sorry I've had no time to do any more with it. I have been so busy lately, and today I just kind of zoned out and watched TV and tried to relax. But I'll look at your indicator shortly and appreciate your help.

Mike

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Started this thread Reply With Quote
Thanked by:
  #10 (permalink)
 
Angelo1's Avatar
 Angelo1 
Adelaide Australia
 
Experience: Intermediate
Platform: Ninja > MC
Broker: AMPs
Trading: ES
Posts: 147 since May 2011
Thanks Given: 1,873
Thanks Received: 78


Hey Mike Jura

Happy anniversary & 4th

Not quite sure what the function of this ind represents, any way I've been wondering about an indicator or script where volume would affect the actual price bar body in a way that if there was say a >500% volume increase then the actual Bar would expand relative to the chart to show this, no need for another viewing pane, is there such an indicator already or is this even possible?

Angelo1

Reply With Quote




Last Updated on July 15, 2011


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts