# Need to convert my strategy into amibroker script

 Discuss Need to convert my strategy into amibroker script at the AmiBroker within the Traderji.com; Hi, I am not good in programming. I need help in converting following strategy into ...

 Traderji.com Need to convert my strategy into amibroker script
 User Name Remember Me? Password
 Register FAQ Calendar Search Today's Posts Mark Forums Read

#1
15th December 2008, 05:59 PM
 Member Join Date: Aug 2008 Location: Delhi Posts: 70 Thanks: 49 Thanked 143 Times in 40 Posts
Need to convert my strategy into amibroker script

Hi,

I am not good in programming.
I need help in converting following strategy into Amibroker script.

Any help is appreciated.

*************************
I use 4 different EMAs.
3EMA
5EMA
13EMA
34EMA

Condition 1
-----------
When 13EMA is above 34EMA, initiate a long position.
Now, when 3EMA cuts 5EMA from upside moving towards downside, exit long position.

Condition 2
-----------
When 13EMA is below 34EMA, initiate a short position.
Now, when 3EMA cuts 5EMA from downside moving towards upside, exit short position.
*************************************

Regards
Yogesh
 Sorry your browser does not support IFRAME

## Looking for a share broker?

#2
21st December 2008, 12:31 PM
 Member Join Date: Feb 2008 Posts: 519 Thanks: 0 Thanked 56 Times in 48 Posts
Re: Need to convert my strategy into amibroker script

dear yogesh,try this

LongPer = Param("Long Period", 13, 30, 100, 5);
ShortPer = Param("Short Period", 34, 30, 100, 5);
LongPer1 = Param("Long Period1", 3, 30, 100, 5);
ShortPer1 = Param("Short Period1", 5, 30, 100, 5);

LongMA = EMA(C, LongPer);
ShortMA = EMA(C, ShortPer);
LongMA1 = EMA(C, LongPer1);
ShortMA1 = EMA(C, ShortPer1);
LastHigh = HHV(H, LongPer);
GraphXSpace = 10;
Plot(LongMA, " EMA(C, " + WriteVal(LongPer, 1) + ")", colorRed, styleLine);
Plot(ShortMA, " EMA(C, " + WriteVal(ShortPer, 1) + ")", colorBrightGreen, styleLine);
Plot(LongMA1, " EMA(C, " + WriteVal(LongPer1, 1) + ")", colorBlue, styleLine);
Plot(ShortMA1, " EMA(C, " + WriteVal(ShortPer1, 1) + ")", colorBrown, styleLine);

Buy = Cross(ShortMA, LongMA);
Sell = Cross(LongMA, ShortMA);
PlotShapes(shapeUpArrow * Buy, colorGreen, 0, L, - 10);
PlotShapes(shapeDownArrow * Sell, colorRed, 0, H, - 10);

#3
21st December 2008, 06:48 PM
 Member Join Date: Aug 2008 Location: Delhi Posts: 70 Thanks: 49 Thanked 143 Times in 40 Posts
Re: Need to convert my strategy into amibroker script

Hi Bhulokeshwar,

Thanks for creating this script for me.

There are few changes that we need to do..I 'd really appreciate, if you can pls do that for me.

1.Arrows are opposite.i.e. wherever sell arrow is indicated, it should be buy arrow and wherever buy arrow is indicated, it should be sell arrow.
2.When a Long is initiated, as per my strategy, the moment 3EMA cuts 5EMA, it should exit Long position.
3.When a Short is initiated, as per my strategy, the moment 3EMA cuts 5EMA, it should exit short position.

Once again, I thank you many for helping me.

Regards
Yogesh

Quote:
 Originally Posted by Bhulokeshwar dear yogesh,try this LongPer = Param("Long Period", 13, 30, 100, 5); ShortPer = Param("Short Period", 34, 30, 100, 5); LongPer1 = Param("Long Period1", 3, 30, 100, 5); ShortPer1 = Param("Short Period1", 5, 30, 100, 5); LongMA = EMA(C, LongPer); ShortMA = EMA(C, ShortPer); LongMA1 = EMA(C, LongPer1); ShortMA1 = EMA(C, ShortPer1); LastHigh = HHV(H, LongPer); GraphXSpace = 10; Plot(LongMA, " EMA(C, " + WriteVal(LongPer, 1) + ")", colorRed, styleLine); Plot(ShortMA, " EMA(C, " + WriteVal(ShortPer, 1) + ")", colorBrightGreen, styleLine); Plot(LongMA1, " EMA(C, " + WriteVal(LongPer1, 1) + ")", colorBlue, styleLine); Plot(ShortMA1, " EMA(C, " + WriteVal(ShortPer1, 1) + ")", colorBrown, styleLine); Buy = Cross(ShortMA, LongMA); Sell = Cross(LongMA, ShortMA); PlotShapes(shapeUpArrow * Buy, colorGreen, 0, L, - 10); PlotShapes(shapeDownArrow * Sell, colorRed, 0, H, - 10); Filter=Buy OR Sell; Sell=ExRem(Sell,Buy); Buy=ExRem(Buy,Sell); AddColumn(Buy,"Buy"); AddColumn(Sell,"sell"); AddColumn(BuyPrice,"BuyPrice"); AddColumn(SellPrice,"SellPrice");
