Traderji.com - Discussion forum for Stocks Commodities & Forex


Help me to create Amibroker AFL use with my formula

Discuss Help me to create Amibroker AFL use with my formula at the AmiBroker within the Traderji.com - Discussion forum for Stocks Commodities & Forex; Dear all, I am using stochastic oscillator crossover system for trading. My parameter is Sto.Osci ...


Go Back   Traderji.com - Discussion forum for Stocks Commodities & Forex > TOOLS & RESOURCES > Software > AmiBroker


Reply
 
Thread Tools
  #1  
Old 25th June 2010, 12:40 PM
Member
 
Join Date: Jun 2010
Posts: 110
Thanks: 78
Thanked 39 Times in 27 Posts
smarttrade is on a distinguished road
Default Help me to create Amibroker AFL use with my formula

Dear all,

I am using stochastic oscillator crossover system for trading. My parameter is Sto.Osci value 39,1 and moving average 3(E).


Here I have created AFL :-

uptrend= (StochK(39,3)>StochD(39,1,3));
downtrend=(StochK(39,3)<StochD(39,1,3));
Buy = Cross(uptrend,downtrend);
PlotShapes( shapeUpArrow * Buy, colorGreen,0,L,-12);
Sell = Cross(downtrend,uptrend);
PlotShapes( shapeDownArrow * Sell, colorRed,0,H,-12);

Above this code will show Buy & Sell Signal When Sto.Oscill Cross Above or Below Level. But I want buy and sell signal in below condition.

BUY CONDITION :- WHEN MARKET IS IN UPTREND [StochK(39,3) >StochD(39,1,3)] WE FIND WHICH CANDLE FIRST BREAK HIGH + 5 POINTS COMPARE WITH PRE.CANDLE HIGH THEN WANT SHOW HERE BUY SIGNAL.

SELL CONDITION :- WHEN MARKET IS IN DOWNTREND [StochK(39,3) <StochD(39,1,3)] WE FIND WHICH CANDLE FIRST BREAK LOW - 5 POINTS COMPARE WITH PRE.CANDLE LOW THEN WANT SHOW HERE SELL SIGNAL.





Here I attached Nifty Chart for Example.

Explanation :-

In this Above Chart, First 5 Candle is green . That means Sto.osci. (39,1) is Above The Moving Average (3) Line. But 4th Candle only (First) Breake Pre.Candle High + 5 Points.
So Here I want to get Buy Signal .

AND 6th & 7th Candle is Red. This means Sto.osci. (39,1) is Below The Moving Average (3) Line. But 7th Red Candle didnt Breake Pre.Candle Low. So Here is Continuing Our Long Trade.

8th and 9th Candle is Green and 9th Candle High also breake Pre.Candle High + 5. But Here we dont Get Buy Signal. Because Already we have Long Position. So we should wait only for Sell signal.

10th Candle is Red But 11th Candel didnt Breake 10th Candle Low. 12,15,18th also the same. [Compare the 17th red Candle low with 16th Candle low = 10 Points. But Pre.Candle 16 is Green] . So here also Contiuing our Long Position.

19th,20th,21st is green Candle and 21st candle is breake Pre.Candle High + 5. Here also we dont get Buy Signal . Because Already we have Long Position.

22nd and 23rd is red and 23rd Candle Breake Pre.Candle Low + 5 . So Here I want to get Sell signal.

24th Candle is Green But 25th Candle Didnt Breake High + 5 Points.

25th & 26th is Red Candle .------> Market closed.

This Day Total Trade : 1 Lot Long & 1 Lot Short.


Kindly Help Me to Create Buy & Sell Signal in My Condition.



Reply With Quote
Sponsored Links
  #2  
Old 28th June 2010, 01:21 AM
Member
 
Join Date: May 2010
Posts: 65
Thanks: 8
Thanked 62 Times in 33 Posts
nagarjuna13 will become famous soon enough
Default Re: Help me to create Amibroker AFL use with my formula

Can you check this?

uptrend= IIf( StochK(39,3) > StochD(39,3,3), 1, 0 );
downtrend=IIf( StochK(39,3)<StochD(39,3,3), 1, 0 );
BuyV = uptrend AND Ref(uptrend, -1) AND (H > ( Ref(H, -1) + 5));
SellV = downtrend AND Ref(downtrend,-1) AND (L > ( Ref(L, -1) - 5));

