Traderji.com - Online community for Indian investors & traders!


Need to convert my strategy into amibroker script

Discuss Need to convert my strategy into amibroker script at the AmiBroker within the Traderji.com - Online community for Indian investors & traders!; Hi, I am not good in programming. I need help in converting following strategy into ...


Go Back   Traderji.com - Online community for Indian investors & traders! > TOOLS & RESOURCES > Software > AmiBroker


Reply
 
Thread Tools
  #1  
Old 15th December 2008, 06:59 PM
Member
 
Join Date: Aug 2008
Location: Delhi
Posts: 70
Thanks: 49
Thanked 143 Times in 40 Posts
yogesh-tiwari has a spectacular aura aboutyogesh-tiwari has a spectacular aura about
Exclamation 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


Advertisements

Reply With Quote
Advertisements
  #2  
Old 21st December 2008, 01:31 PM
Member
 
Join Date: Feb 2008
Posts: 524
Thanks: 0
Thanked 56 Times in 48 Posts
Bhulokeshwar will become famous soon enough
Default 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);

Filter=Buy OR Sell;
Sell=ExRem(Sell,Buy); Buy=ExRem(Buy,Sell);
AddColumn(Buy,"Buy");
AddColumn(Sell,"sell");
AddColumn(BuyPrice,"BuyPrice");
AddColumn(SellPrice,"SellPrice");
Reply With Quote
  #3  
Old 21st December 2008, 07:48 PM
Member
 
Join Date: Aug 2008
Location: Delhi
Posts: 70
Thanks: 49
Thanked 143 Times in 40 Posts
yogesh-tiwari has a spectacular aura aboutyogesh-tiwari has a spectacular aura about
Default 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 View Post
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");
Reply With Quote
  #4  
Old 21st December 2008, 10:40 PM
Member
 
Join Date: Feb 2008
Posts: 524
Thanks: 0
Thanked 56 Times in 48 Posts
Bhulokeshwar will become famous soon enough
Default 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);

Filter=Buy OR Sell;
Sell=ExRem(Sell,Buy); Buy=ExRem(Buy,Sell);
AddColumn(Buy,"Buy");
AddColumn(Sell,"sell");
AddColumn(BuyPrice,"BuyPrice");
AddColumn(SellPrice,"SellPrice");
Reply With Quote
  #5  
Old 21st December 2008, 10:50 PM
Member
 
Join Date: Feb 2008
Posts: 524
Thanks: 0
Thanked 56 Times in 48 Posts
Bhulokeshwar will become famous soon enough
Default 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
Reply With Quote
  #6  
Old 22nd December 2008, 10:56 AM
Member
 
Join Date: Aug 2008
Location: Delhi
Posts: 70
Thanks: 49
Thanked 143 Times in 40 Posts
yogesh-tiwari has a spectacular aura aboutyogesh-tiwari has a spectacular aura about
Default 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
Reply With Quote
  #7  
Old 22nd December 2008, 11:41 AM
Member
 
Join Date: Feb 2008
Posts: 524
Thanks: 0
Thanked 56 Times in 48 Posts
Bhulokeshwar will become famous soon enough
Default 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=Buy OR Sell;
Filter=Short OR Cover;
Sell=ExRem(Sell,Buy); Buy=ExRem(Buy,Sell);
Short=ExRem(Short,Cover); Cover=ExRem(Cover,Short);
AddColumn(Buy,"Buy");
AddColumn(Sell,"sell");
AddColumn(Short,"short");
AddColumn(Cover,"cover");
AddColumn(BuyPrice,"BuyPrice");
AddColumn(SellPrice,"SellPrice");
AddColumn(ShortPrice,"shortPrice");
AddColumn(CoverPrice,"coverPrice");
_SECTION_END();
Reply With Quote
The Following 2 Users Say Thank You to Bhulokeshwar For This Useful Post:
cbosein (15th November 2010), dishant4u (28th April 2010)
  #8  
Old 22nd December 2008, 06:43 PM
Member
 
Join Date: Aug 2008
Location: Delhi
Posts: 70
Thanks: 49
Thanked 143 Times in 40 Posts
yogesh-tiwari has a spectacular aura aboutyogesh-tiwari has a spectacular aura about
Default 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
Reply With Quote
  #9  
Old 24th December 2008, 12:42 AM
Banned
 
Join Date: Nov 2006
Posts: 91
Thanks: 3
Thanked 13 Times in 12 Posts
niklravi is on a distinguished road
Default 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
Reply With Quote
  #10  
Old 24th December 2008, 07:29 PM
Member
 
Join Date: Jun 2006
Posts: 14
Thanks: 0
Thanked 3 Times in 2 Posts
hemal_40009 is on a distinguished road
Default 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...

Advertisements

Reply With Quote
Reply

Bookmarks


Advertise Here


Thread Tools

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 Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT +5.5. The time now is 02:49 AM.

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.
 


Copyright © www.Traderji.com 2001 - , All rights reserved.

Recommended Websites - www.TradersEdgeIndia.com - www.TradingPicks.com - www.MasterOfTrading.com

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70