Simple Coding Help - No Promise.

extremist

Well-Known Member
Hi,

I need help in writing an AFL exploration code for finding out the scrips whose Bollinger Band width is minimum in the last 6 months. Right now I am doing this manually with the help of Excel. I am using this code:

D = Sum(Close, 10)/10;
E = D + StDev(Close, 10);
F = D - StDev(Close, 10);
G = E - F;

Filter = 1;

AddColumn(Close, "Price");
AddColumn(G, "G");

In the AA window, in the Range section, I enter "from" and "to" dates and copy the output to Excel, click on column titled "G", click on Sort Ascending, choose "Expand the selection" and sort. Then I click on "Ticker" column, click on Sort Ascending, choose "Expand the selection" and again sort. Then I use "Find" function of Excel to see whether the "To" date I entered in the Range section appears at the top for that scrip or not.

Can anybody please help me to write the code to display the list of scrips in AA window or just flag them with a color?

******

i thought timeframeset would be usefull so asked u about the TF u used but it seems it is not working....
trying to find way with my limited knowledge.



*****

i tried but it looks out of my grasp.
i think it need some veteran.

hope they look in to it

the code i reached up to
****

pr=Param("lookback",150,0,200,1);
D = Sum(Close, 10)/10;
E = D + StDev(Close, 10);
F = D - StDev(Close, 10);
G = E - F;
Hh=HHV(g,pr);
Ll=LLV(g,pr);

Plot(g,"BD",colorBlack);
t=hh==Ref(Hh,-1);
b=ll==Ref(Ll,-1);
top=ExRem(t,b);
bot=ExRem(b,t);
PlotShapes(top*shapeUpArrow, colorGreen, 0, g, -28);
PlotShapes(bot*shapeDownArrow, colorRed, 0, g, -28);


Filter = 1;

AddColumn(Close, "Price");
AddColumn(G, "G");
 
Last edited:
Hi,

I need help in writing an AFL exploration code for finding out the scrips whose Bollinger Band width is minimum in the last 6 months. Right now I am doing this manually with the help of Excel. I am using this code:

D = Sum(Close, 10)/10;
E = D + StDev(Close, 10);
F = D - StDev(Close, 10);
G = E - F;

Filter = 1;

AddColumn(Close, "Price");
AddColumn(G, "G");

In the AA window, in the Range section, I enter "from" and "to" dates and copy the output to Excel, click on column titled "G", click on Sort Ascending, choose "Expand the selection" and sort. Then I click on "Ticker" column, click on Sort Ascending, choose "Expand the selection" and again sort. Then I use "Find" function of Excel to see whether the "To" date I entered in the Range section appears at the top for that scrip or not.

Can anybody please help me to write the code to display the list of scrips in AA window or just flag them with a color?

Code:
P = ParamField("Price field",-1);
Per = Param("Periods", 15, 2, 300, 1 );
W = Param("Width", 2, 0, 10, 0.05 );
BBT =  BBandTop( P, Per, W); 
BBB =  BBandBot( P, Per, W); 

BBW = BBT - BBB;

Bars_Since = 22 * 6;// Assumed 22 session in a month adjust this num as required

Filter = LLV(BBW,Bars_Since) == BBW; //Today is lowest of last 6 months

// Add the columns that you need in the exploration here . . .
Happy :)
 

extremist

Well-Known Member
Code:
P = ParamField("Price field",-1);
Per = Param("Periods", 15, 2, 300, 1 );
W = Param("Width", 2, 0, 10, 0.05 );
BBT =  BBandTop( P, Per, W); 
BBB =  BBandBot( P, Per, W); 

BBW = BBT - BBB;

Bars_Since = 22 * 6;// Assumed 22 session in a month adjust this num as required

Filter = LLV(BBW,Bars_Since) == BBW; //Today is lowest of last 6 months

// Add the columns that you need in the exploration here . . .
Happy :)

tht i also done in my code but just not added filter . coz i knew this won't work. as he needed.
it wont give the single lowest value of the 22*6 periods.
if the BB diff. is consistently falling every day LLV function will generate the continuous array of falling BBW points.