BuySB = BarsSince(Ref(BuyV,-1));
SellSB= BarsSince(Ref(SellV,-1));

Buy = BuyV AND BuySB > SellSB;
Sell = SellV AND BuySB < SellSB ;

It took couple of hours to get the logic of the last 2 lines.

I tried back testing of this and I did not get much from it. Is there another indicator that needs to be clubbed with this? or Any more theory that you can provide?

thank you
nagarjuna
Reply With Quote
The Following 2 Users Say Thank You to nagarjuna13 For This Useful Post:
singhboy (28th June 2010), smarttrade (28th June 2010)
  #3  
Old 28th June 2010, 07:34 PM
Member
 
Join Date: Mar 2008
Posts: 81
Thanks: 34
Thanked 112 Times in 59 Posts
vkunisetty will become famous soon enoughvkunisetty will become famous soon enough
Default Re: Help me to create Amibroker AFL use with my formula

smarttrade

Try the attached code

vidyasagar
Reply With Quote
The Following User Says Thank You to vkunisetty For This Useful Post:
smarttrade (28th June 2010)
  #4  
Old 28th June 2010, 08:02 PM
Member
 
Join Date: Jun 2010
Posts: 110
Thanks: 78
Thanked 39 Times in 27 Posts
smarttrade is on a distinguished road
Default Re: Help me to create Amibroker AFL use with my formula

Quote:
Originally Posted by nagarjuna13 View Post
Can you check this?

uptrend= IIf( StochK(39,3) > StochD(39,3,3), 1, 0 );
downtrend=IIf( StochK(39,3)<StochD(39,3,3), 1, 0 );
BuyV = uptrend AND Ref(uptrend, -1) AND (H > ( Ref(H, -1) + 5));
SellV = downtrend AND Ref(downtrend,-1) AND (L > ( Ref(L, -1) - 5));

BuySB = BarsSince(Ref(BuyV,-1));
SellSB= BarsSince(Ref(SellV,-1));

Buy = BuyV AND BuySB > SellSB;
Sell = SellV AND BuySB < SellSB ;

It took couple of hours to get the logic of the last 2 lines.

I tried back testing of this and I did not get much from it. Is there another indicator that needs to be clubbed with this? or Any more theory that you can provide?

thank you
nagarjuna
Dear Nagarjuna,
I dont know How to say Thanks to you. Exactly I was Expecting this. Thanks, Thanks, Thanks a lot.

Reply With Quote
  #5  
Old 30th June 2010, 12:53 AM
Member
 
Join Date: May 2010
Posts: 65
Thanks: 8
Thanked 62 Times in 33 Posts
nagarjuna13 will become famous soon enough
Default Re: Help me to create Amibroker AFL use with my formula

Quote:
Originally Posted by smarttrade View Post
Dear Nagarjuna,
I dont know How to say Thanks to you. Exactly I was Expecting this. Thanks, Thanks, Thanks a lot.

If possible, can you please respond to the following question? That will help me a lot.

Quote:
Originally Posted by nagarjuna13 View Post
I tried back testing of this and I did not get much from it. Is there another indicator that needs to be clubbed with this? or Any more theory that you can provide?
Reply With Quote
The Following User Says Thank You to nagarjuna13 For This Useful Post:
smarttrade (30th June 2010)
  #6  
Old 30th June 2010, 01:00 PM
Member
 
Join Date: Jun 2010
Posts: 110
Thanks: 78
Thanked 39 Times in 27 Posts
smarttrade is on a distinguished road
Default Re: Help me to create Amibroker AFL use with my formula

Dear Nagarjuna,

I am using this method for Trade Nifty Future in Intraday. Time Frame : 15 Min. If I get buy signal I will take 2 Lots in Nifty Future. I will Close 1 lot at Every 25 Points+ and Another 1 lot I will hold till 3.29 p.m.

Suppose I booked Ist lot in 25 points+. After that If I get sell signal I will Close that 1 lot Long Position & I will go Short 2 lots Nifty @ Sell Signal. Here also same first I will book one lot @ 25 Points Profit and another 1 Lot I will hold till 3.29 p.m..

Stop Loss :

For Buy : In Uptrend, Which Candle high Breake Pre.Candle High (Here We will get Buy Signal) I will put SL @ That Pre.Candle Low Value - 3 Points.

