Exploration to find all stocks which are trading above the 200 day EMA & Stohastic <= 20?


#1

Dear All,

I need an exploration to find all stocks which are trading above the 200 day EMA & also the stochastic should be <= 20. My Stochastic settings in the chart are as follows: Stochastic %D(8,3,3) and Stochastic %K(8,3).

Do help me out…I tried myself but was not successful.

Regards,


#2

post your code please so one can correct the error.
just asking for code from someone i not very helpful as that person too has to make time to write it. Please be considerate of other’s time as well as you are of your own time.

Thus request you to post your code here.


#3
//This exploration is made to scan stocks were the Beta > 1.1 and Stochastic Crossover

inMonthly

ticker = ParamStr(“Ticker”,“nsenifty”);
P = Foreign(ticker,“C”,1);
Periods = Param(“period”,7,1,50,1);
AT = ATR(7);

// Calculation of Beta
Beta = ((Periods * Sum(ROC(C,1) * ROC(P,1),Periods)) - (Sum(ROC(C,1),Periods) * Sum(ROC(P,1),Periods))) /
((Periods * Sum((ROC(P,1)^2),Periods)) - (Sum(ROC(P,1),Periods)^2));

//Condition for Buy
BC = Beta > 1.1 AND StochK(8,3) > StochD(8,3,3);

//Stop Loss
SL = BC - (AT * 2);

//Target Price
FTP = BC + (AT * 3);
STP = BC + (AT * 6);

Filter = BC;

AddColumn(C,“Close”,1.2);
AddColumn(Beta,“Beta”,1.2);
AddColumn(AT,“ATR”,1.2);
AddColumn(BC,“Buy Price”,1.2,colorBlack,colorGreen);
AddColumn(SL,“SLP”,1.2,colorBlack,colorPink);
AddColumn(FTP,“FTP”,1.2,colorBlack,colorPaleGreen);
AddColumn(STP,“STP”,1.2,colorBlack,colorPaleGreen);

Do help me out to solve the errors

Regards,

Sonjoe


#4

Made some changes in the code… Pasting the code below:-

//This exploration is made to scan stocks were the Beta > 1.1 and Stochastic Crossover

TimeFrameSet( inMonthly ); // switch to Monthly time frame

ticker = ParamStr(“Ticker”,“nsenifty”);
P = Foreign(ticker,“C”,1);
Periods = Param(“period”,7,1,50,1);
AT = ATR(7);

// Calculation of Beta
Beta = ((Periods * Sum(ROC(C,1) * ROC(P,1),Periods)) - (Sum(ROC(C,1),Periods) * Sum(ROC(P,1),Periods))) /
((Periods * Sum((ROC(P,1)^2),Periods)) - (Sum(ROC(P,1),Periods)^2));

//Condition for Buy
BC = Beta > 1.1 AND StochK(8,3) > StochD(8,3,3);

//Stop Loss
SL = BC - (AT * 2);

//Target Price
FTP = BC + (AT * 3);
STP = BC + (AT * 6);

Filter = BC;

AddColumn(C,“Close”,1.2);
AddColumn(Beta,“Beta”,1.2);
AddColumn(AT,“ATR”,1.2);
AddColumn(BC,“Buy Price”,1.2,colorBlack,colorGreen);
AddColumn(SL,“SLP”,1.2,colorBlack,colorPink);
AddColumn(FTP,“FTP”,1.2,colorBlack,colorPaleGreen);
AddColumn(STP,“STP”,1.2,colorBlack,colorPaleGreen);


#5

By the looks of it alone, this is a half baked code, … hacked and edited from different afl’s, without giving an honest and sincere attempt to solve and yet asking a fully confused question.

Just referencing the TimeFrameSet() in the formula editor will give you a detailed explaniation of how to write the function expression. In case you don’t know how to use it, do this. Open the afl in formula editor, place your cursor right in the middle of the function that you want a referance for, in this case, TimeFrameSet, right click, look at the new popup menu and go to the last option in this menu “Function Rerefance”. This will open an AFL referance window of the relavant function and you can use the correct usage of it. There are also examples given in the same and also various AFL codes where the function is used which can thus be used as a ready referance.

Next, u don’t even need to use a timeframeset function here. Comment it out by putting “//” in the begning of that line and see that it turns to green. Just running the exploration in Daily mode will give u the desired result. Also make sure that the ticker of “nsenifty” is there in the database else nothing will showup on the scan. As in my case, i had to change it to Nifty instead of nsenifty. There was also an error of " in the whole of the afl. If that is a case with u as well, copy that character, go to edit>replace and put the character in find what space and type the " character in the below space. Repeat the same for the close quote as well. This should do. Now run the exploration in daily mode.

