[amibroker] Re: Trying to add to a scan.

 

Here's an example of what I think you wanted. Broke the lines down as best I could to explain the steps, always multiple ways to accomplish something in AFL. Sometimes nice to break everything into smaller lines for easier troubleshooting.

I'd also recommend starting with Introduction to AmiBroker - Blue Owl Press

 


Great guide to get started with the basics,

Also I often skim through http://www.amibroker.com/kb/2016/01/ and the users knowledge base. the users section doesn't allow new entries but its filled with great mini tutorial and information on AFL.


/*
Two options available, same results. Erase // from whatever line of ChangeLastWeek you wish, add // or delete other line to comment out
Uses TimeFrameSet to set to weekly bars Can also use the options for timeframe in settings menu in analysis window.
*/



TimeFrameSet(inWeekly); //Sets all following AFL from weekly bar values
//ChangeLastWeek= (Ref(C-1) - Ref(C,-2)) * 100 / C ; // cross multiplying to calculate percentage. ref(C,-1) = last weeks close, ref(C,-2) = Close 2 weeks ago
ChangeLastWeek = Ref(ROC(C,1),-1); // using RateofChange , ROC(C,1) calculates the change from last current bar and previous bar, using the Ref() we set it back one bar using Ref("Array",-1)
WeekGainVariable = 20; // plug in the variable for weekly gain(percentage);

ChangeLessThan = ChangeLastWeek <= WeekGainVariable;//change less then or equal to weekgainvariable
TimeFrameRestore();//resets time frame, good practice to restore timeframes as to not get confused with further AFL

Buy = ChangeLessThan;//buy and sell used in scan feature in analysis window
Sell = 0;

Filter =  ChangeLessThan;//filter used with explore feature in analysis window, allows use of AddColumn AFL down below
AddColumn(ChangeLastWeek," Change in Percent " , 1.2);//adds the ChangeSinceLastWeek array into column when "Filter = True"

__._,_.___

Posted by: brandon.richard03@yahoo.com
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (2)

Have you tried the highest rated email app?
With 4.5 stars in iTunes, the Yahoo Mail app is the highest rated email app on the market. What are you waiting for? The Yahoo Mail app is fast, beautiful and intuitive.

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