[amibroker] How to calculate number of bars in amibroker from a given date

 

Dear Group,

 

I wish to calculate number of bars in amibroker from a given date. For the first date I am taking input from the parameter window.

 

fromdate = StrToDateTime( ParamDate("Start Date", "2016-01-01", 1 ) );
fromdatestr = DateTimetoStr(fromdate);

fromval = Lookup( Close, fromdate, -1 );
endval = C;
absreturn = endval-fromval;
perreturn = absreturn/fromval*100;

Now I wish to calculate average closing price over the start date till today so logic is :

 

AvgPrice = Cum(C,NoOfBars);

Now NoOfBars is from the start date. How do I calculate this?

 

------------------------

 

Second Level of the same is calculating the number of days from Last Thursday (Expiry Day for the Indian Derivatives Markets) of earlier month, as also the Close of this Last Thursday.

 

The last Thursday can be got from following feed in AFL Function reference:

 

_SECTION_BEGIN("Last Thursday");
function Lastthursday()
{
 Daysinmonth=IIf(Month()==1 OR Month()==3 OR Month()==5 OR Month()==7 OR Month()==8 OR Month()==10 OR Month()==12,31,30);
 Daysinmonthfeb=IIf(Year()%4 == 0 AND Year()%100!=0,29,28);
 Daysinmonthfinal=IIf(Month()==2,Daysinmonthfeb,Daysinmonth);
 returnvalue=IIf(Daysinmonthfinal-Day()<7 AND DayOfWeek()==4,1,0);
 return returnvalue;
}

_SECTION_END();

__._,_.___

Posted by: capitavp@yahoo.co.uk
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (1)

Upgrade your account with the latest Yahoo Mail app
Get organized with the fast and easy-to-use Yahoo Mail app. Upgrade today!

**** 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/


.

__,_._,___

Related Posts


EmoticonEmoticon

:)
:(
=(
^_^
:D
=D
=)D
|o|
@@,
;)
:-bd
:-d
:p
:ng
:lv