wht he want is the only lowest of the period he want.

i hope we can do this with some for loop?

*****
i think this is only he will get if we keep adding period frm param function or use it as fixed constant.

if at all he still want only single value then we will have to assign some range by begin value and endvalue and find min of tht range.

may be this time i'm correct.
 
Last edited:
Code:
P = ParamField("Price field",-1);
Per = Param("Periods", 15, 2, 300, 1 );
W = Param("Width", 2, 0, 10, 0.05 );
BBT =  BBandTop( P, Per, W); 
BBB =  BBandBot( P, Per, W); 

BBW = BBT - BBB;

Bars_Since = 22 * 6;// Assumed 22 session in a month adjust this num as required

Filter = LLV(BBW,Bars_Since) == BBW; //Today is lowest of last 6 months

// Add the columns that you need in the exploration here . . .
Happy :)
Many many thanks Happy Singh!

But there seems to be some difference between my code (if at all I can call it as "code") and your code as some scrips which were not in my exploration are appearing in yours and vice versa. For example, JILJALEQS has appeared in my exploration on 24/3/2014 whereas it didn't appear in yours. Similarly CENTURYTEX on 25/3/2014 in your list didn't appear in mine.
 
Many many thanks Happy Singh!

But there seems to be some difference between my code (if at all I can call it as "code") and your code as some scrips which were not in my exploration are appearing in yours and vice versa. For example, JILJALEQS has appeared in my exploration on 24/3/2014 whereas it didn't appear in yours. Similarly CENTURYTEX on 25/3/2014 in your list didn't appear in mine.
Try changing parameter values to make it same as what you need/want . . .

Your excel formula is calculating 1 SD for 10 days period

Amibroker standard one used 15 days with SD 2

Happy :)
 
Hello,
Need help is coding a PArabolic sar exit.I want to use the SAR as the trailing stop loss. the point is, SAR is a continuous indicator i.e once it is hit it changes the direction, where as i am looking out is...
1) SAR should start once the buy/short condition is filled, and if not filled SAR should not show up. for instance: buy is on the cross over of EMA 10 & EMA 20 so the SAR should start once there is a crossover.
2) when the SAR is hit, the exit price should be the SAR value and not the close of the bar, in the backtest .

Hope my query is clear. do help me out.
 

nac

Well-Known Member
I am trying to get Buy/Sell/Short/Cover in ami exploration. I mean, alphabetical exploration, like how we get buy/sell under trade column when scanning.

Is that possible? If yes, how?

Thank you.
 
Sir i want afl working for my above strategy
I do this in manual, opening charts of few selected company and with pen & paper. I would now like that ami does that for me

Explaination
WHENEVER THE CANDLE BREAKS SUPPORT "SELL" IS TO BE TRIGGERED

How to find support:-
When a stock price is in uptrend lowest low between 2 high is the support. If the uptrend continued the support gets modified in the same manner.

and vice versa for triggering BUY
the image demonstrates the strategy

thanx in advance
is this poosible for amibroker
 

Attachments

pratapvb

Well-Known Member
I am trying to get Buy/Sell/Short/Cover in ami exploration. I mean, alphabetical exploration, like how we get buy/sell under trade column when scanning.

Is that possible? If yes, how?

Thank you.
you cannot have text that is variable....you could make variable and set them to +2 / -1 / -2 / +1 and then display that in a column

type = iif(buy, 2, 0) ;
type = iif(sell, -1, type) ;
type = iif(short, -2, type) ;
type = iif(cover, 1, type) ;

and display type in an addtional column
 
Last edited:
Sir i want afl working for my below strategy
I do this in manual, opening charts of few selected company and with pen & paper. I would now like that ami does that for me

Explaination
WHENEVER THE CANDLE BREAKS SUPPORT "SELL" IS TO BE TRIGGERED

How to find support:-
When a stock price is in uptrend lowest low between 2 high is the support. If the uptrend continued the support gets modified in the same manner.

and vice versa for triggering BUY
the image demonstrates the strategy

thanx in advance
is this poosible for amibroker
 

Similar threads