#4
21st December 2008, 09:40 PM
 Member Join Date: Feb 2008 Posts: 519 Thanks: 0 Thanked 56 Times in 48 Posts
Re: Need to convert my strategy into amibroker script

hi
same thing i observed after posting.Now i am correcting it

LongPer = Param("Long Period", 13, 30, 100, 5);
ShortPer = Param("Short Period", 34, 30, 100, 5);
LongPer1 = Param("Long Period1", 3, 30, 100, 5);
ShortPer1 = Param("Short Period1", 5, 30, 100, 5);

LongMA = EMA(C, LongPer);
ShortMA = EMA(C, ShortPer);
LongMA1 = EMA(C, LongPer1);
ShortMA1 = EMA(C, ShortPer1);
LastHigh = HHV(H, LongPer);
GraphXSpace = 10;
Plot(LongMA, " EMA(C, " + WriteVal(LongPer, 1) + ")", colorBrightGreen, styleLine);
Plot(ShortMA, " EMA(C, " + WriteVal(ShortPer, 1) + ")", colorRed, styleLine);
Plot(LongMA1, " EMA(C, " + WriteVal(LongPer1, 1) + ")", colorBlue, styleLine);
Plot(ShortMA1, " EMA(C, " + WriteVal(ShortPer1, 1) + ")", colorBrown, styleLine);

Buy = Cross(LongMA, ShortMA);
Sell = Cross(ShortMA, LongMA);
PlotShapes(shapeUpArrow * Buy, colorGreen, 0, L, - 10);
PlotShapes(shapeDownArrow * Sell, colorRed, 0, H, - 10);

#5
21st December 2008, 09:50 PM
 Member Join Date: Feb 2008 Posts: 519 Thanks: 0 Thanked 56 Times in 48 Posts
Re: Need to convert my strategy into amibroker script

Dear yogesh
correction done for sl.no-1
but 2 and 3 rd iam not done because both are 3 and 5 ema are very close
so many time both will intersect in actual trading.even u want for exit ,i will do it either before 22/12 or later 28/12
#6
22nd December 2008, 09:56 AM
 Member Join Date: Aug 2008 Location: Delhi Posts: 70 Thanks: 49 Thanked 143 Times in 40 Posts
Re: Need to convert my strategy into amibroker script

Thanks Bhulokeshwar,

The reason I use 3EMA and 5EMA is becoz they give me target for the trade.

You are right, they intersect a lot in actual trading. However, in my manual testing that I tried(without your code, only tried it with excel and watching graph), it seems that most of the time when you are in trade and when 3EMA & 5EMA give exit signal, it rarely bounces back and continues the trade.

However, there are incidents when it bounces back like for eg. if you check the daily graph of nifty. This strategy suggests a sell on 12/9/08 and then on 19/9/08 it suggest to exit as the 3EMA and 5EMA cut each other.

Now, after such incident, a better idea would to book 50%profit when 3EMA and 5EMA intersect and then wait for 3EMA to further cut 13EMA and book remaining 50% and exit the trade completely.

Following the example quoted above, if you see, this strategy caught the oct downfall on 12/9/08 and when oct came it gave brilliant profit.

I am not sure, how many ppl here would agree with me on this strategy.
Nevertheless, I am thankful one soul at least for believing in me.

I wait for you..take your time.

Thanks again
Yogesh
#7
22nd December 2008, 10:41 AM
 Member Join Date: Feb 2008 Posts: 519 Thanks: 0 Thanked 56 Times in 48 Posts
Re: Need to convert my strategy into amibroker script