For Sell : In downtrend, Which Candle Low Break Pre. Candle Low (Here We will get Sell Signal) I will Put SL @ That Pre.Candle High Value + 3 Points .

In which Candle We get Buy or Sell Signal, I will use SL That Pre.Candle H/L value +/- 3 Points. I dont Modify this SL for Each Candle H/L .

One More Condition:

I will use this concept only for Intraday not for delivery. So everyday we should close all the position before market end. Another Day Morning We should get Fresh Signal. So we should add here one more condition If we get buy or Sell signal, We must check here Pre.Candle and Current Candle Date also Should be the Same Date. This will help to Avoid Continuing Yesterday's Signal.


One More Request Can You give your code with Add of this above Condition with SL? and I am trying to write this same concept for Metastock Expert. Can you help to this also?

Last edited by smarttrade; 30th June 2010 at 01:43 PM.
Reply With Quote
The Following User Says Thank You to smarttrade For This Useful Post:
nagarjuna13 (30th June 2010)
  #7  
Old 30th June 2010, 01:18 PM
Member
 
Join Date: Jun 2010
Posts: 110
Thanks: 78
Thanked 39 Times in 27 Posts
smarttrade is on a distinguished road
Default Re: Help me to create Amibroker AFL use with my formula

One More Query :-

I am using this sto.Oscillator value in Metastock :

%K Parameters Time Periods:39,Slowing:3
%D Parameters Time Periods:3.

But there Using Exponential Method. How Should this Exponential Method add in Amibroker Code.
Reply With Quote
  #8  
Old 30th June 2010, 11:33 PM
Member
 
Join Date: May 2010
Posts: 65
Thanks: 8
Thanked 62 Times in 33 Posts
nagarjuna13 will become famous soon enough
Default Re: Help me to create Amibroker AFL use with my formula

Quote:
Originally Posted by smarttrade View Post
One More Query :-

I am using this sto.Oscillator value in Metastock :

%K Parameters Time Periods:39,Slowing:3
%D Parameters Time Periods:3.

But there Using Exponential Method. How Should this Exponential Method add in Amibroker Code.
are you looking out for this?

http://www.amibroker.com/guide/afl/afl_view.php?id=44

Thank you
nagarjuna
Reply With Quote
The Following User Says Thank You to nagarjuna13 For This Useful Post:
smarttrade (1st July 2010)
  #9  
Old 30th June 2010, 11:34 PM
Member
 
Join Date: May 2010
Posts: 65
Thanks: 8
Thanked 62 Times in 33 Posts
nagarjuna13 will become famous soon enough
Default Re: Help me to create Amibroker AFL use with my formula

Quote:
Originally Posted by smarttrade View Post
Dear Nagarjuna,

I am using this method for Trade Nifty Future in Intraday. Time Frame : 15 Min. If I get buy signal I will take 2 Lots in Nifty Future. I will Close 1 lot at Every 25 Points+ and Another 1 lot I will hold till 3.29 p.m.

Suppose I booked Ist lot in 25 points+. After that If I get sell signal I will Close that 1 lot Long Position & I will go Short 2 lots Nifty @ Sell Signal. Here also same first I will book one lot @ 25 Points Profit and another 1 Lot I will hold till 3.29 p.m..

Stop Loss :

For Buy : In Uptrend, Which Candle high Breake Pre.Candle High (Here We will get Buy Signal) I will put SL @ That Pre.Candle Low Value - 3 Points.

For Sell : In downtrend, Which Candle Low Break Pre. Candle Low (Here We will get Sell Signal) I will Put SL @ That Pre.Candle High Value + 3 Points .

In which Candle We get Buy or Sell Signal, I will use SL That Pre.Candle H/L value +/- 3 Points. I dont Modify this SL for Each Candle H/L .

One More Condition:

I will use this concept only for Intraday not for delivery. So everyday we should close all the position before market end. Another Day Morning We should get Fresh Signal. So we should add here one more condition If we get buy or Sell signal, We must check here Pre.Candle and Current Candle Date also Should be the Same Date. This will help to Avoid Continuing Yesterday's Signal.


One More Request Can You give your code with Add of this above Condition with SL? and I am trying to write this same concept for Metastock Expert. Can you help to this also?
Thank you very much for taking time to explain this. I do not have live data flowing to my ami. So, I am not able to visualize this. I will work on this theoretically and let you know.

