Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers, Unverified Users Joined: 10/28/2004(UTC) Posts: 3,111 Location: Perth, Western Australia
Was thanked: 16 time(s) in 16 post(s)
|
Because I have finished my exams now !!! YAY !!! =D> :yahoo: :thumbup:
Here is my take on finding the change in the price in the last two calendar months of the chart...
--8<------------------------------
{Exploration}
{ColA - %}
theDay:=LastValue(DayOfMonth());
theMonth:=LastValue(Month());
theYear:=LastValue(Year());
{subtract two months}
theMonth:=theMonth-2;
{roll back years and days as necessary}
theYear:=If(theMonth<=0,theYear-1,theYear);
leapYear:=Mod(theYear,4)=0 AND Mod(theYear,100)<>0 OR Mod(theYear,400)=0;
theMonth:=If(theMonth<=0,theMonth+12,theMonth);
theDay:=
If(theMonth=4 OR theMonth=6 OR theMonth=9 OR theMonth=11,If(theDay>30,30,theDay),
If(theMonth=2 AND leapYear, If(theDay>29,29,theDay),
If(theMonth=2 AND leapYear=0,If(theDay>28,28,theDay),theDay)));
x:=Year()>theYear OR (Year()=theYear AND (Month()>theMonth OR Month()=theMonth AND DayOfMonth()>=theDay));
y:=x AND Alert(x=0,2);
i:=Cum(1)=1;
(x>0)*(100*C)/ValueWhen(1, y OR i,C);
--8<------------------------------
This will return a percentage change of the last close versus the close of the first bar traded two calendar months ago.
Set your filter as required, in this case you want a 190% rise in the period... so
--8<------------------------------
{Filter}
ColA>=190
--8<------------------------------
I hope you find this useful. Let me know if there are any bugs. ( I have had a few glasses of wine tonight, so expect anything from the code! :onebeer: :boire: )
wabbit :D
|