What u asked in the first post of the thread is totally different from your third post. U should learn to write the correct question at least as someone is going to spend their time to make sense of it and answer. Since u changed the code in the third post, you should also have deleted your second post or edited to make it blank. Despite of the gibbrish that u posted, i have still replied and and have let u know what u should and should not do when asking questions on a public forum.

I am a member to some of the star forums on the net about the markets, and they are very strict and intolerant to such behaviour as your’s. If you had done the same thing there, …

Kindly take it as an advise from a senior and do better next time.
Let me know how it goes!


#6

Friend i’m new this AFL thing and i accept mistakes are there from my side. Even i was searching for a delete option but didnt find it. Well the going is tough with regard to learn AFL. I just go to other AFL forums and just try my things. This AFL code which i have written is not coming correct don’t really know how to correct.


#7

It’s very simple, if u have some decent experiance with afl coding. I can see that since u r new to this, it could be a bit of challange.

Did u do all that i told u? BTW, what is it that u wish to achieve by this code?

AFAIK, it is the Man and not the machine that wins the race. Just coping code is
not the best way to learn things. First have an understanding of the logic for which u want to formulate code. Just cause there is someones code out there which looks facinating and sophisticated is not something that will suit u as well.

Let me ask u a few things.
What is your experiance of the markets? how many years i,e?
What is your trading objective? Long term, medium term, short term, Intraday?
what is yur risk appetite? i.e how much are u williing to loose per trade?
How often do u look at the markets, Full day, Once a day day for an hour, 3-4 days ina week?

These are some fundamental questions that one needs to have in place before one goes for the higher stuff. I suggest you first have these answers in place before anything else.

There is an Amibroker algo tutorial somewhe re in this site which teaches u basic and intermediae afl coding. Find that out and whatch it step by step. Tat will beimmense progress for you.

Let me know more!


#8

Hi Freelancer,

How are you? I’m very keen to learn AFL and would like to take any challenge when it comes to learning AFL.

I have an idea but don’t know how to implement it as AFL code. Yes i know human intervention is always necessary even if we code our idea. But once the code is working fine we can take away the psychological defect of the humans when it comes to trading.

I have been trading in the markets for almost 7 yrs both as an investor and trader. But over the years i realized that the brokers have been fooling me and only when i changed my account to Zerodha i knew that trading is just for professionals who are in the game and i need to learn a lot. From then on i have been lots of articles when it comes to trading and investing and i know its a vast ocean i’m just an ant in this whole new world. Still i’m struggling to Break Even.

When it comes to my trading objective i have both short term and long term objective so currently active in intra day trading and i would like to invest in some stocks when an opportunity arises. Regarding the risk appetite i just don’t want to blow my account and i always c when the trade goes wrong i suddenly do a square off and there is not point in waiting if the trade goes wrong. I’m pretty devoted to markets and active throughout the week whenever the markets are there.

Anyway i will be searching for the algo tutorial which u have said me to go through and let me c if i can learn some stuff over there. In case u get the link please do pass to me ok. Anyway i will do the seach incase i get i will ping you.

Hope i can discuss my ideas with u and in time as a small baby walks i will write some small AFL codes and will send it to you. ok .

Thank You for your time in advising me a lot and your just simple great no one was so kind enough to write a mail like that ya. You are my friend.

Thanking You,

Sonjoe


#9

Heree is the link. Very well written stuff.

Do it step by step and you will get the hang of it.
CUrrently i am trying to learn python & R. That’s the language what the pro’s use. Still there are vast oppentunities with amibroker too.
Go through the course. Guess it would take u a week or so for the whole thing. After finishing it, try to code what logic u have in mind. Then when u get stuck, post it on the forum and someone will surely work it out for u.

kindly add ur e-mail!

ATB!


#10

Hello Freelancer,

Good Morning to you and how are you doing? Well i’m not able to find the tutorials. Can u provide me the links and if any good sites available to that i can learn AFL coding step by step as a baby. Good to know that ur learning Python & R. I hope u already have good knowledge about programming.

Do share me the links and my email ID: sonjoejoseph@gmail.com and whatsapp No.8921768916. Do add me and do share ur whats app no ok

Thanking You,

With Regards,

Sonjoe


#11

Hello.
Why the link is not working for you? It’s working for me for sure.
I guess maybe you have to register with the Algoji site first. It is a perfect link. I have seen a few tutorials on the net for afl learning but this one is the best. So i would suggest you to learn from the said tutorial and not go beating around the bush.

Cheers.