thank you
nagarjuna
Reply With Quote
The Following User Says Thank You to nagarjuna13 For This Useful Post:
smarttrade (1st July 2010)
  #10  
Old 1st July 2010, 12:26 PM
Member
 
Join Date: Jun 2010
Posts: 110
Thanks: 78
Thanked 39 Times in 27 Posts
smarttrade is on a distinguished road
Default Re: Help me to create Amibroker AFL use with my formula

Quote:
Originally Posted by nagarjuna13 View Post
are you looking out for this?

http://www.amibroker.com/guide/afl/afl_view.php?id=44

Thank you
nagarjuna

No Mr.Nagarjuna . I ask Method of use EMA in Sto.Osci. indicator.
Here I show example of Metastock Chart Option. Please see this Below Picture.
Here Method of moving average menu is available in Sto.Osci. Properties Window.
I am using 39,3,3 & Selected EMA Method.
How should add this EMA option in Amibroker Sto.Oscill ? .










I got this below Example AFL in Amibroker website. Here Using Sto.Osci. in EMA Method. Kindly see this .

************************************************** *
/*StochK/StochD Crossover for A single ticker.

Enters long on stochastic indicator when EMA StochD line crosses the EMA StochK
line. Exit on reversing signals only.

Sequence: To run optimisation remove // in front of lines with optimization
instructions (the 3 lines in the praragraph below) and place // in front of line
with specific STK, STD and pds per ticker (3 lines in 2nd paragraph below). Set
range, click apply to current stock and run optimisation.
Insert the optimized figures in ( STK=, STD= and pds=) statement of 2nd
paragraph below.
Once completed replace // in front of optimization instruction lines (1st
paragraph below), remove // in front of line with specific STK, STD and pds (2nd
paragraph below), save file and click on scan, explore or backtest. These
formulas can also be used as indicator.

Each optimisation requires 729 optimisation steps.*/

/*1st paragraph.*/
STK=Optimize ("StK" , 14, 2, 18, 2); //*Remove // before STK for optimization,
replace for scan, exploration & backtesting.
STD=Optimize ("StD" ,14, 2, 18, 2); //*Remove // before STD for optimization,
replace for scan, exploration & backtesting.
pds = Optimize("pds", 9,2,18,2); //*Remove // before pds for optimization,
replace for scan, exploration & backtesting.

/*2nd paragraph.*/

//STK= 14; //*Place // in front of STK before optimization, remove for scan,
exploration & backtesting.*//
//STD= 14; //*Place // in front of STD before optimization, remove for scan,
exploration & backtesting.*//
//pds= 14; //*Place // in front of pds before optimization, remove for scan,
exploration & backtesting.*//

STK=LastValue(STK);
STD=LastValue(STD);
pds = LastValue(pds);

Sell= Cross (EMA (StochD (STD),pds),EMA( StochK (STK),pds));
Buy= Cross (EMA(StochK (STK),pds),EMA( StochD (STD),pds));
Cover = Cross (EMA(StochK (STK),pds),EMA( StochD (STD),pds));
Short = Cross (EMA (StochD (STD),pds),EMA( StochK (STK),pds));


Filter=Buy OR Sell OR Short OR Cover;
Buy=ExRem(Buy,Sell); Sell=ExRem(Sell,Buy); Short=ExRem(Short,Cover);
Cover=ExRem(Cover,Short);
NumColumns = 2;
Column0 = EMA( StochK (STK),pds);
Column1 = EMA (StochD (STD),pds);

AddColumn(Buy,"Buy"); AddColumn(Sell,"sell"); AddColumn(Short,"short");
AddColumn(Cover,"cover");

Graph0 = EMA( StochK (STK),pds);
Graph1 = EMA (StochD (STD),pds);
Graph2 = (EMA( StochK (STK),pds) - EMA (StochD (STD),pds))*2;
Graph2Style = 2;
Graph2Color =1;


Title=Name()+" " +"StD% Cross StK%" + " "
+"%K="+WriteVal(Graph0,FORMAT=1.1)+", %D="+
WriteVal(Graph1,FORMAT=1.1)+
WriteIf(Graph0>Graph1," LONG position"," ")+
WriteIf(Graph1>Graph0," SHORT position","")+"; "+ " Delta" + "
"+WriteVal((Graph2/2),FORMAT=1.1)+"%";
************************************************** *******


Can you help me to add this EMA Method ?


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 07:55 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.
 


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 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247