dear yogesh,good luck,i am giving complete afl as u required.do u want audible alarm also?
////////////////////////////////////////////
_SECTION_BEGIN("EMA CROSSOVER CHART");
LongPer = Param("Long Period", 13, 30, 100, 5);
ShortPer = Param("Short Period", 34, 30, 100, 5);
LongPer1 = Param("Long Period1", 3, 30, 100, 5);
ShortPer1 = Param("Short Period1", 5, 30, 100, 5);
LongMA = EMA(C, LongPer);
ShortMA = EMA(C, ShortPer);
LongMA1 = EMA(C, LongPer1);
ShortMA1 = EMA(C, ShortPer1);
LastHigh = HHV(H, LongPer);
GraphXSpace = 10;
Plot(LongMA, " EMA(C, " + WriteVal(LongPer, 1) + ")", colorBrightGreen, styleLine);
Plot(ShortMA, " EMA(C, " + WriteVal(ShortPer, 1) + ")", colorRed, styleLine);
Plot(LongMA1, " EMA(C, " + WriteVal(LongPer1, 1) + ")", colorBlue, styleLine);
Plot(ShortMA1, " EMA(C, " + WriteVal(ShortPer1, 1) + ")", colorBrown, styleLine);
Buy = Cross(LongMA, ShortMA);
Short = Cross(ShortMA, LongMA);
Cover = Cross(LongMA1, ShortMA1);
Sell = Cross(ShortMA1, LongMA1);
PlotShapes(shapeUpArrow * Buy, colorBrightGreen, 0, L, - 10);
PlotShapes(shapeDownArrow * Short, colorRed, 0, H, - 10);
PlotShapes(shapeUpArrow * Cover, colorBlue, 0, L, - 10);
PlotShapes(shapeDownArrow * Sell, colorBrown, 0, H, - 10);
Filter=Short OR Cover;
Short=ExRem(Short,Cover); Cover=ExRem(Cover,Short);
_SECTION_END();
 The Following 2 Users Say Thank You to Bhulokeshwar For This Useful Post: cbosein (15th November 2010), dishant4u (28th April 2010)
#8
22nd December 2008, 05:43 PM
 Member Join Date: Aug 2008 Location: Delhi Posts: 70 Thanks: 49 Thanked 143 Times in 40 Posts
Re: Need to convert my strategy into amibroker script

Hi,

Fantastic!!

Work Well Done!! Kudoos to you friend.

It now works exactly,the way I wanted it to.

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

Thank you very much.

God Bless

Take care

Regards
Yogesh
#9
23rd December 2008, 11:42 PM
 Banned Join Date: Nov 2006 Posts: 91 Thanks: 3 Thanked 13 Times in 12 Posts
Re: Need to convert my strategy into amibroker script

dear yogish
can you add volume in this afl to give a good entry point on an intraday?
like V> 1.5 X 20 MA of Vol then only buy

with regards
ravi
#10
24th December 2008, 06:29 PM
 Member Join Date: Jun 2006 Posts: 14 Thanks: 0 Thanked 3 Times in 2 Posts
Re: Need to convert my strategy into amibroker script

Sir i need and afl that plots DYNAMIC support and resistance lines on intraday charts along with entry and exit signals...i also need an indicator that plots red colour for selling pressure and green colour for buying pressure on intrday charts...

 Bookmarks

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is OffTrackbacks are Off Pingbacks are Off Refbacks are Off Forum Rules

All times are GMT +5.5. The time now is 12:51 PM.

Indemnity, Disclaimer & Disclosure Notice:
* By visiting Traderji.com you automatically indicate that you agree to our Forum Rules, Indemnity, Disclaimer & Disclosure Notice and General Content Disclaimer Notice and indemnify Traderji.com, its associates and related parties of all claims howsoever resulting from the usage of the forum/site.
* Disclaimer: Trading or investing in stocks & commodities is a high risk activity. Any action you choose to take in the markets is totally your own responsibility. You are recommended to make appropriate enquiries and seek appropriate advise before sending money, incurring any expenses, acting on recommendations or entering into any commitment in relation to any advertisement published here. Traderji.com does not vouch for any claims made by the advertisers of products and services. Traderji.com will not be held liable for any consequences in the event such claims are not honoured by the advertisers. Traderji.com will not be liable for any, direct or indirect, consequential or incidental damages or loss arising out of the use of any information by anybody mentioned anywhere on this site.
* Disclosure: The information in this forum is neither an offer to sell nor solicitation to buy any of the securities mentioned herein. The writers may or may not be trading in the securities mentioned.
* All names or products mentioned are trademarks or registered trademarks of their respective owners.
General Content Disclaimer Notice:
In light of our policy of encouraging candid, open exchanges of views and the rapid distribution of information originating from many sources, Traderji.com cannot determine the accuracy or legality of any information that may be uploaded to the forum. Opinions, advice and all other information expressed by participants in discussions are those of the author. You rely on such information at your own risk. You are urged to seek professional advice for specific, individual situations and not rely solely on advice or opinions given in the discussions. Since Traderji.com is an open and free discussion forum, any comments made by members of this forum in their posts reflect their own views and not of the owner or administrator of Traderji.com. Thus the owner/administrator indemnify themselves of all claims whatsoever and will not be liable or responsible for any members comments/views in this forum Traderji.com. Although we constantly delete all irrelevant content and/or SPAM, if you should find any objectionable or offensive posts made by members of this forum which you would like to bring to our notice for removal then please Contact Us.

 Advertise With Us - Forum Rules - Contact Us - Home - Archive - Privacy Statement - Top

Our Partner Websites: www.chittorgarh.com, IPO Investment Portal | www.topsharebrokers.com, Broker Comparision