![]() |
|
| Discuss Need help for AFL at the AmiBroker within the Traderji.com - Discussion forum for Stocks Commodities & Forex; Hi, I got this code from amibroker website and would like to include the buy/long ... |
|
|||||||
| Notices |
![]() |
|
|
Thread Tools |
| Sponsored Links |
|
#1
|
|||
|
|||
|
Hi,
I got this code from amibroker website and would like to include the buy/long condition is reverse to the short . Could someone please help me out ? Thanks fCl = Ref(C,-1); fHigh = Ref(H,-1); fLow = Ref(L,-1); fAdvDrop = fCl - Ref(C,-2); fAtr = Ref(ATR(8),-1); diffHl = fHigh-fLow; fStoch = Ref(StochD(14),-1); fBBandTop=Ref(BBandTop(C,20,2),-1); fOpCond = fCl - 0.5 * fAtr; fOp = Ref(O,0); fStopLoss = fHigh + 0.5 * fAtr; bbTopSell = // The stock must first puncture and close outside (above) the upper Bollinger Band IIf( fCl > fBBandTop AND // The closer the closing price is to the high of the day, the better. fCl > (fLow + 0.75 * diffHL ) AND // And the bigger the day's advance, the better fAdvDrop > (1.5 * fAtr) AND // On the following day, the stock must 'gap' down below the prior day's close. // This 'gap down' is crucial as it serves as the most important criteria of // the entire strategy. fOp < fOpCond AND // Overbought condition added fStoch > 80, 1, 0 ); /* Exploration Columns for Sorting */ NumColumns = 10; Column0 = fOp; Column1 = fOpCond; Column2 = fStopLoss; Column0Name = "Open"; Column1Name = "OpenCond"; Column2Name = "StopLoss"; Column0Format = 1.2; Column1Format = 1.2; Column2Format = 1.2; Filter = bbTopSell == 1; Buy = 0; Sell = bbTopSell>0; |
|
#2
|
|||
|
|||
|
hai tican2
can u pls help me to plot daily and weekly mscd in daily price charts in amibroker. kurian joseph |
|
#3
|
|||
|
|||
|
dear tican2,
i have arranged your formula so that it is more understandable. pls see this. it is for ami4.8 or higher. else replace the addcolumns with the older one with numcolumns. ************************************** fCl = Ref(C,-1); // close yesterday fHigh = Ref(H,-1); // high yesterday fLow = Ref(L,-1); // low yesterday fAdvDrop = fCl - Ref(C,-2); // difference between yesterday and day before's close fAtr = Ref(ATR(8),-1); // last 8 days Average True Range till yesterday diffHl = fHigh-fLow; // difference between yesterday's high and low (range) fStoch = Ref(StochD(14),-1); //14 day slow stochastics as on yeaterday fBBandTop=Ref(BBandTop(C,20,2),-1); //bollinger band top fOpCond = fCl - 0.5 * fAtr; // opening condition gap down by .5 times ATR(8) from yesterday's close fOp = Ref(O,0); //today's opening fStopLoss = fHigh + 0.5 * fAtr; // stp loss at yesterday's high + .5 times ATR(8) // The stock must first puncture and close outside (above) the upper Bollinger Band bbTopSell = IIf( fCl > fBBandTop AND // The closer the closing price is to the high of the day, the better. fCl > (fLow + 0.75 * diffHL ) AND // And the bigger the day's advance, the better fAdvDrop > (1.5 * fAtr) // On the following day, the stock must 'gap' down below the prior day's close. // This 'gap down' is crucial as it serves as the most important criteria of // the entire strategy. AND fOp < fOpCond AND // Overbought condition added fStoch > 80, 1, 0 ); /* Exploration Columns for Sorting */ //NumColumns = 10; //Column0 = fOp; //Column1 = fOpCond; //Column2 = fStopLoss; //Column0Name = "Open"; //Column1Name = "OpenCond"; //Column2Name = "StopLoss"; //Column0Format = 1.2; //Column1Format = 1.2; //Column2Format = 1.2; AddColumn(fOp, "Open", 1.2); AddColumn(fOpCond, "OpenCond", 1.2); AddColumn(fStopLoss, "StopLoss", 1.2); AddTextColumn(FullName(), "Stock Name"); Filter = bbTopSell == 1; Buy = 0; Sell = bbTopSell>0; ************************************* now this formula has a big problem. by bollinger itself it is fine, but it does not take into account the direction of the trend. in case of strong trend, if u understand all the conditions you will see that a gap down of .5 * atr is very normal and prices can recover very rapidly in the direction of the main trend. see the attached charts on the last day for which signals were generated. the macd and all the three MAs are up...so this kind of trade becomes very risky as you are going against the trend EVEN WHEN PRICES ARE TRENDING UP. you are only depending upon an opening gap, which professionals will gladly fill. and STOC or RSI or any OSC is of no use as during trends, they will remain in overbought zones, often > 80. in spite of this do you want a downside break formula for buy? if u still want, i can try. btw pls read bb walk in bollinger on bollinger bands, where prices walk across the bb top during strong trends. |
|
#4
|
|||
|
|||
|
// Weekly MACD Histogran
_SECTION_BEGIN("Weekly MACD"); TimeFrameSet( inWeekly ); MACDw = MACD( 3, 10 ) - Signal( 3, 10, 16 ); MACDwLINE = MACD( 3, 10 ) ; MACDwSignal = Signal( 3, 10, 16); TimeFrameRestore(); Plot(MACDw,"MACD Weekly",colorDarkOliveGreen,styleHistogram); Plot(MACDwLINE,"MACD Weekly Line",colorRed,styleLine); Plot(MACDwSignal,"MACD Weekly Signal Line",colorBlue,styleLine); _SECTION_END(); please get it checked by someone like sunil or praveen daily macd // Daily MACD Histogram _SECTION_BEGIN("MACD"); r1 = Param( "Fast avg", 12, 2, 200, 1 ); r2 = Param( "Slow avg", 26, 2, 200, 1 ); r3 = Param( "Signal avg", 9, 2, 200, 1 ); Plot( ml = MACD(r1, r2), StrFormat(_SECTION_NAME()+"(%g,%g)", r1, r2), ParamColor("MACD color", colorRed ), ParamStyle("MACD style") ); Plot( sl = Signal(r1,r2,r3), "Signal" + _PARAM_VALUES(), ParamColor("Signal color", colorBlue ), ParamStyle("Signal style") ); Plot( ml-sl, "MACD Histogram", ParamColor("Histogram color", colorBlack ), styleNoTitle | ParamStyle("Histogram style", styleHistogram | styleNoLabel, maskHistogram ) ); _SECTION_END(); this was posted by someone in this forum...is it casoni? |
|
#5
|
|||
|
|||
|
hi beginner_av,
Thanks you for your help and comments . I understand the risk there . What i am after is the coding for the reverse ( buy position ) . Thanks Tican2 |
|
#7
|
|||
|
|||
|
Quote:
I think Tican is asking to edit the AFL, so that it gives BUY signal. If you see the AFL, it gives SELL signal alone. I've not went through the AFL; so can't comment much on it. Praveen. |
|
#8
|
|||
|
|||
|
hi beginner_av ,
You are correct , that is what i mean . Thanks Tican |
|
#9
|
|||
|
|||
|
This is the exact reverse of what u have given - buy when prices go and hit bb bottom and then gap up
fCl = Ref(C,-1); // close yesterday fHigh = Ref(H,-1); // high yesterday fLow = Ref(L,-1); // low yesterday fAdvDrop = Ref(C,-2) - fCl; // difference between yesterday and day before's close //where yesterday's close < day b4 yesterday close fAtr = Ref(ATR(8),-1); // last 8 days Average True Range till yesterday diffHl = fHigh-fLow; // difference between yesterday's high and low (range) fStoch = Ref(StochD(14),-1); //14 day slow stochastics as on yeaterday fOpCond = fCl + 0.5 * fAtr; // opening condition gap up by .5 times ATR(8) from yesterday's Close fOp = Ref(O,0); //today's opening fStopLoss = fLow - 0.5 * fAtr; // stp loss at yesterday's low - .5 times ATR(8) fBBandBottom=Ref(BBandBot(C,20,2),-1); //bollinger band bottom ***** // The stock must first puncture and close outside (below) the lower Bollinger Band bbBottomBuy = IIf( fCl < fBBandBottom AND // The closer the closing price is to the low of the day, the better. fCl < (fHigh - 0.75 * diffHL ) AND // And the bigger the previous day's decline, the better fAdvDrop > (1.5 * fAtr) AND // On the following day, the stock must 'gap' up above the prior day's close. // This 'gap up' is crucial as it serves as the most important criteria of // the entire strategy. fOp > fOpCond AND // Oversold condition added fStoch < 80, 1, 0 ); /* Exploration Columns for Sorting */ AddColumn(fOp, "Open", 1.2); AddColumn(fOpCond, "OpenCond", 1.2); AddColumn(fStopLoss, "StopLoss", 1.2); AddTextColumn(FullName(), "Stock Name"); Filter = bbBottomBuy == 1; Sell = 0; Buy = bbBottomBuy>0; in case u r looking for something else, do let me know. |
|
#10
|
|||
|
|||
|
hi Avi,
Thank you so much . That is what i really need . You have been a great help. Just a quick question . In the code you mentioned : // Oversold condition added fStoch < 80, 1, 0 ); Don't you mean : // Oversold condition added fStoch < 30, 1, 0 ); Thanks Tican |
| Sponsored Links |
|
|
![]() |
| Bookmarks |
| Thread Tools | |
|
|
Indemnity, Disclaimer & Disclosure
Notice:
• By visiting Traderji.com you indicate your acceptance of our Forum
Rules Disclaimer & Disclosure and indemnify Traderji.com, its
associates and related parties of all claims howsoever resulting from
the usage of the forum.
• 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. Traderji.com will not be liable for
any, direct or indirect, consequential or incidental damages or loss arising out of the use of this information.
• 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 of 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. If you 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.