[amibroker] Custom volume histogram

 

Hi all, I'm trying to make a volume histogram like this: https://tradingpsychologyedge.com/wp-content/uploads/2015/09/Weis-Wave-2.png

ie in this histogram if on T0 (today) the share price closed higher than it opened (making it an up day), and yesterday was also an up day, todays volume is added to yesterdays volume and the total volume is displayed under todays share price. If another consecutive up day is encountered, the volume shown will now be the sum volume of all three up days. A similar process occurs if a down day follows a down day the day prior. The count resets once there is a change in trend between up/down days.

So far I have this:


_SECTION_BEGIN("Volume");
//Was today an up or down day. Up=r1=1, down=r1=-1
d1=IIf( (Close-Open) > 0, 1, -1);

//Was yesterday an up or down day.
//d2 is equal to the opening price yesterday
d2=Ref( O, -1);
//d3 is equal to the closing price yesterday
d3=Ref( C, -1);
//Was yesterday an up or down day. Up=d4=1, down=d4=-1
d4=IIf( (d3-d2) > 0, 1, -1);

//If both days were up or both down days, add the volume today to the day prior. Otherwise the volume count is reset and started again
//d5=volume today
d5=V;
//d6=volume yesterday
d6=Ref( V, -1);
//
d7=IIf ( (d1==1==d4), (V+d6), V);


Plot( d7, "Volume", IIf( C > O, ParamColor("Up Color", colorGreen ), ParamColor("Down Color", colorRed ) ),
ParamStyle( "Style", styleHistogram | styleThick, maskHistogram  ) );

_SECTION_END();


I think the problem is I can't figure out a way to get the volumes to recursively add to the days prior - ie the issue is with variable d7.

Any ideas?

__._,_.___

Posted by: siv_var@yahoo.com
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (1)
**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/


.

__,_._,___


EmoticonEmoticon