└── Custom-Formulas ├── 01_3MA.afl ├── 02_2MA.afl ├── 52&26-Week High Low - by SIR.afl ├── 52w-H-L.afl ├── BG_Color.afl ├── Break_Out.afl ├── CANSLIM.afl ├── CANSLIM_Daily.afl ├── CDC PnT 1.1A2S indy.afl ├── CDC PnT 1.1A2S.afl ├── CDC PnT 1.1A2S_RSshort.afl ├── CRS.afl ├── Candle.afl ├── Change over Time.afl ├── DEMA FAN.afl ├── Daily - Strength.afl ├── Detecting double tops and bottoms.afl ├── DochianH.afl ├── DochianL.afl ├── Explore Most Active.afl ├── FL.afl ├── Formula 1.afl ├── IBD RS RANKING 1.afl ├── IBD RS RANKING.afl ├── Minervini_Trend_Template.afl ├── NS-EMA.afl ├── NS-HL.afl ├── NS-RSI.afl ├── P-L Over time.afl ├── PPBP.afl ├── Price (foreign) - IBD.afl ├── Price 5.afl ├── Price-Bar-IBD.afl ├── Price-Bar.afl ├── PullBack.afl ├── RANKING KAKA.afl ├── ROC_vs_SET.afl ├── ROC_vs_SET_RANK.afl ├── RSI - Relative Strength Index 4.afl ├── RSI-Explore.afl ├── Strength.afl ├── SupportResistance-Auto.afl ├── SupportResistance.afl ├── Volume Price Analysis - V.1.0.afl ├── Volume Spread Analysis.afl ├── Volume-IBD.afl ├── Zone - RSI.afl ├── chaloke-v1.afl ├── myKeltner.afl ├── my_MFI.afl ├── squeeze.afl ├── stock-200ma.afl ├── support_line.afl ├── volume at price group.afl └── xtl.afl /Custom-Formulas/01_3MA.afl: -------------------------------------------------------------------------------- 1 | {//MKC ===================================== 2 | SET = Foreign("SET","CLOSE"); 3 | } 4 | {//SIGNAL ================================== 5 | {//Liquidity 6 | Million = Optimize( "Million", 100, 100 , 100, 100 ); 7 | Value = Million*1000000; 8 | Liq = Sum(Avg*Volume,10) >= Value; 9 | } 10 | {//Indicator 11 | {//RSI 12 | Indy_RSI = RSI(14) > 66.66; 13 | } 14 | } 15 | {//MA 16 | {//Short 17 | Period_Short = Param("Short period",5); 18 | MA_Short = EMA(Close,Period_Short); 19 | } 20 | {//Medium 21 | Period_Medium = Param("Medium period",50,1,300); 22 | MA_Medium= EMA(Close,Period_Medium); 23 | } 24 | {//Long 25 | Period_Long = Param("Long Period",200,1,300); 26 | MA_Long = EMA(Close,Period_Long); 27 | } 28 | {//MAC - Moving Average Classification 29 | MAC = IIf(MA_Short > MA_Medium 30 | , IIf( MA_Medium > MA_Long , 1 //MA_Short > MA_Medium > MA_Long 31 | , 2) //MA_SHORT > MA_Medium < MA_Long 32 | ,IIf(MA_Medium > MA_Long,3 // MA_SHORT < MA_MEDIUM BUT > MA_LONG 33 | ,4)); // MA_SHORT < MA_MEDIUM < MA_LONG 34 | } 35 | } 36 | {//Price action on MA 37 | p_Cross_Short = IIf(Cross(C,MA_Short), 1, //Price Cross MA_Short. 38 | IIf( Low > MA_Short AND Ref(Close,-1) <= Ref(MA_Short,-1) ,2 , //Price jump over MA_Short 39 | 0)); 40 | p_Break_up_Short_Medium = Ref(Close,-1) < Ref(MA_Short,-1) AND Ref(Close,-1) < Ref(MA_Medium,-1) AND //Yesterday Close is lower both MA 41 | Close > MA_Short AND Close > MA_Medium; // Just one bar it goes up. 42 | } 43 | } 44 | {//Money Management 45 | PositionSize = -5; 46 | } 47 | {//Buy / Sell 48 | Buy = MAC == 1 AND (p_Cross_Short != 0) AND Liq; 49 | Sell = 0; 50 | } 51 | {//Stop Mode 52 | ApplyStop(stopTypeNBar,stopModeBars,7); 53 | } 54 | {// Trade Option 55 | SetOption("InitialEquity",700000); 56 | SetOption("MinShares",100); 57 | RoundLotSize = 100; 58 | 59 | SetOption("CommissionMode", 1); 60 | SetOption("CommissionAmount", 0.2); 61 | 62 | slippage = 0.019; 63 | 64 | numStocks = 20; 65 | SetOption( "MaxOpenPositions", numStocks ); 66 | 67 | settradedelays( 1, 1, 1, 1 ); 68 | BuyPrice = Open+(Open*slippage);//Open Next day 69 | SellPrice = Open-(Open*slippage); 70 | PriceRange = C > 0.9; 71 | //PositionScore = RS_Short; 72 | } 73 | {//Color 74 | prc_color = IIf( MAC == 1 AND C > MA_Short, colorGreen , 75 | IIf( MAC == 1 AND C < MA_Short, colorYellow , 76 | IIf( 77 | } 78 | {//Plot 79 | Plot(MA_Short,"MA_SHORT",ParamColor("MA_Short",colorGreen)); 80 | Plot(MA_Medium,"MA_Medium",ParamColor("MA_Medium",colorBlue)); 81 | Plot(MA_Long,"MA_Long",ParamColor("MA_Long",colorBlack)); 82 | } 83 | -------------------------------------------------------------------------------- /Custom-Formulas/02_2MA.afl: -------------------------------------------------------------------------------- 1 | {//Option 2 | //SetOption("NoDefaultColumns", True ); 3 | P = ParamField("Price field",-1); 4 | ShortTerm = Param("Short Term period",18,1,100,1); 5 | LongTerm = Param("Long Term period",118,20,500,1); 6 | } 7 | {//Moving Average 8 | ma18 = EMA( P, ShortTerm ); 9 | ma118 = MA( P, LongTerm ); 10 | pCrossma118 = Cross(C,ma118); 11 | Cross9Above50 = Cross( ma18, ma118 ); 12 | Cross9Below50 = Cross( ma118, ma18 ); 13 | Condition1 = Flip( Cross9Below50, Cross9Above50 ); 14 | Condition2 = Flip( Cross9Above50, Cross9Below50 ); 15 | Count1 = BarsSince( Condition1 ); // if you don't want to count the crossing bar, then "-1" 16 | Count2 = BarsSince( Condition2 ); 17 | } 18 | { // RSI 19 | rsiUp = RSI(55) > 55; 20 | } 21 | {// I like to make my Explorations "easy on the eyes" 22 | dynamic_color = IIf(Cross9Above50 OR Cross9Below50, colorYellow, colorDefault ); 23 | dynamic_color2 = IIf(Count1 >0, colorlime, colorDefault ); 24 | dynamic_color3 = IIf(Count2 >0, colorRose, colorDefault ); 25 | } 26 | {// Charting // 27 | PriceColor = IIf( ma18 >= ma118 AND C >= ma18, colorGreen , 28 | IIf( ma18 >= ma118 AND C < ma18 AND C >= ma118, colorBlue , 29 | IIf( ma18 >= ma118 AND C < ma18 AND C < ma118, colorBrown, 30 | IIf( ma18 < ma118 AND C >= ma118, colorYellow, 31 | IIf( ma18 < ma118 AND C < ma118 AND C >= ma18, colorYellow, 32 | IIf( ma18 < ma118 AND C < ma18, colorRed, colorBlack)))))); 33 | } 34 | _SECTION_BEGIN("Price"); 35 | SetChartOptions(0,chartShowArrows|chartShowDates); 36 | _N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) )); 37 | Plot( C, "Close", PriceColor, styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 38 | _SECTION_END(); 39 | _SECTION_BEGIN("Count"); 40 | //Plot( Count1, "Count1", colorGreen, styleThick ); 41 | //Plot( Count2, "Count2", colorRed, styleThick ); 42 | _SECTION_END(); 43 | {//Explorer 44 | liq = MA(Volume,10) * MA(Avg,10) > 3000000; 45 | Filter = pCrossma118; 46 | AddColumn( Close, "Close" ); 47 | AddColumn( ma18, "ma18", 1.2, colorDefault, dynamic_color ); 48 | AddColumn( ma118, "ma118", 1.2, colorDefault, dynamic_color ); 49 | AddColumn( Count1, "#bar Short GRT Long", 1.0, colorDefault, dynamic_color2 ); 50 | AddColumn( Count2, "#bar Long GRT Short", 1.0,colorDefault, dynamic_color3 ); 51 | } 52 | {//Back Testing Option 53 | SetOption("InitialEquity", 100000); 54 | SetOption("MaxOpenPositions", 100 ); 55 | PositionSize = -2; // invest 2% of portfolio equity in single trade 56 | priceRange = C > 0.8; 57 | } 58 | {//Back Testing 59 | Buy = rsiUp AND PriceColor == colorGreen AND (Ref(PriceColor,-1) == colorBlue OR Ref(PriceColor,-1) == colorYellow)AND liq AND priceRange; 60 | Sell = 0; 61 | } 62 | {//Apply Stop 63 | ApplyStop(stopTypeNBar, stopModeBars, 5); 64 | } -------------------------------------------------------------------------------- /Custom-Formulas/52&26-Week High Low - by SIR.afl: -------------------------------------------------------------------------------- 1 | //Amibroker 52&26-Week High Low By Agapol Chamnanpanich 2 | //Set up Chart 3 | _SECTION_BEGIN("Price"); 4 | SetChartOptions(0,chartShowArrows|chartShowDates); 5 | _N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) )); 6 | Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 7 | _SECTION_END(); 8 | //Set up Variable 9 | _SECTION_BEGIN("52&26-Week High Low System"); 10 | Hclose=HHV(H,252); 11 | Lclose= LLV(L,252); 12 | cal52 = (C-HHV(H,252))/(HHV(H,252))*100; 13 | cal26 = (C-HHV(H,126))/(HHV(H,126))*100; 14 | H1close=HHV(H,126); 15 | L1close= LLV(L,126); 16 | //Display on Left Chart 17 | Sha1 = EncodeColor(colorGreen) + "52-Week High = " + Hclose + "\n"; 18 | Sha2 = EncodeColor(colorRed) + "52-Week Low = " + Lclose + "\n"; 19 | Sha3 = EncodeColor(colorBlue) + "Off 52-Week High(%) = " + Cal52 + "\n"; 20 | Sha4 = EncodeColor(colorGreen) + "26-Week High = " + H1close + "\n"; 21 | Sha5 = EncodeColor(colorRed) + "26-Week Low = " + L1close + "\n"; 22 | Sha6 = EncodeColor(colorBlue) + "Off 26-Week High(%) = " + Cal26 + "\n"; 23 | _N(Title = StrFormat("{{NAME}} ({{INTERVAL}}), {{DATE}} ; {{OHLCX}}, V=%1.0f\n {{VALUES}}\n\n", V) + Sha1 + Sha2 + sha3 + sha4 + sha5 + Sha6); 24 | _SECTION_END(); 25 | _SECTION_BEGIN("MA"); 26 | P = ParamField("Price field",-1); 27 | Periods = Param("Periods", 10, 2, 300, 1, 10 ); 28 | Plot( MA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") ); 29 | _SECTION_END(); 30 | _SECTION_BEGIN("MA1"); 31 | P = ParamField("Price field",-1); 32 | Periods = Param("Periods", 40, 2, 300, 1, 10 ); 33 | Plot( MA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") ); 34 | _SECTION_END(); 35 | //Condition 36 | HI = Close > Ref(HHV(High,260),-1); 37 | LW = Close < Ref(LLV(Low,260),-1); 38 | //52 Week High Low 39 | High52 = HHV(High,250); 40 | Low52 = LLV(Low,250); 41 | Filter = 1; 42 | //26 Week High Low 43 | High26 = HHV(High,125); 44 | Low26 = LLV(Low,125); 45 | Filter = 1; 46 | //Off-52 Week High % 47 | Cal1 = (C-High52)/(High52)*100; 48 | //Off-26 Week High % 49 | Cal2 = (C-High26)/(High26)*100; 50 | //Diff of 52-26 Weeks 51 | Cal3 = High52-High26; 52 | //Display Column 53 | AddColumn(C,"Close",1.2,IIf(C>Ref(C,-1),colorGreen,colorRed)); 54 | AddColumn(High52,"High-52W",1.2,IIf(High52>Low52,colorGreen,colorRed)); 55 | AddColumn(Low52,"Low-52W",1.2,IIf(Low52Low26,colorGreen,colorRed)); 58 | AddColumn(Low26,"Low-26W",1.2,IIf(Low26 Ref(HHV(shigh,period),-1),1,0)); 19 | newlow = IIf(slowNul, 0 ,IIf(slow < Ref(LLV(slow,period),-1),1,0)); 20 | newhighs = newhighs + newhigh; 21 | newlows = newlows + newlow; 22 | AddToComposite( newhigh, "~newHL", "H" ); 23 | AddToComposite( newlow, "~newHL", "L" ); 24 | AddToComposite( IIf(shighNul,0,1), "~newHL", "I" ); 25 | } 26 | pctNewH = 100*newhighs/numStocks; 27 | pctNewL = 100*newlows/numStocks; 28 | //Plot(pctNewH, "% New High", ParamColor("Color",16), ParamStyle("Style",4)); 29 | Graph0 = foreign( "~newHL", "H"); -------------------------------------------------------------------------------- /Custom-Formulas/BG_Color.afl: -------------------------------------------------------------------------------- 1 | color = IIf( C > MA( C, 200 ), colorgreen, colorred); //Replace the condition here with your condition 2 | SetChartBkColor( LastValue(color)); 3 | Plot(C,"",colorBlack,styleCandle); 4 | Plot(MA(C,200),"",colorBlack,styleLine); 5 | -------------------------------------------------------------------------------- /Custom-Formulas/Break_Out.afl: -------------------------------------------------------------------------------- 1 | {//Init Options ===================================== 2 | SetOption("InitialEquity",900000); 3 | SetOption("MinShares",100); 4 | SetOption("NoDefaultColumns", True ); 5 | numStocks = 100; 6 | SetOption( "MaxOpenPositions", numStocks ); 7 | SetOption("CommissionMode", 1); 8 | SetOption("CommissionAmount", 0.2); 9 | settradedelays( 1, 0, 1, 1 ); // Buy - Sell on Next Day 10 | RoundLotSize = 100; 11 | slippage = 0.03; 12 | BuyPrice = Open+(Open*slippage); 13 | SellPrice = Open-(Open*slippage); 14 | } 15 | {//Liquidity 16 | liq = EMA(Close, 10) * MA(Volume,10) > 10000000; 17 | } 18 | {//Dochian Break Out 19 | hhvRange = Optimize("hhv Range", 260, 200, 520, 20); 20 | resistRange = Optimize("Short Range", 50, 10, 100, 10); 21 | HHVLongRange = HHV(Close, hhvRange); 22 | resistHHV = Ref(ROC(HHVLongRange,resistRange),-1) == 0; 23 | 24 | BOLong = Cross(Close, Ref( HHVLongRange, -1)); 25 | F_BOLong = BOLong AND resistHHV; 26 | } 27 | {//Buy Sell 28 | Buy = F_BOLong AND liq; 29 | Sell = 0; 30 | PositionSize = -1; 31 | } 32 | {//Apply Stop 33 | ndayStop = Optimize("nday Stop",5,3,20,1); 34 | ApplyStop(stopTypeNBar, stopModeBars, ndayStop); 35 | ApplyStop(stopTypeLoss, stopModePercent,ndayStop); 36 | } 37 | -------------------------------------------------------------------------------- /Custom-Formulas/CANSLIM.afl: -------------------------------------------------------------------------------- 1 | {//Options ===================================== 2 | SetOption("InitialEquity",600000); 3 | SetOption("MinShares",100); 4 | SetOption("NoDefaultColumns", True ); 5 | numStocks = 10; 6 | SetOption( "MaxOpenPositions", numStocks ); 7 | SetOption("CommissionMode", 1); 8 | SetOption("CommissionAmount", 0.2); 9 | settradedelays( 0, 1, 1, 1 ); 10 | RoundLotSize = 100; 11 | slippage = 0.03; 12 | BuyPrice = Open+(Open*slippage);//Open Next day 13 | SellPrice = Open-(Open*slippage); 14 | //BuyPrice = Max(Low,EMA(Close,20)); 15 | } 16 | 17 | {//MKC ===================================== 18 | SET = Foreign("SET","CLOSE"); 19 | } 20 | {//Comparative Relative Strength 21 | SET = Foreign("SET", "SET"); 22 | CRS_Month_Period = 4; 23 | CRS_Month = (C / Ref(C,-1 * CRS_Month_Period)) / (SET / Ref(SET, -1 *CRS_Month_Period)); 24 | CRS_Month_SCORE = 100 - (100 / (1+CRS_Month)); 25 | CRS_Quater_Period = 13; 26 | CRS_Quater = (C / Ref(C,-1 * CRS_Quater_Period)) / (SET / Ref(SET, -1 *CRS_Quater_Period)); 27 | CRS_Quater_SCORE = 100 - (100 / (1+CRS_Quater)); 28 | CRS_HalfYear_Period = 26; 29 | CRS_HalfYear = (C / Ref(C,-1 * CRS_HalfYear_Period)) / (SET / Ref(SET, -1 *CRS_HalfYear_Period)); 30 | CRS_HalfYear_SCORE = 100 - (100 / (1+CRS_HalfYear)); 31 | CRS_Year_Period = 52; 32 | CRS_Year = (C / Ref(C,-1 * CRS_Year_Period)) / (SET / Ref(SET, -1 *CRS_Year_Period)); 33 | CRS_Year_SCORE = 100 - (100 / (1+CRS_Year)); 34 | CRS_SCORE = (CRS_Year_SCORE ); 35 | } 36 | {//SIGNAL ================================== 37 | {//Liquidity 38 | Million = Optimize( "Million", 50, 50 , 800, 100 ); 39 | Value = Million*1000000; 40 | Liq = Sum(Avg*Volume,5) >= Value; 41 | VolMA = Volume > EMA(Volume,10); 42 | VolUp = Volume > Ref(Volume,-1); 43 | } 44 | 45 | {//Indicator 46 | rsi52w = RSI(52) > Ref(HHV(RSI(52),52),-1); 47 | rsi14 = Cross(RSI(14) ,66.66); 48 | } 49 | {//IBD RS Ranking 50 | tr_monthly = ( (C - Ref(C, -4)) / Ref(C, -4) * 100); 51 | tr_quaterly = ( (C - Ref(C, -13)) / Ref(C, -13) * 100); 52 | tr_halfyear = ( (C - Ref(C, -26)) / Ref(C, -26) * 100); 53 | tr_yearly = ( (C - Ref(C, -52)) / Ref(C, -52) * 100); 54 | ibd_rs_rank = (0.2*tr_monthly)+(0.3*tr_quaterly) + (0.2*tr_halfyear) + (0.1*tr_yearly); 55 | RS_Long = (0.2*tr_quaterly) + (0.3*tr_halfyear) + (0.5*tr_yearly); 56 | RS_Medium = (0.4*tr_quaterly) + (0.3*tr_halfyear) + (0.3*tr_yearly); 57 | RS_Short = (0.3*tr_monthly)+(0.3*tr_quaterly) + (0.2*tr_halfyear) + (0.1*tr_yearly); 58 | } 59 | {//Strength 60 | TwoYearHigh = HHV(High,104); 61 | YearHigh = HHV(High,52); 62 | YearLow = LLV(Low,52); 63 | C52=HHV(Close,52); 64 | C_H_52= (abs(C52-C)/C52)*100; 65 | Prv1YearHigh = Ref(YearHigh,-1); 66 | bo1Year = Cross(Close,Prv1YearHigh); 67 | bo2Year = Cross(Close,Ref(TwoYearHigh,-1)); 68 | 69 | H26 = HHV(High,26); 70 | P_H26 = Ref(H26,-1); 71 | boHalfYear = Cross(Close,P_H26); 72 | 73 | HighQuater = HHV(High,12); 74 | P_HighQuater = Ref(HighQuater,-1); 75 | BO_12 = Cross(Close,P_HighQuater); 76 | 77 | HighMonth = HHV(H,4); 78 | PrvHMonth = Ref(HighMonth,-1); 79 | bo1Month = Cross(C,PrvHMonth); 80 | 81 | hZone = YearHigh*0.8; 82 | rocStrength = ROC(Close,10) > ROC(Foreign("SET","Close"),10) 83 | AND ROC(Close,26) > ROC(Foreign("SET","Close"),26) 84 | AND ROC(Close,52) > ROC(Foreign("SET","Close"),52); 85 | PctfarYearHigh = (C-C52)*100/C52; 86 | } 87 | {// ROC vs SET Ranking 88 | Month_ROC = ROC(Close,4) - ROC(Foreign("SET","Close"),4); 89 | Quarter_ROC = ROC(Close,12) - ROC(Foreign("SET","Close"),12); 90 | HY_ROC = ROC(Close,26) - ROC(Foreign("SET","Close"),26); 91 | Y_ROC = ROC(Close,26) - ROC(Foreign("SET","Close"),26); 92 | Short_RANK = 0.5*Month_ROC + 0.3*Quarter_ROC + 0.15*HY_ROC + 0.05*HY_ROC; 93 | Medium_RANK = 0.25*Month_ROC + 0.25*Quarter_ROC + 0.25*HY_ROC + 0.25*HY_ROC; 94 | Long_RANK = 0.05*Month_ROC + 0.15*Quarter_ROC + 0.3*HY_ROC + 0.5*HY_ROC; 95 | } 96 | {// VCP -- Mark Minervini 97 | P_L26 = Ref(LLV(Low,26),-1); //Low of Half Year 98 | P_L12 = Ref(LLV(Low,12),-1); //Low of Quater 99 | P_L4 = Ref(LLV(Low,4),-1); //Low of Month 100 | HL_VCP = P_L4 > P_L12 AND P_L12 > P_L26; // Higher Low 101 | // --------------- 102 | // ----------------- 103 | // ----------- 104 | // ----------- 105 | // ------------------- 106 | // --------------- 107 | LH_VCP = Prv1YearHigh > P_H26 AND P_H26 >PrvHMonth; // Lower High 108 | PctDeptYearHigh_VCP = ( (Prv1YearHigh - P_L26) / Prv1YearHigh ) *100; 109 | PctDepth26_VCP = ( (P_H26 - P_L12) / Prv1YearHigh ) *100; 110 | PctDeptHighMonth_VCP = ( (PrvHMonth - P_L4) / Prv1YearHigh ) *100; 111 | VCP = HL_VCP AND LH_VCP AND Close > EMA(Close,50) AND 112 | ( 113 | PctDeptYearHigh_VCP >= PctDepth26_VCP 114 | AND PctDepth26_VCP >= PctDeptHighMonth_VCP 115 | ) AND ( PctDeptYearHigh_VCP <= 45); 116 | //AND (Close < Prv1YearHigh); 117 | } 118 | {//4 Weeks Resting 119 | L4 = Ref(LLV(Low,4),-1); 120 | RangeMonth = ((PrvHMonth-L4)/PrvHMonth)*100; 121 | } 122 | {//4 Weeks Tight Close 123 | maxC=Ref(HHV(C,4),-1); 124 | minC=Ref(LLV(C,4),-1); 125 | CSMonth=(maxC-minC)/maxC*100; 126 | } 127 | {//BarSince the high 128 | ResistPeriod = BarsSince( Prv1YearHigh > Ref(YearHigh,-2)); 129 | } 130 | {//Price vs EMA 131 | Mov0 = EMA(Close,10); 132 | Mov1 = EMA(Close,20); 133 | Mov2 = EMA(Close,50); 134 | P_EMA10 = Cross(Close,Mov0); 135 | P_EMA50 = Cross(Close,Mov2); 136 | PercOfEMA10 = (Close-Mov0)*100/Mov0; 137 | PercOfEMA50 = (Close-Mov2)*100/Mov2; 138 | } 139 | {// Price action on Moving Average 140 | //Price cross EMA 141 | pAc1 = Low <= Mov0*1.015 AND Close > Mov0; 142 | //In case that Low not completely touch MA AND Close going up 143 | pAc2 = Low <= Mov2*1.015 AND Low > Mov2; //Percent of low than come to EMA zone but not touch. 144 | {// Mov Avg 145 | MovTrend = IIf(Mov0 > Mov1 AND Mov1 > Mov2,1,0); 146 | } 147 | {// Keltner 148 | Periods = 130; 149 | Width = 5; 150 | 151 | CenterLine = MA( Close, Periods ); 152 | KTop = CenterLine + Width * ATR( Periods ); 153 | 154 | P_KTOP = Close >= KTop*0.98; 155 | } 156 | pricePBema10w = (pAc1 OR P_EMA10) AND ROC(C,3) < 0; 157 | pricePBema50w = (pAc2 OR P_EMA50) AND ROC(C,3) < 0; 158 | } 159 | {// Resistance 160 | resist4wHighMonth = Ref(ROC(HighMonth,4),-1) == 0; 161 | resist4wHighQuater = Ref(ROC(HighQuater,4),-1) == 0; 162 | resist4wHalfYearHigh = Ref(ROC(H26,4),-1) == 0; 163 | resist4wYearHigh = Ref(ROC(YearHigh,4),-1) == 0; 164 | } 165 | { //Profit/Loss % Change over Time 166 | // PARAMETERS 167 | TtD_Param = ParamList("Period","Day to Date|Week to Date|Month to Date|Year to Date",0); 168 | 169 | // VARIABLES 170 | FDayMonth = BarsSince(Month() != Ref(Month(),-1)); 171 | FDayYear = BarsSince(Year() != Ref(Year(),-1)); 172 | TtD_Period = IIf(TtD_Param == "Day to Date",1, 173 | IIf(TtD_Param == "Week to Date",DayOfWeek(), 174 | IIf(TtD_Param == "Month to Date",FDayMonth, 175 | IIf(TtD_Param == "Year to Date",FDayYear,0)))); 176 | // FORMULA 177 | TtD_Change = 100 * (Close - Ref(Close, -TtD_Period) ) / Ref(Close, -TtD_Period); 178 | } 179 | {// Specific Condition 180 | F_BO52 = bo1Year AND (resist4wYearHigh); 181 | F_BO26 = boHalfYear AND ( resist4wHalfYearHigh ); 182 | F_BO4 = bo1Month AND ( resist4wHighMonth ); 183 | RS_Up = Close > Mov2 AND ( RS_Long >= 20 AND RS_Long <= 35); 184 | } 185 | {//Multi Time Frame 186 | {//Daily 187 | TimeFrameSet( inDaily ); 188 | {//EMA10 Day is greater than yesterday 189 | Day_EMA10 = EMA(Close,10); 190 | Day_EMA10_Uptrend = Ref(Day_EMA10,-1) < Day_EMA10; 191 | } 192 | {// Close price is -x% from HalfYearHigh 193 | Day_HalfYear_High = Ref(HHV(high,130),-1); //HYH 194 | Day_Pct_Close_to_HYH = 100*(Day_HalfYear_High - Close)/Day_HalfYear_High; 195 | Day_Close_to_HYH = Day_Pct_Close_to_HYH < 3 AND Day_Pct_Close_to_HYH > 0; // Close in between 3 - 0 % 196 | } 197 | {// Close price is -x% from YearHigh 198 | Day_Year_High = Ref(HHV(high,260),-1); //YH 199 | Day_Pct_Close_to_YH = 100*(Day_Year_High - Close)/Day_Year_High; 200 | Day_Close_to_YH = Day_Pct_Close_to_YH < 3 AND Day_Pct_Close_to_YH > 0; // Close in between 3 - 0 % 201 | } 202 | TimeFrameRestore(); //Restore to default time 203 | } 204 | } 205 | {//C&H 206 | CupHandle = (Prv1YearHigh >= P_H26) 207 | AND Day_Close_to_HYH 208 | AND ResistPeriod > 4 209 | ; 210 | } 211 | {//Buy 212 | buyCon1 = (pAc1 OR pAc2 );//Price 213 | buyCon2 = 1;//Volume 214 | buyCon3 = rsi52w;//Indicator 215 | BO = bo1Year OR boHalfYear; 216 | Buy = F_BO52; 217 | } 218 | 219 | {//Sell 220 | sellCon1 = MACD() < 0; 221 | Sell = 0; 222 | } 223 | {//MANUAL CHECK 224 | prev = Ref(C,-1); 225 | result = c > prev; 226 | } 227 | {//Filter 228 | Filter = Liq AND C >= hzone; 229 | AddTextColumn( Name(), "Stock"); 230 | //AddColumn(CRS_SCORE,"CRS-RATING"); 231 | AddColumn(RSI(14),"RSI14",1.2,colorDefault, 232 | IIf(RSI(14)>=66.67, colorPaleGreen 233 | ,IIf(RSI(14)<=33.33 ,colorPink 234 | ,colorWhite) 235 | ) 236 | ); 237 | AddColumn(rsi52w,"RSI 52w Year High",1.2,colorDefault, 238 | IIf(rsi52w ,colorPaleGreen,colorWhite) 239 | ); 240 | // AddColumn(RSI(52),"RSI Year"); 241 | // AddColumn(rocStrength,"rocStrength",1.2,colorDefault,IIf(rocStrength,colorTurquoise,colorWhite)); 242 | AddColumn(PctfarYearHigh,"% of 52w Close",1.2,colorDefault, 243 | IIf(PctfarYearHigh >= -5 ,colorPaleGreen,colorWhite) 244 | ); 245 | AddColumn(VolMA,"V>MA10",1.2,colorDefault,IIf(VolMA,colorTurquoise,colorWhite)); 246 | AddColumn(RangeMonth,"HL4WS"); //H-L 4 Weeks Spread 247 | AddColumn(CSMonth,"C4WS"); //C 4 Weeks Spread 248 | AddColumn(CupHandle ,"Cup with Handle"); 249 | AddColumn(ResistPeriod, "Resist Period"); 250 | AddColumn(F_BO52,"1st 52wBO",1.2,colorDefault,IIf(F_BO52,colorPaleGreen,colorRose)); 251 | AddColumn(F_BO26,"1st 26wBO",1.2,colorDefault,IIf(F_BO26,colorPaleGreen,colorRose)); 252 | AddColumn(F_BO4,"1st 4wBO",1.2,colorDefault,IIf(F_BO4,colorPaleGreen,colorRose)); 253 | AddColumn(bo1Month,"4W B.O",1.2,colorDefault,IIf(bo1Month,colorPaleGreen,colorRose)); 254 | AddColumn(boHalfYear,"26W B.O",1.2,colorDefault,IIf(boHalfYear,colorPaleGreen,colorRose)); 255 | AddColumn(bo1Year,"52W B.O",1.2,colorDefault,IIf(bo1Year,colorPaleGreen,colorRose)); 256 | AddColumn(bo2Year,"2Y B.O",1.2,colorDefault,IIf(bo2Year,colorPaleGreen,colorRose)); 257 | AddColumn(pricePBema10w,"PB10w",1.2,colorDefault,IIf(pricePBema10w,colorPaleGreen,colorWhite)); 258 | AddColumn(pricePBema50w,"PB50w",1.2,colorDefault,IIf(pricePBema50w,colorPaleGreen,colorWhite)); 259 | AddColumn(ROC(Close,52),"ROC Year"); 260 | AddColumn(C_H_52,"% C of CY"); 261 | AddColumn(PercOfEMA10,"% of MA10",1.2); 262 | AddColumn(PercOfEMA50,"% of MA50",1.2); 263 | AddColumn(MovTrend,"MA Trend",1.2); 264 | AddColumn(TtD_Change,"P/L % to Date"); 265 | 266 | AddColumn(RS_Up,"RS_Long-UP",1.2,colorDefault,IIf(RS_Up,colorPaleGreen,colorRose)); 267 | AddColumn(VCP,"VCP"); 268 | } 269 | } 270 | 271 | {//POSITION ================================== 272 | /*Position Score*/ 273 | PositionScore = ROC(Close,5); 274 | 275 | /*Position Size*/ 276 | /* PositionRisk = 1; // how much (in percent of equity) we risk in single position 277 | TradeRisk = (BuyPrice - Moving)/BuyPrice; // trade risk in percent equals to max. loss percentage stop 278 | PctSize = PositionRisk / TradeRisk; 279 | PositionSize = -1*PctSize; 280 | */ 281 | //SetPositionSize(5, spsPercentOfEquity); 282 | //End Position Size 283 | 284 | } 285 | 286 | {//STOP ================================== 287 | ApplyStop(stopTypeLoss, stopModePercent, 10); 288 | ApplyStop(stopTypeTrailing, stopModePercent, 25); 289 | ApplyStop(stopTypeProfit, stopModePercent, 30); 290 | ApplyStop(stopTypeNBar,stopModeBars,3); 291 | } -------------------------------------------------------------------------------- /Custom-Formulas/CANSLIM_Daily.afl: -------------------------------------------------------------------------------- 1 | {//Options ===================================== 2 | SetOption("InitialEquity",600000); 3 | SetOption("MinShares",100); 4 | SetOption("NoDefaultColumns", True ); 5 | RoundLotSize = 100; 6 | 7 | SetOption("CommissionMode", 1); 8 | SetOption("CommissionAmount", 0.2); 9 | 10 | slippage = 0.01; 11 | 12 | numStocks = 10; 13 | SetOption( "MaxOpenPositions", numStocks ); 14 | 15 | settradedelays( 1, 1, 1, 1 ); 16 | BuyPrice = Open+(Open*slippage);//Open Next day 17 | SellPrice = Open-(Open*slippage); 18 | //BuyPrice = Max(Low,EMA(Close,20)); 19 | 20 | } 21 | 22 | {//MKC ===================================== 23 | SET = Foreign("SET","CLOSE"); 24 | } 25 | 26 | {//SIGNAL ================================== 27 | {//Liquidity 28 | Million = Optimize( "Million", 50, 50 , 800, 100 ); 29 | Value = Million*1000000; 30 | Liq = Sum(Avg*Volume,10) >= Value; 31 | VolMA = Volume > EMA(Volume,5)*1.5; 32 | VolUp = Volume > Ref(Volume,-1); 33 | } 34 | 35 | {//Indicator 36 | Indy = RSI(55) > Ref(HHV(RSI(55),260),-1); 37 | RSI_BO = Cross(RSI(14) ,66.66); 38 | } 39 | {//IBD RS Ranking 40 | tr_monthly = ( (C - Ref(C, -20)) / Ref(C, -20) * 100); 41 | tr_quaterly = ( (C - Ref(C, -65)) / Ref(C, -65) * 100); 42 | tr_halfyear = ( (C - Ref(C, -130)) / Ref(C, -130) * 100); 43 | tr_yearly = ( (C - Ref(C, -260)) / Ref(C, -260) * 100); 44 | RS_Long = (0.2*tr_quaterly) + (0.3*tr_halfyear) + (0.5*tr_yearly); 45 | RS_Medium = (0.20*tr_quaterly) + (0.3*tr_halfyear) + (0.3*tr_yearly); 46 | RS_Short = (0.3*tr_monthly)+(0.3*tr_quaterly) + (0.2*tr_halfyear) + (0.1*tr_yearly); 47 | } 48 | {//Strength 49 | HighHighYear = HHV(High,260); 50 | HighCloseYear=HHV(Close,260); 51 | Close_vs_HighCloseYear= (abs(HighCloseYear-C)/HighCloseYear)*100; 52 | Prev_HighHighYear = Ref(HighHighYear,-1); 53 | BO_Year = Cross(Close,Prev_HighHighYear); 54 | 55 | HighHalfYear = HHV(High,130); 56 | Prev_HighHalfYear = Ref(HighHalfYear,-1); 57 | BO_HalfYear = Cross(Close,Prev_HighHalfYear); 58 | 59 | HighQuarterly = HHV(High,65); 60 | Prev_HighQuarterly = Ref(HighQuarterly,-1); 61 | BO_Quarterly = Cross(Close,Prev_HighQuarterly); 62 | 63 | High_Monthly = HHV(H,20); 64 | Prev_High_Monthly = Ref(High_Monthly,-1); 65 | BO_Monthly = Cross(H,Ref(High_Monthly,-1)); 66 | 67 | hZone = HighHighYear*0.80; 68 | rocStrength = ROC(Close,10) > ROC(Foreign("SET","Close"),10) 69 | AND ROC(Close,130) > ROC(Foreign("SET","Close"),130) 70 | AND ROC(Close,260) > ROC(Foreign("SET","Close"),260); 71 | strength = rocStrength; 72 | C_vs_HighCloseYear = (C-HighCloseYear)*100/HighCloseYear; 73 | } 74 | 75 | {//Comparative Relative Strength 76 | SET = Foreign("SET", "SET"); 77 | CRS_Month_Period = 20; 78 | CRS_Month = (C / Ref(C,-1 * CRS_Month_Period)) / (SET / Ref(SET, -1 *CRS_Month_Period)); 79 | CRS_Month_SCORE = 100 - (100 / (1+CRS_Month)); 80 | CRS_Quater_Period = 65; 81 | CRS_Quater = (C / Ref(C,-1 * CRS_Quater_Period)) / (SET / Ref(SET, -1 *CRS_Quater_Period)); 82 | CRS_Quater_SCORE = 100 - (100 / (1+CRS_Quater)); 83 | CRS_HalfYear_Period = 130; 84 | CRS_HalfYear = (C / Ref(C,-1 * CRS_HalfYear_Period)) / (SET / Ref(SET, -1 *CRS_HalfYear_Period)); 85 | CRS_HalfYear_SCORE = 100 - (100 / (1+CRS_HalfYear)); 86 | CRS_Year_Period = 252; 87 | CRS_Year = (C / Ref(C,-1 * CRS_Year_Period)) / (SET / Ref(SET, -1 *CRS_Year_Period)); 88 | CRS_Year_SCORE = 100 - (100 / (1+CRS_Year)); 89 | CRS_SCORE = ( CRS_Month_SCORE + CRS_Quater_SCORE + CRS_HalfYear_SCORE ) /3; 90 | } 91 | {// VCP -- Mark Minervini 92 | Prev_LowHalfYear = Ref(LLV(Low,130),-1); //Low of Half Year 93 | Prev_LowQuarter = Ref(LLV(Low,65),-1); //Low of Quater 94 | Prev_LowMonthly = Ref(LLV(Low,20),-1); //Low of Month 95 | HigherLow_VCP = Prev_LowMonthly > Prev_LowQuarter AND Prev_LowQuarter > Prev_LowHalfYear; // Higher Low 96 | // --------------- 97 | // ----------------- 98 | // ----------- 99 | // ----------- 100 | // ------------------- 101 | // --------------- 102 | LowerHigh_VCP = Prev_HighHighYear >= Prev_HighHalfYear AND Prev_HighHalfYear >=Prev_High_Monthly; // Lower High 103 | PctDeptHighHighYear_VCP = ( (Prev_HighHighYear - Prev_LowHalfYear) / Prev_HighHighYear ) *100; 104 | PctDeptHighHalfYear_VCP = ( (Prev_HighHalfYear - Prev_LowQuarter) / Prev_HighHighYear ) *100; 105 | PctDeptHigh_Monthly_VCP = ( (Prev_High_Monthly - Prev_LowMonthly) / Prev_HighHighYear ) *100; 106 | VCP = HigherLow_VCP AND LowerHigh_VCP AND Close > EMA(Close,50) AND 107 | ( 108 | PctDeptHighHighYear_VCP >= PctDeptHighHalfYear_VCP 109 | AND PctDeptHighHalfYear_VCP >= PctDeptHigh_Monthly_VCP 110 | ) ;//AND ( PctDeptHighHighYear_VCP <= 205) 111 | //AND (Close < Prev_HighHighYear); 112 | } 113 | 114 | {//20 Weeks Resting 115 | High_Monthly = Ref(HHV(High,20),-1); 116 | L20 = Ref(LLV(Low,20),-1); 117 | RangeMonth = ((High_Monthly-L20)/High_Monthly)*100; 118 | } 119 | 120 | {//20 Weeks Tight Close 121 | maxC=Ref(HHV(C,20),-1); 122 | minC=Ref(LLV(C,20),-1); 123 | CSMonth=(maxC-minC)/maxC*100; 124 | } 125 | 126 | {//Price vs EMA 127 | Mov0 = EMA(Close,10); 128 | Mov1 = EMA(Close,20); 129 | Mov2 = EMA(Close,50); 130 | P_EMA20 = Cross(Close,Mov1); 131 | P_EMA50 = Cross(Close,Mov2); 132 | PercOfEMA10 = (Close-Mov0)*100/Mov0; 133 | PercOfEMA50 = (Close-Mov2)*100/Mov2; 134 | } 135 | 136 | {// Price action on Moving Average 137 | 138 | //Price cross EMA 139 | pAc1 = Low <= Mov1*1.015 AND Close > Mov1; 140 | //In case that Low not completely touch MA AND Close going up 141 | pAc2 = Low <= Mov2*1.015 AND Low > Mov2; //Percent of low than come to EMA zone but not touch. 142 | {// Mov Avg 143 | MovTrend = IIf(Mov0 > Mov1 AND Mov1 > Mov2,1,0); 144 | } 145 | {// Keltner 146 | Periods = 130; 147 | Width = 5; 148 | 149 | CenterLine = MA( Close, Periods ); 150 | KTop = CenterLine + Width * ATR( Periods ); 151 | 152 | P_KTOP = Close >= KTop*0.98; 153 | } 154 | } 155 | 156 | { //Profit/Loss % Change over Time 157 | // PARAMETERS 158 | TtD_Param = ParamList("Period","Day to Date|Week to Date|Month to Date|Year to Date",0); 159 | 160 | // VARIABLES 161 | FDayMonth = BarsSince(Month() != Ref(Month(),-1)); 162 | FDayYear = BarsSince(Year() != Ref(Year(),-1)); 163 | TtD_Period = IIf(TtD_Param == "Day to Date",1, 164 | IIf(TtD_Param == "Week to Date",DayOfWeek(), 165 | IIf(TtD_Param == "Month to Date",FDayMonth, 166 | IIf(TtD_Param == "Year to Date",FDayYear,0)))); 167 | // FORMULA 168 | TtD_Change = 100 * (Close - Ref(Close, -TtD_Period) ) / Ref(Close, -TtD_Period); 169 | } 170 | {// Specific Condition 171 | F_BO260 = BO_Year AND ( ROC(Close,260) <= 30 ); 172 | F_BO130 = BO_HalfYear AND ( ROC(Close,130) <= 35 ); 173 | RS_Up = Close > Mov2 AND ( RS_Long >= 20 AND RS_Long <= 35); 174 | } 175 | {//Buy 176 | buyCon1 = (pAc1 OR pAc2 );//Price 177 | buyCon2 = 1;//Volume 178 | buyCon3 = Indy;//Indicator 179 | BO = BO_Year OR BO_HalfYear; 180 | Buy = BO; 181 | } 182 | 183 | {//Sell 184 | sellCon1 = MACD() < 0; 185 | Sell = 0; 186 | } 187 | 188 | {//Filter 189 | Filter = C>=hZone AND Liq; 190 | AddTextColumn( Name(), "Stock"); 191 | AddColumn(CRS_SCORE,"CRS-RATING"); 192 | AddColumn(C_vs_HighCloseYear,"% of High Close Year",1.2,colorDefault,IIf(C_vs_HighCloseYear>=0,colorPaleGreen,colorRose)); 193 | AddColumn(HighHighYear,"Year High"); 194 | AddColumn(Strength,"Strength",1.2,colorDefault,IIf(Strength,colorTurquoise,colorWhite)); 195 | AddColumn(VolMA,"VolMA",1.2,colorDefault,IIf(VolMA,colorTurquoise,colorWhite)); 196 | AddColumn((pAc1 OR P_EMA20),"PB20d",1.2,colorDefault,IIf((pAc1 OR P_EMA20),colorPaleGreen,colorWhite)); 197 | AddColumn((pAc2 OR P_EMA50),"PB50w",1.2,colorDefault,IIf((pAc2 OR P_EMA50),colorPaleGreen,colorWhite)); 198 | AddColumn(BO_Monthly,"20W B.O",1.2,colorDefault,IIf(BO_Monthly,colorPaleGreen,colorRose)); 199 | AddColumn(BO_HalfYear,"130W B.O",1.2,colorDefault,IIf(BO_HalfYear,colorPaleGreen,colorRose)); 200 | AddColumn(BO_Year,"260W B.O",1.2,colorDefault,IIf(BO_Year,colorPaleGreen,colorRose)); 201 | AddColumn(ROC(Close,260),"ROC Year"); 202 | AddColumn(Close,"C.C"); 203 | AddColumn(Ref(Close,-260),"P.C"); 204 | AddColumn(RangeMonth,"HL20WS"); //H-L 20 Weeks Spread 205 | AddColumn(CSMonth,"C20WS"); //C 20 Weeks Spread 206 | AddColumn(Close_vs_HighCloseYear,"% C of CY"); 207 | AddColumn(PercOfEMA10,"% of MA10",1.2); 208 | AddColumn(PercOfEMA50,"% of MA50",1.2); 209 | AddColumn(MovTrend,"MA Trend",1.2); 210 | AddColumn(TtD_Change,"P/L % to Date"); 211 | AddColumn(F_BO260,"1st 260wBO",1.2,colorDefault,IIf(F_BO260,colorPaleGreen,colorRose)); 212 | AddColumn(F_BO130,"1st 130wBO",1.2,colorDefault,IIf(F_BO130,colorPaleGreen,colorRose)); 213 | AddColumn(RS_Up,"RS_Long-UP",1.2,colorDefault,IIf(RS_Up,colorPaleGreen,colorRose)); 214 | AddColumn(VCP,"VCP"); 215 | AddColumn(Indy,"RSI 55 Year High"); 216 | } 217 | } 218 | 219 | {//POSITION ================================== 220 | /*Position Score*/ 221 | PositionScore = ROC(Close,5); 222 | 223 | /*Position Size*/ 224 | /* PositionRisk = 1; // how much (in percent of equity) we risk in single position 225 | TradeRisk = (BuyPrice - Moving)/BuyPrice; // trade risk in percent equals to max. loss percentage stop 226 | PctSize = PositionRisk / TradeRisk; 227 | PositionSize = -1*PctSize; 228 | */ 229 | //SetPositionSize(5, spsPercentOfEquity); 230 | //End Position Size 231 | 232 | } 233 | 234 | {//STOP ================================== 235 | ApplyStop(stopTypeLoss, stopModePercent, 10); 236 | ApplyStop(stopTypeTrailing, stopModePercent, 25); 237 | ApplyStop(stopTypeProfit, stopModePercent, 30); 238 | ApplyStop(stopTypeNBar,stopModeBars,3); 239 | } -------------------------------------------------------------------------------- /Custom-Formulas/CDC PnT 1.1A2S indy.afl: -------------------------------------------------------------------------------- 1 | Pct = Param("%Change",1,0,100,1); 2 | RctPnT=Param("Recent PnT",1,1,100,1); 3 | Prc = MA((O + H + L + C)/4,2); 4 | Pk = Peak(H,Pct,RctPnT); 5 | Tr = Trough(L,Pct,RctPnT); 6 | Upper = Ref(ValueWhen(Pk!=Ref(Pk,-1),H,RctPnT),-1); 7 | Lower = Ref(ValueWhen(Tr!=Ref(Tr,-1),L,RctPnT),-1); 8 | bspu = BarsSince(Pk!=Ref(Pk,-1)); // 9 | //Plot(Upper,"",ParamColor("Upper",colorBlue),styleDashed); 10 | //Plot(Lower,"",ParamColor("Lower",colorOrange),styleDashed); 11 | Plot(Ref(Upper,-bspu),"support",ParamColor("support",colorGreen),styleDashed); 12 | for(i=0;i Upper); // 10 | bspl = BarsSince(Lower > Prc); 11 | Bullish = bspu < bspl; // 12 | Bearish = bspu > bspl; // 13 | } 14 | {//Moving Average 15 | Short_MA = EMA( Close , Optimize("Short MA",8,3,8,1)); 16 | } 17 | {//Keltner Band 18 | KPeriods = Param("Periods", 15, 2, 300, 1 ); 19 | KWidth = Param("Width", 2, 0, 10, 0.05 ); 20 | KColor = ParamColor("Color", colorCycle ); 21 | KStyle = ParamStyle("Style", styleLine | styleNoLabel); 22 | 23 | KCenterLine = MA( Prc, KPeriods ); 24 | KTop = KCenterLine + KWidth * ATR( KPeriods ); 25 | KBot = KCenterLine - KWidth * ATR( KPeriods ); 26 | } 27 | {//Liquidity 28 | Million = Optimize( "Million", 100, 100 , 800, 100 ); 29 | Value = Million*1000000; 30 | Liq = Sum(Avg*Volume,10) >= Value; 31 | } 32 | {//Volume 33 | VolCon = EMA(Volume,5) > EMA(Volume,10); 34 | } 35 | {//IBD RS Ranking 36 | tr_Month = ( (C - Ref(C, -10)) / Ref(C, -10) * 100); 37 | tr_Quater = ( (C - Ref(C, -65)) / Ref(C, -65) * 100); 38 | tr_HalfYear = ( (C - Ref(C, -130)) / Ref(C, -130) * 100); 39 | tr_Year = ( (C - Ref(C, -252)) / Ref(C, -252) * 100); 40 | RS_Long = (0.2*tr_Quater) + (0.3*tr_HalfYear ) + (0.5*tr_Year); 41 | RS_Medium = (0.4*tr_Quater) + (0.3*tr_HalfYear ) + (0.3*tr_Year); 42 | RSMW = Optimize("RSMW",0.1,0.1,0.6,0.1); 43 | RSMQ = (1-RSMW)/2; 44 | RSMH = (1-RSMW)/4; 45 | RSMY = (1-RSMW)/4; 46 | RS_Short = (RSMW*tr_Month)+(RSMQ *tr_Quater) + (RSMH*tr_HalfYear ) + (RSMY*tr_Year); 47 | //RS_Min = Optimize("RS_min",50,50,70,10); 48 | //RS_Max = Optimize("RS_max",150,100,200,20); 49 | } 50 | {//Color =========================== 51 | Green = IIf(Prc > Upper,1,0); 52 | Yellow = IIf(Bullish AND Prc < Upper,1,0); 53 | Red = IIf(Bearish AND Prc < Lower,1,0); 54 | Blue = IIf(Bearish AND Prc > Lower,1,0); 55 | Color=IIf(Green,ParamColor("Green",colorPaleGreen), // Price Go up 56 | IIf(Yellow,ParamColor("Yellow",colorGold), // Price Go up then pullback 57 | IIf(Red,ParamColor("Red",colorRed), // Price Go down 58 | IIf(Blue,ParamColor("Blue",colorBlue), // Price Go down then rebound 59 | ParamColor("Bullish",colorBlack)) // Undefind 60 | ) 61 | ) 62 | ); 63 | //End Color =========================== 64 | } 65 | {// Trade Option 66 | SetOption("InitialEquity",20000000); 67 | SetOption("MinShares",100); 68 | RoundLotSize = 100; 69 | //Commission detail 70 | SetOption("CommissionMode", 1); 71 | SetOption("CommissionAmount", 0.2); 72 | 73 | slippage = 0.019; 74 | 75 | numStocks = 200; 76 | SetOption( "MaxOpenPositions", numStocks ); 77 | SetOption("PriceBoundChecking",True); //checking and adjusting buyprice/sellprice arrays to current symbol High-Low range. 78 | SetOption("UsePrevBarEquityForPosSizing",True); //use previous bar closing equity to perform position sizing 79 | settradedelays( 1, 1, 1, 1 ); //Next Day Trade 80 | BuyPrice = Open+(Open*slippage);//Open Next day 81 | SellPrice = Open-(Open*slippage); 82 | PriceRange = C > 0.9; 83 | PositionScore = RS_Short; 84 | } 85 | {//Buy / Sell =========================== 86 | {//Other buy condition (Inactive) 87 | /* 88 | {//Original Code 89 | Buy = Bullish AND Ref(Bearish,-1); 90 | BuyPrice = ValueWhen(Buy,C,1); 91 | Long = 100*((C-BuyPrice)/BuyPrice); 92 | 93 | Sell = Bearish AND Ref(Bullish,-1); 94 | SellPrice = ValueWhen(Sell,C,1); 95 | Short = 100*((SellPrice-C)/SellPrice); 96 | } 97 | {//Buy @ first Green / Sell when Yellow 98 | Buy = IIf(Green > Ref(Green,-1),1,0) AND Liq; 99 | BuyPrice = Open; 100 | Sell = Yellow; 101 | SellPrice = Open; 102 | } 103 | {//Buy @Green AND RS_Short in (50,180) AND Liq = 100 AND PriceRange > 0.9THB AND VolCon EMA5 > EMA10 / Sell when NOT BUY - 2016 CAR = 70% 104 | Buy = Green AND (RS_Short >= RS_min AND RS_Short <= RS_max) 105 | AND Liq AND PriceRange AND VolCon; 106 | Sell = Close < Short_ma; 107 | Buy = ExRem(Buy,Sell); 108 | Sell = ExRem(Sell,Buy); 109 | } 110 | */ 111 | } 112 | {//Buy @Green AND Liq = 100 AND PriceRange > 0.9THB AND VolCon EMA5 > EMA10 / Sell when NOT BUY - 2016 CAR = 103% 113 | Buy = (Green) 114 | AND Liq AND PriceRange AND VolCon; 115 | Sell = Close < Short_Ma; 116 | Buy = ExRem(Buy,Sell); 117 | Sell = ExRem(Sell,Buy); 118 | } 119 | //END Buy / Sell ======================== 120 | } 121 | {//Money Management 122 | /*{// 1% Risk of portfolio 123 | PositionRisk = Optimize("Risk",2.5,0.5,3,0.5); // how much (in percent of equity) we risk in single position 124 | TradeRisk = (BuyPrice - Upper)/BuyPrice; // trade risk in percent equals to max. loss percentage stop 125 | PctSize = PositionRisk / TradeRisk; 126 | InitPositionSize = -1*PctSize; 127 | maxPositionSize = -20; 128 | PositionSize = IIf(InitPositionSize <= maxPositionSize , maxPositionSize , InitPositionSize); 129 | }*/ 130 | PositionSize = 100000; 131 | } 132 | {//Ploting 133 | _SECTION_BEGIN("Price Section"); 134 | Plot(Prc,"Prc",colorBlack); 135 | Plot(Upper,"",ParamColor("Upper",colorBlue),styleDashed); 136 | //Plot(Lower,"",ParamColor("Lower",colorOrange),styleDashed); 137 | Plot(C,"CDC PnT 1.1A2S",Color,64); 138 | shape = Buy * shapeUpArrow + Sell * shapeDownArrow; 139 | PlotShapes( shape, IIf( Buy, colorGreen, colorRed ), 0, IIf( Buy, Low, High ) ); 140 | Plot( KTop, "KBTop" + _PARAM_VALUES(), KColor, KStyle ); 141 | Plot( KBot, "KBBot" + _PARAM_VALUES(), KColor, KStyle ); 142 | /*{//Plot Risk 143 | currenRisk = 100*(Close-Upper)/Close; 144 | for( i = 0; i < BarCount; i++ ) 145 | { 146 | if( Buy[i] ) PlotText( "%"+currenRisk[ i ], i, L[ i ]-L[i]*0.1, colorRed ); 147 | if( Buy[i] ) PlotText( "CL@"+upper[ i ], i, L[ i ]-L[i]*0.15, colorRed ); 148 | 149 | } 150 | }*/ 151 | _SECTION_END(); 152 | } 153 | {//Filter - Exploration 154 | Filter = Buy OR Sell; 155 | } 156 | {// Column ============================= 157 | AddColumn(Buy OR Sell,"B/S",1.2,IIf(Buy ,colorGreen, colorRed)); 158 | // End Column ========================== 159 | } -------------------------------------------------------------------------------- /Custom-Formulas/CDC PnT 1.1A2S_RSshort.afl: -------------------------------------------------------------------------------- 1 | {//IBD RS Ranking 2 | tr_Month = ( (C - Ref(C, -10)) / Ref(C, -10) * 100); 3 | tr_Quater = ( (C - Ref(C, -65)) / Ref(C, -65) * 100); 4 | tr_HalfYear = ( (C - Ref(C, -130)) / Ref(C, -130) * 100); 5 | tr_Year = ( (C - Ref(C, -252)) / Ref(C, -252) * 100); 6 | RS_Long = (0.2*tr_Quater) + (0.3*tr_HalfYear ) + (0.5*tr_Year); 7 | RS_Medium = (0.4*tr_Quater) + (0.3*tr_HalfYear ) + (0.3*tr_Year); 8 | RSMW = Param("RSMW",0.1,0.1,0.6,0.1); 9 | RSMQ = (1-RSMW)/2; 10 | RSMH = (1-RSMW)/4; 11 | RSMY = (1-RSMW)/4; 12 | RS_Short = (RSMW*tr_Month)+(RSMQ *tr_Quater) + (RSMH*tr_HalfYear ) + (RSMY*tr_Year); 13 | RS_Min = Param("RS_min",50,50,70,10); 14 | RS_Max = Param("RS_max",180,100,200,20); 15 | Plot(IIf(RS_Short <= RS_Max AND RS_Short >= RS_Min,1,0),"RS_Short" ,colorBlue,styleArea|styleNoLabel); 16 | } -------------------------------------------------------------------------------- /Custom-Formulas/CRS.afl: -------------------------------------------------------------------------------- 1 | {//Comparative Relative Strength 2 | SET = Foreign("SET", "SET"); 3 | CRS_Month_Period = 4; 4 | CRS_Month = (C / Ref(C,-1 * CRS_Month_Period)) / (SET / Ref(SET, -1 *CRS_Month_Period)); 5 | CRS_Month_SCORE = 100 - (100 / (1+CRS_Month)); 6 | CRS_Quater_Period = 13; 7 | CRS_Quater = (C / Ref(C,-1 * CRS_Quater_Period)) / (SET / Ref(SET, -1 *CRS_Quater_Period)); 8 | CRS_Quater_SCORE = 100 - (100 / (1+CRS_Quater)); 9 | CRS_HalfYear_Period = 26; 10 | CRS_HalfYear = (C / Ref(C,-1 * CRS_HalfYear_Period)) / (SET / Ref(SET, -1 *CRS_HalfYear_Period)); 11 | CRS_HalfYear_SCORE = 100 - (100 / (1+CRS_HalfYear)); 12 | CRS_Year_Period = 52; 13 | CRS_Year = (C / Ref(C,-1 * CRS_Year_Period)) / (SET / Ref(SET, -1 *CRS_Year_Period)); 14 | CRS_Year_SCORE = 100 - (100 / (1+CRS_Year)); 15 | CRS_SCORE = ( CRS_Month_SCORE + CRS_Quater_SCORE + CRS_HalfYear_SCORE ) /3; 16 | 17 | CRS_High = Ref(HHV(CRS_SCORE, 200), -1); 18 | Plot(CRS_SCORE,"CRS-RATING",colorRed); 19 | } -------------------------------------------------------------------------------- /Custom-Formulas/Candle.afl: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////// 2 | 3 | /*Candle Stick Chart For Stock*/ 4 | 5 | /*Body Colors*/ 6 | Whitebody=C>=O; 7 | Blackbody=O>C; 8 | Realbody =abs(O-C); 9 | Realbodypercent = (Realbody/Ref(C, -1))*100; 10 | Range = H-L; 11 | Percentdiff =((C - Ref(C, -1))/Ref(C, -1))*100; 12 | Tiny = 0.25; 13 | Small = 1; 14 | Medium = 3; 15 | Large = 5; 16 | 17 | 18 | /*Body Size*/ 19 | Smallbody = Realbodypercent <= Small; 20 | Mediumbody =Small < Realbodypercent < Medium ; 21 | Largebody = Medium < Realbodypercent < Large ; 22 | Extralargebody = Realbodypercent >= Large; 23 | 24 | 25 | 26 | /*Shadows*/ 27 | Lowershadow = abs(Min(O,C) - L); 28 | Lowershadowpercent = ((abs(Min(O,C) - L))/Ref(C, -1))*100; 29 | Uppershadow =abs( H - Max(O,C)); 30 | Uppershadowpercent = ((abs( H - Max(O,C)))/Ref(C, -1))*100; 31 | 32 | Lowershadow1 = Min(Ref(O, -1) ,C) - Min(L,Ref(L,-1)); 33 | Uppershadow1 = Max(H, Ref(H,-1)) - Max(Ref(O, -1),C); 34 | Range1= Max(H, Ref(H,-1))-Min(L,Ref(L,-1)); 35 | Realbody1 =abs(C-Ref(O,-1)); 36 | 37 | Min1 = Min( L, Ref(L,-1)); 38 | Max1 = Max(H, Ref(H,-1)); 39 | Lowershadow2 = Min(Ref(O, -2) ,C) - Min(Min1, Ref(L,-2)); 40 | Uppershadow2 = Max(Max1,Ref(H,-2)) - Max(Ref(O, -2),C); 41 | 42 | Range2= Max(Max1,Ref(H,-2))-Min(Min1,Ref(L,-2)); 43 | Realbody2 =abs(C-Ref(O,-2)); 44 | Smalluppershadow= Uppershadowpercent <= Tiny; 45 | Smalllowershadow= Lowershadowpercent <= Tiny; 46 | 47 | Largeuppershadow= Uppershadowpercent >= Small; 48 | Largelowershadow= Lowershadowpercent >=Small; 49 | 50 | 51 | /*Gaps*/ 52 | Upgappoint = O - Ref(C,-1); 53 | Upgap= O >= (Ref(C, -1) + Ref(C, -1)*0.005); 54 | Downgap= O <= (Ref(C, -1) - Ref(C, -1)*0.005); 55 | 56 | /*Candlestick Chart Of Bullish Sentiment Start */ 57 | 58 | Abandonedbabybullish=Ref(Close,-2)<=Ref(Open,-2)*.99 AND Ref(High,-1)Ref(High,-1) AND Close>=Open*1.01 AND LLV(Low, 5)==Min(Low, Ref(Low,-1)); 59 | 60 | Abovethestomach= LLV(Low, 3)==Ref(Low,-1) AND Ref(C,-1) < Ref(O, -1) AND O > ((Ref(H,-1)+Ref(L,-1))/2) AND C >Ref(H,-1) AND C>O AND LLV(Low, 5)==Min(Low, Ref(Low,-1)); 61 | 62 | Beltholdbullish= LLV(Low, 5)==Low AND O> Ref(L,-1) AND C> O AND O<=L*0.99 AND LLV(Low, 5)==Min(Low, Ref(Low,-1)); 63 | 64 | Breakawaybullish = HHV(High,3)==High AND C >O AND Ref(LLV(Low, 5),-3)==Ref(L,-3) AND Ref(O,-3) < Ref(L, -3) AND Ref(L,-1) < Ref(L,-2) < Ref(L,-3) AND LLV(Low, 5)==Min(Low, Ref(Low,-1)) ; 65 | 66 | Engulfingbullish=OpenRef(High,-1) AND Close>=Open*1.01 AND LLV(Low, 5)==Low AND LLV(Low, 5)==Min(Low, Ref(Low,-1)); 67 | 68 | Hammer=Open>=(High-((High-Low)*.25)) AND Close>=(High-((High-Low)*.25)) AND LLV(Low,5)==Low AND LLV(Low, 5)==Min(Low, Ref(Low,-1)); 69 | 70 | Matchinghigh=HHV(High,8)==HHV(High,2) AND Ref(Close,-1)>=Ref(Open,-1)*.99 AND abs(High-Ref(High,-1))<=High*.0025 AND Open> Close AND LLV(Low, 5)==Min(Low, Ref(Low,-1)); 71 | 72 | Morningstar=Ref(Close,-2)<=Ref(Open,-2)*.99 AND Ref(Open,-1)<=Ref(Close,-2) AND Ref(Close,-1)<=Ref(Close,-2) AND Close>Ref(Close,-2) AND Close>=Open*1.01 AND LLV(Low,5)==Low AND LLV(Low, 5)==Min(Low, Ref(Low,-1)); 73 | 74 | Piercingline=Ref(Close,-1)<=Ref(Open,-1)*.99 AND Open=(Close+((Open-Close)*.5)) AND LLV(Low,5)==Low AND LLV(Low, 5)==Min(Low, Ref(Low,-1)); 75 | 76 | Threestarsinthesouth=LLV(Low,3)==LLV(Low, 13) AND (HHV(High, 3)-LLV(Low, 3))<=(HHV(High, 3)*.01) AND LLV(Low, 5)==Min(Low, Ref(Low,-1)); 77 | 78 | Tristarbullish=LLV(Low,8)==Ref(Low,-2) AND Ref(Close,-2)=(Ref(Low,-2)+((Ref(High,-2)-Ref(Low,-2))*.25)) AND Ref(Open,-1)>Ref(Close,-2) AND Ref(Low,-1)>Ref(Low,-2) AND Ref(Close,-1)>=(Ref(Low,-1)+((Ref(High,-1)-Ref(Low,-1))*.25)) AND Ref(Close,-1)Ref(Low,-1) AND High-Low<=(High*.01) AND LLV(Low, 5)==Min(Low, Ref(Low,-1)); 79 | 80 | 81 | 82 | /*Candlestick Chart Of Bearish Sentiment Start */ 83 | 84 | Abandonedbabybearish=Ref(Close,-2)>=Ref(Open,-2)*1.01 AND Ref(Low,-1)>Ref(High,-2) AND High Ref(O, -1) AND O < ((Ref(H,-1)+Ref(L,-1))/2) AND C < Ref(L,-1) AND C Ref(H,-1) AND C< O AND O>=H*0.99 AND HHV(High, 5)== Max(High, Ref(High, -1)); 89 | 90 | Breakawaybearish = LLV(Low,3)==Low AND C < O AND Ref(HHV(High, 5),-3)==Ref(H,-3) AND Ref(O,-3) > Ref(H, -3) AND Ref(H,-1) > Ref(H,-2) > Ref(H,-3) AND C=Ref(Close,-1)*1.01 AND Open>Ref(Close,-1) AND Close<=(Ref(Close,-1)-((Ref(Close,-1)-Ref(Open,-1))*.5)) AND HHV(High, 5)== Max(High, Ref(High, -1)); 93 | 94 | Engulfingbearish=Open>Ref(High,-1) AND Close=Ref(Open,-2)*1.01 AND Ref(Open,-1)>=Ref(Close,-2) AND Ref(Close,-1)>=Ref(Close,-2) AND Open<=Ref(Close,-1) AND Close<=Open*.99 AND HHV(High, 5)== Max(High, Ref(High, -1)) ; 97 | 98 | Matchinglow=LLV(Low,8)==LLV(Low,2) AND Ref(Close,-1)<=Ref(Open,-1)*.99 AND abs(Close-Ref(Close,-1))<=Close*.0025 AND Open>Ref(Close,-1) AND Open<=(High-((High-Low)*.5)) AND HHV(High, 5)== Max(High, Ref(High, -1)); 99 | 100 | Shootingstar=Low>Ref(High,-1) AND Open<=(Low+((High-Low)*.25)) AND Close<=(Low+((High-Low)*.25)) AND HHV(High, 5)== Max(High, Ref(High, -1)); 101 | 102 | Tristarbearish=HHV(High, 3)==HHV(High, 13) AND (HHV(High, 3)-LLV(Low, 3))<=( HHV(High, 3)*.01) AND HHV(High, 5)== Max(High, Ref(High, -1)); 103 | 104 | 105 | 106 | 107 | /*Candlestick Chart Of Bullish Sentiment Continuation */ 108 | 109 | Whitemarubuzu = Whitebody AND Realbodypercent >= 1.5 AND Smalluppershadow AND Smalllowershadow; 110 | 111 | Opiningwhitemarubuzu = Whitebody AND Realbodypercent >= 1.5 AND Smalluppershadow; 112 | 113 | Closingwhitemarubuzu = Whitebody AND Realbodypercent >= 1.5 AND Smalllowershadow; 114 | 115 | Concealingbabyswallow=Ref(Close,-3)<=Ref(Open,-3)*.99 AND Ref(Close,-2)<=Ref(Open,-2)*.99 AND Ref(Open,-1)Ref(Close,-2) AND Open>Ref(Close,-2) AND Close<=Ref(Close,-1) AND LLV(Low,2)==LLV(Low,8); 116 | 117 | Downsidegapthree=Ref(Close,-2)<=Ref(Open,-2)*.99 AND Ref(High,-1)Ref(Close,-2) AND LLV(Low,5)==Ref(Low,-1) ; 118 | 119 | Hangingman=Open>Ref(High,-1) AND Open>=(High-((High-Low)*.25)) AND Close>=(High-((High-Low)*.25)); 120 | 121 | Haramibullish=Ref(Close,-1)<=Ref(Open,-1)*.99 AND High<=Ref(Open,-1) AND Low>=Ref(Close,-1) AND Close>Open AND LLV(Low, 5) ==Low; 122 | 123 | Haramicrossbullish=Ref(Close,-1)<=Ref(Open,-1)*.99 AND HighRef(Close,-1) AND LLV(Low, 5) ==Low; 124 | 125 | Highpricegapping=Ref(Close,-4)>=Ref(Open,-4)*1.01 AND HHV(Ref(High, -1),3)<=Ref(High,-4) AND LLV(Ref(Low, -1), 3) >=Ref(Low,-4) AND Close>Open*1.01 AND Low>=Ref(High,-4); 126 | 127 | Kickingbullish=Ref(Close,-1)<=Ref(Open,-1)*.99 AND Low>=Ref(High,-1) AND Close>=Open*1.01; 128 | 129 | Mathold=Ref(Close,-4)>=Ref(Open,-4)*1.01 AND Ref(Low,-3)>Ref(High,-4) AND Ref(High,-1) Ref(Low,-4) AND OpenHHV(Ref(H,-1),3) AND Close>=Open*1.01; 130 | 131 | Meetinglinesbullish=Ref(Close,-1)<=Ref(Open,-1)*.99 AND abs(Close-Ref(Close,-1))<=Close*.0025 AND Close>=Open*1.01; 132 | 133 | Onneck=Ref(Close,-1)<=Ref(Open,-1)*.99 AND OpenOpen AND CloseRef(Open,-4) AND Ref(High,-3)>Ref(High,-4) AND Ref(High,-1)Ref(Low,-4) AND Close>=Open*1.01 AND Close>HHV(Ref(H,-1),3); 136 | 137 | Seperatinglinesbullish=Ref(Close,-1)<=Ref(Open,-1)*.99 AND abs(Open-Ref(Open,-1))<=Open*.0025 AND Close>=Open*1.01; 138 | 139 | Sidebysidewhitelinesbullish=HHV(High,2)==HHV(High,8) AND Ref(Close,-2)>=Ref(Open,-2)*1.01 AND Ref(Low,-1)>Ref(High,-2) AND Ref(Close,-1)>=Ref(Open,-1)*1.01 AND Low>Ref(High,-2) AND Open<=Ref(Open,-1)*1.005 AND Close>=Open*1.01; 140 | 141 | Sticksandwich=LLV(Low, 8)==LLV(Low, 3) AND Ref(Close,-2)<=Ref(Open,-2)*.99 AND Ref(Close,-1)>=Ref(Open,-1)*1.01 AND Ref(Close,-1)>=Ref(High,-2) AND Open>=Ref(High,-1) AND abs(Close-Ref(Close,-2))<=Close*.0025; 142 | 143 | Tasukigapbearish=Ref(Close,-2)<=Ref(Open,-2)*.99 AND Ref(High,-1)Ref(High,-1) AND High=Ref(Close,-2) AND Close>Ref(Open,-2); 146 | 147 | Threelinestrikebullish=Ref(Open,-2)Ref(Close,-3) AND Ref(Close,-1)>Ref(Close,-2) AND Ref(Close,-3)>=Ref(Open,-3)*1.01 AND Ref(Close,-2)>=Ref(Open,-2)*1.01 AND Ref(Close,-1)>=Ref(Open,-1)*1.01 AND Open>Ref(Close,-1) AND Close< LLV( Ref(Open,-1), 3); 148 | 149 | Threeriverbottom=Ref(Close,-2)<=Ref(Open,-2)*.99 AND Ref(Open,-1)>Ref(Close,-2) AND Ref(Close,-1)>Ref(Close,-2) AND Close>Open AND CloseRef(Close,-2) AND Ref(Open,-1)>=(Ref(High,-1)-((Ref(High,-1)-Ref(Low,-1))*.25)) AND Ref(Close,-1)>=(Ref(High,-1)-((Ref(High,-1)-Ref(Low,-1))*.25)); 150 | 151 | Threeoutsideup=Ref(Open,-1)Ref(High,-2) AND Ref(Close,-1)>=Ref(Open,-1)*1.01 AND Close>Ref(High,-1) AND Close>Open; 152 | 153 | Threewhitesoldiers=LLV(Low,8)==Ref(Low,-2) AND Ref(Open,-1)Ref(Close,-2) AND Close>Ref(Close,-1) AND Ref(Close,-2)>=Ref(Open,-2)*1.01 AND Ref(Close,-1)>=Ref(Open,-1)*1.01 AND Close>=Open*1.01; 154 | 155 | Windowrising = O>Ref(High,-1)*1.005 AND L>Ref(High,-1)*1.005; 156 | 157 | 158 | 159 | /*Candlestick Chart Of Bearish Sentiment Continuation */ 160 | 161 | 162 | Blackmarubuzu = Blackbody AND Realbodypercent >= 1.5 AND Smalluppershadow AND Smalllowershadow; 163 | 164 | Opiningblackmarubuzu = Blackbody AND Realbodypercent >= 1.5 AND Smalluppershadow; 165 | 166 | Closingblackmarubuzu = Blackbody AND Realbodypercent >= 1.5 AND Smalllowershadow; 167 | 168 | Advanceblock=Ref(Close,-2)>=Ref(Open,-2)*1.01 AND Ref(High,-1)>Ref(High,-2) AND Ref(Close,-1)>Ref(Open,-1) AND Close>Open AND High>Ref(High,-1) AND (Ref(Close,-1)-Ref(Open,-1))<(Ref(Close,-2)-Ref(Open,-2)) AND (Close-Open)<(Ref(Close,-1)-Ref(Open,-1)); 169 | 170 | Deliberation=Ref(Close,-2)>=Ref(Open,-2)*1.01 AND Ref(High,-1)>Ref(High,-2) AND Ref(Close,-1)>Ref(Open,-1)*1.01 AND Close>Open AND High>Ref(High,-1) AND (Close-Open)<(Ref(Close,-1)-Ref(Open,-1)); 171 | 172 | Fallingthree=Ref(Close,-4)Ref(High,-3) AND Ref(Low,-1)>Ref(Low,-3) AND HHV(Ref(H,-1),3) <= Ref(High,-4) AND Open>Ref(Low,-1) AND Close=Ref(Open,-1)*1.01 AND HighRef(Open,-1) AND HHV(High,5)==Ref(High,-1) ; 177 | 178 | Haramicrossbearish=Ref(Close,-1)>=Ref(Open,-1)*1.01 AND HighRef(Open,-1) AND HHV(High,5)==Ref(High,-1); 179 | 180 | Homingpigeon=Ref(Close,-1)<=Ref(Open,-1)*.99 AND High<=Ref(Open,-1) AND Low>=Ref(Close,-1) AND CloseOpen AND abs(Close-Ref(Close,-1))<=(Close*.0025); 183 | 184 | Lowpricegapping=Ref(Close,-4)Ref(Open,-1) AND Open>=Ref(Close,-1)*1.01 AND abs(Close-Ref(Close,-1))<=Close*.0025; 187 | 188 | Seperatinglinesbearish=Ref(Close,-1)>=Ref(Open,-1)*1.01 AND abs(Open-Ref(Open,-1))<=Open*.0025 AND Close=Ref(Open,-1)*1.01 AND Close>=Open*1.01; 191 | 192 | Tasukigapbullish=Ref(Close,-2)>=Ref(Open,-2)*1.01 AND Ref(Low,-1)>Ref(High,-2) AND Ref(Close,-1)>=Ref(Open,-1)*1.01 AND CloseRef(High,-2); 193 | 194 | Threeblackcrows=HHV(High,8)==Ref(High,-2) AND Ref(Open,-1)>Ref(Close,-2) AND Open>Ref(Close,-1) AND Ref(Close,-1)=Ref(Open,-2)*1.01 AND Ref(High,-1)Ref(Open,-2) AND CloseRef(Open,-2); 197 | 198 | Threelinestrikebearish=HHV(High,8)==Ref(High,-3) AND Ref(Open,-2)>Ref(Close,-3) AND Ref(Open,-1)>Ref(Close,-2) AND Ref(Close,-2)HHV(Ref(H,-1),3); 199 | 200 | Threeoutsidedown=Ref(Open,-1)>Ref(High,-2) AND Ref(Close,-1)=Ref(Open,-2)*1.01 AND Ref(Open,-1)>=Ref(Close,-2) AND Ref(Close,-1)>=Ref(Close,-2) AND Open>Ref(Low,-1) AND Open=Ref(Open,-2)*1.01 AND Ref(Open,-1)>=Ref(Close,-2) AND Ref(Close,-1)>=Ref(Close,-2) AND Open>Ref(High,-1) AND Close3.5 AND C>= (Low +Range*0.8) AND LLV(Low,5)==Low; 235 | 236 | Twobarbullishwick=(Range1/Realbody1)>3.5 AND C>= (Min(L,Ref(L,-1)) +Range1*0.8) AND LLV(Low,5)==Min(L,Ref(L,-1)) AND L < Ref(L, -1); 237 | 238 | Threebarbullishwick=(Range2/Realbody2)>3.5 AND C>= (Min(Min1,Ref(L,-2)) +Range2*0.8) AND LLV(Low,5)==Min(Min1,Ref(L,-2)) AND L < Ref(L, -1); 239 | 240 | 241 | /*Bearish Wick Reversal Set Up */ 242 | 243 | Onebarbearishwick=(Range/Realbody)>3.5 AND C<= (High-Range*0.8) AND HHV(High, 5)==High; 244 | 245 | Twobarbearishwick=(Range1/Realbody1)>3.5 AND C<= (Max(H, Ref(H,-1))-Range1*0.8) AND HHV(High, 5)==Max(H, Ref(H,-1)) AND H < Ref(H, -1); 246 | 247 | Threebarbearishwick=(Range2/Realbody2)>3.5 AND C<= (Max(Max1,Ref(H,-2))-Range2*0.8) AND HHV(High, 5)==Max(Max1,Ref(H,-2)) AND H < Ref(H, -1); 248 | 249 | 250 | /*Bullish Extreme Reversal Setup*/ 251 | Candleaverage = Ref(MA(H, 5), -1) - Ref(MA(L, 5), -1); 252 | Theextremereversalbullish = Range > 3*Candleaverage AND HHV(L, 5) ==Low AND Realbody > Range*0.5 AND Realbody < Range*0.85; 253 | 254 | /*Bearish Extreme Reversal Setup*/ 255 | 256 | Theextremereversalbearish = Range > 3*Candleaverage AND HHV(H, 5) ==High AND C<= (L +Range*0.8) AND C>= (L +Range*0.4); 257 | 258 | 259 | /*Bullish Trend Continuation */ 260 | 261 | Fivedaynewlinepatternbullish = (H>Ref(H,-1) AND Ref(H,-1) >Ref(H,-2) AND Ref(H,-2) >Ref(H,-3) AND Ref(H,-3) >Ref(H,-4) ) OR (L>Ref(L,-1) AND Ref(L,-1) >Ref(L,-2) AND Ref(L,-2) >Ref(L,-3) AND Ref(L,-3) >Ref(L,-4) ); 262 | 263 | Eightdaynewlinepatternbullish = (H>Ref(H,-1) AND Ref(H,-1) >Ref(H,-2) AND Ref(H,-2) >Ref(H,-3) AND Ref(H,-3) >Ref(H,-4) AND Ref(H,-4) >Ref(H,-5) AND Ref(H,-5) >Ref(H,-6) AND Ref(H,-6) >Ref(H,-7) ) OR (L>Ref(L,-1) AND Ref(L,-1) >Ref(L,-2) AND Ref(L,-2) >Ref(L,-3) AND Ref(L,-3) >Ref(L,-4) AND Ref(L,-4) >Ref(L,-5) AND Ref(L,-5) >Ref(L,-6) AND Ref(L,-6) >Ref(L,-7) ); 264 | 265 | Thrteendaynewlinepatternbullish = (H>Ref(H,-1) AND Ref(H,-1) >Ref(H,-2) AND Ref(H,-2) >Ref(H,-3) AND Ref(H,-3) >Ref(H,-4) AND Ref(H,-4) >Ref(H,-5) AND Ref(H,-5) >Ref(H,-6) AND Ref(H,-6) >Ref(H,-7) AND Ref(H,-7) >Ref(H,-8) AND Ref(H,-8) >Ref(H,-9) AND Ref(H,-9)>Ref(H,-10) AND Ref(H,-10)>Ref(H,-11) AND Ref(H,-11) >Ref(H,-12) ) OR (L>Ref(L,-1) AND Ref(L,-1) >Ref(L,-2) AND Ref(L,-2) >Ref(L,-3) AND Ref(L,-3) >Ref(L,-4) AND Ref(L,-4) >Ref(L,-5) AND Ref(L,-5) >Ref(L,-6) AND Ref(L,-6) >Ref(L,-7) AND Ref(L,-7) >Ref(L,-8) AND Ref(L,-8) >Ref(L,-9) AND Ref(L,-9) >Ref(L,-10) AND Ref(L,-10) >Ref(L,-11) AND Ref(L,-11) >Ref(L,-12) ); 266 | 267 | 268 | 269 | /*Bearish Trend Continuation */ 270 | 271 | 272 | Fivedaynewlinepatternbearish = (H0,colorGreen,colorRed)); 20 | _SECTION_END(); -------------------------------------------------------------------------------- /Custom-Formulas/DEMA FAN.afl: -------------------------------------------------------------------------------- 1 | SetChartOptions(0,chartShowArrows|chartShowDates); 2 | 3 | _SECTION_BEGIN("DEMA BUY"); 4 | Cond1 = DEMA( Close , 5 ) > DEMA( Open , 36 ); 5 | Cond2 = DEMA( Close , 7 ) > DEMA( Open , 36 ); 6 | Cond3 = DEMA( Close , 9 ) > DEMA( Open , 36 ); 7 | Cond4 = DEMA( Close , 11 ) > DEMA( Open , 36 ); 8 | Cond5 = DEMA( Close , 13 ) > DEMA( Open , 36 ); 9 | 10 | Cond6= DEMA( Close , 5 ) < DEMA( Open , 21 ); 11 | Cond7= DEMA( Close , 7 ) < DEMA( Open , 21 ); 12 | Cond8= DEMA( Close , 9 ) < DEMA( Open , 21 ); 13 | Cond9= DEMA( Close , 11 ) < DEMA( Open , 21 ); 14 | Cond10= DEMA( Close , 13 ) < DEMA( Open , 21 ); 15 | 16 | Buy = Cond1 AND Cond2 AND Cond3 AND Cond4 AND Cond5; 17 | Sell = Cond6 AND Cond7 AND Cond8 AND Cond9 AND Cond10; 18 | 19 | Buy=ExRem(Buy,Sell); 20 | Sell=ExRem(Sell,Buy); 21 | 22 | PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-20); 23 | PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-30); 24 | PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-25); 25 | PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorOrange, 0, H, Offset=20); 26 | PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorGreen, 0,H, Offset=30); 27 | PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-25); 28 | 29 | 30 | dist = 3*ATR(10); 31 | dist1 = 3*ATR(10); 32 | for( i = 0; i < BarCount; i++ ) 33 | { 34 | if( Buy[i] ) 35 | { 36 | PlotText( "\nBuy@:" + C[ i ], i, C[ i ]-dist[i], colorGreen, colorDarkOliveGreen ); 37 | } 38 | if( Sell[i] ) 39 | { 40 | PlotText( "Sel@:" + C[ i ], i, C[ i ]+dist1[i], colorRed, colorDarkOliveGreen ); 41 | } 42 | 43 | } 44 | _SECTION_END(); 45 | 46 | _SECTION_BEGIN("DEMA SELL"); 47 | 48 | Cond11 = DEMA( Close , 5 ) < DEMA( Open , 36 ); 49 | Cond12 = DEMA( Close , 7 ) < DEMA( Open , 36 ); 50 | Cond13 = DEMA( Close , 9 ) < DEMA( Open , 36 ); 51 | Cond14 = DEMA( Close , 11 ) < DEMA( Open , 36 ); 52 | Cond15 = DEMA( Close , 13 ) < DEMA( Open , 36 ); 53 | 54 | 55 | 56 | Cond16= DEMA( Close , 5 ) > DEMA( Open , 21 ); 57 | Cond17= DEMA( Close , 7 ) > DEMA( Open , 21 ); 58 | Cond18= DEMA( Close , 9 ) > DEMA( Open , 21 ); 59 | Cond19= DEMA( Close , 11 ) > DEMA( Open , 21 ); 60 | Cond20= DEMA( Close , 13 ) > DEMA( Open , 21 ); 61 | 62 | Buy = Cond16 AND Cond17 AND Cond18 AND Cond19 AND Cond20; 63 | Sell = Cond11 AND Cond12 AND Cond13 AND Cond14 AND Cond15; 64 | 65 | Buy=ExRem(Buy,Sell); 66 | Sell=ExRem(Sell,Buy); 67 | 68 | PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-20); 69 | PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorOrange, 0,L, Offset=-30); 70 | PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-25); 71 | PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0, H, Offset=20); 72 | PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorOrange, 0,H, Offset=30); 73 | PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-25); 74 | 75 | dist = 3*ATR(10); 76 | dist1 = 3*ATR(10); 77 | for( i = 0; i < BarCount; i++ ) 78 | { 79 | if( Buy[i] ) 80 | { 81 | PlotText( "\nCov@:" + C[ i ], i, C[ i ]-dist[i], colorGreen, colorDarkOliveGreen ); 82 | } 83 | if( Sell[i] ) 84 | { 85 | PlotText( "Sht@:" + C[ i ], i, C[ i ]+dist1[i], colorRed, colorDarkOliveGreen ); 86 | } 87 | 88 | } 89 | 90 | _SECTION_END(); 91 | 92 | _SECTION_BEGIN("DEMA COLOR"); 93 | 94 | Cond1 = DEMA( Close , 5 ) > DEMA( Open , 36 ); 95 | Cond2 = DEMA( Close , 7 ) > DEMA( Open , 36 ); 96 | Cond3 = DEMA( Close , 9 ) > DEMA( Open , 36 ); 97 | Cond4 = DEMA( Close , 11 ) > DEMA( Open , 36 ); 98 | Cond5 = DEMA( Close , 13 ) > DEMA( Open , 36 ); 99 | 100 | Cond11 = DEMA( Close , 5 ) < DEMA( Open , 36 ); 101 | Cond12 = DEMA( Close , 7 ) < DEMA( Open , 36 ); 102 | Cond13 = DEMA( Close , 9 ) < DEMA( Open , 36 ); 103 | Cond14 = DEMA( Close , 11 ) < DEMA( Open , 36 ); 104 | Cond15 = DEMA( Close , 13 ) < DEMA( Open , 36 ); 105 | 106 | CondA= Cond1 AND Cond2 AND Cond3 AND Cond4 AND Cond5; 107 | CondB= Cond11 AND Cond12 AND Cond13 AND Cond14 AND Cond15; 108 | BarColor = IIf(CondA,colorGreen,IIf(CondB,colorRed,colorWhite)); 109 | 110 | Plot( C, "Close", BarColor, styleNoTitle | ParamStyle("Style") | 111 | GetPriceStyle() ); 112 | 113 | GraphXSpace=10; 114 | 115 | _SECTION_END(); -------------------------------------------------------------------------------- /Custom-Formulas/Daily - Strength.afl: -------------------------------------------------------------------------------- 1 | {//Options ===================================== 2 | SetOption("InitialEquity",600000); 3 | SetOption("MinShares",100); 4 | RoundLotSize = 100; 5 | 6 | SetOption("CommissionMode", 1); 7 | SetOption("CommissionAmount", 0.2); 8 | 9 | slippage = 0.01; 10 | 11 | numStocks = 10; 12 | SetOption( "MaxOpenPositions", numStocks ); 13 | 14 | settradedelays( 1, 1, 1, 1 ); 15 | BuyPrice = Open+(Open*slippage);//Open Next day 16 | SellPrice = Open-(Open*slippage); 17 | //BuyPrice = Max(Low,EMA(Close,20)); 18 | 19 | } 20 | 21 | {//MKC ===================================== 22 | SET = Foreign("SET","CLOSE"); 23 | } 24 | 25 | {//SIGNAL ================================== 26 | {//Liquidity 27 | Liq = MA(Volume*Avg,4) > 10000000; 28 | VolMA = Volume > EMA(Volume,10); 29 | VolUp = Volume > Ref(Volume,-1); 30 | } 31 | 32 | {//Indicator 33 | RSI_Strength = RSI(20) > 66.67; 34 | ADX_Range = 20; 35 | ADX_Value = ADX(ADX_Range); 36 | Plus_DI = PDI(ADX_Range); 37 | Minus_DI = MDI(ADX_Range); 38 | ADX_UpTrend = Plus_DI > Minus_DI; 39 | ADX_Strength = IIf(ADX_Value >= 20,1,0); 40 | ADX_Translation = IIF(ADX_UpTrend AND ADX_Strength,1, 41 | IIF(ADX_UpTrend AND (ADX_Strength != 1),2,3) 42 | ); 43 | } 44 | 45 | {//Strength 46 | H_Year = HHV(High,252); 47 | P_H_Year = Ref(H_Year,-1); 48 | H_H_Year = HHV(High,130); 49 | P_H_H_Year = Ref(H_H_Year,-1); 50 | hZone = H_Year*0.85; 51 | rocStrength = ROC(Close,20) > ROC(Foreign("SET","Close"),20) 52 | AND ROC(Close,130) > ROC(Foreign("SET","Close"),130) 53 | AND ROC(Close,252) > ROC(Foreign("SET","Close"),252); 54 | strength = rocStrength; 55 | PctfarH_Year = (Close-H_Year)*100/H_Year; 56 | } 57 | 58 | {//Breakout 59 | BO_Month = Cross(C,Ref(HHV(H,20),-1)); 60 | BO_H_H_Year = Cross(Close,P_H_H_Year); 61 | BO_Year = Cross(Close,P_H_Year); 62 | } 63 | 64 | {//4 Weeks Resting 65 | H_Month = Ref(HHV(High,20),-1); 66 | L4 = Ref(LLV(Low,20),-1); 67 | RangeMonth = ((H_Month-L4)/L4)*100; 68 | } 69 | 70 | {//4 Weeks Tight Close 71 | maxC=Ref(HHV(C,20),-1); 72 | minC=Ref(LLV(C,20),-1); 73 | CSMonth=(maxC-minC)/minC*100; 74 | } 75 | 76 | {//Price vs EMA 77 | Mov0 = EMA(Close,10); 78 | Mov1 = EMA(Close,20); 79 | Mov2 = EMA(Close,50); 80 | P_EMA10 = Cross(Close,Mov0); 81 | P_EMA50 = Cross(Close,Mov2); 82 | PercOfEMA10 = (Close-Mov0)*100/Mov0; 83 | PercOfEMA50 = (Close-Mov2)*100/Mov2; 84 | } 85 | 86 | {// Price action on Moving Average 87 | 88 | //Price cross EMA 89 | pAc1 = Low <= Mov0 AND Close > Mov0; 90 | //In case that Low not completely touch MA AND Close going up 91 | pAc2 = Low <= Mov2*1.03; //Percent of low than come to EMA zone but not touch. 92 | {// Mov Avg 93 | MovTrend = IIf(Mov0 > Mov1 AND Mov1 > Mov2,1,0); 94 | } 95 | {// Keltner 96 | Periods = 130; 97 | Width = 5; 98 | 99 | CenterLine = MA( Close, Periods ); 100 | KTop = CenterLine + Width * ATR( Periods ); 101 | 102 | P_KTOP = Close >= KTop*0.98; 103 | } 104 | } 105 | 106 | 107 | {//Buy 108 | buyCon1 = (pAc1 OR pAc2 );//Price 109 | buyCon2 = 1;//Volume 110 | 111 | BO = BO_Year OR BO_H_H_Year; 112 | Buy = BO; 113 | } 114 | 115 | {//Sell 116 | sellCon1 = MACD() < 0; 117 | Sell = 0; 118 | } 119 | 120 | {//Filter 121 | Filter = (Mov0 > Mov2) AND Liq; 122 | AddColumn(PctfarH_Year,"% of YearHigh",1.2,colorDefault,IIf(PctfarH_Year>=0,colorPaleGreen,colorRose)); 123 | AddColumn(H_Year,"Year High"); 124 | AddColumn(RSI(14),"RSI14",1.2,colorDefault, 125 | IIf(RSI(14)>=66.67, colorPaleGreen 126 | ,IIf(RSI(14)<=33.33 ,colorPink 127 | ,colorWhite) 128 | ) 129 | ); 130 | AddColumn(Strength,"Strength",1.2,colorDefault,IIf(Strength,colorTurquoise,colorWhite)); 131 | AddColumn(C >= hzone,"85%",1.2,C >= hzone,IIf(C >= hzone,colorTurquoise,colorWhite)); 132 | AddColumn(VolMA,"VolMA",1.2,colorDefault,IIf(VolMA,colorTurquoise,colorWhite)); 133 | AddColumn((pAc1 OR P_EMA10),"PB10w",1.2,colorDefault,IIf((pAc1 OR P_EMA10),colorPaleGreen,colorWhite)); 134 | AddColumn((pAc2 OR P_EMA50),"PB50w",1.2,colorDefault,IIf((pAc2 OR P_EMA50),colorPaleGreen,colorWhite)); 135 | AddColumn(BO_Month,"4W B.O",1.2,colorDefault,IIf(BO_Month,colorPaleGreen,colorRose)); 136 | AddColumn(BO_H_H_Year,"26W B.O",1.2,colorDefault,IIf(BO_H_H_Year,colorPaleGreen,colorRose)); 137 | AddColumn(BO_Year,"52W B.O",1.2,colorDefault,IIf(BO_Year,colorPaleGreen,colorRose)); 138 | AddColumn(ROC(Close,52),"ROC Year"); 139 | AddColumn(ROC(Close,10),"ROC 10Ws"); 140 | AddColumn(RangeMonth,"HL4WS"); //H-L 4 Weeks Spread 141 | AddColumn(CSMonth,"C4WS"); //C 4 Weeks Spread 142 | AddColumn(PercOfEMA10,"% of MA10",1.2,colorDefault,IIf(PercOfEMA10>0,colorPaleGreen,colorRose)); 143 | AddColumn(PercOfEMA50,"% of MA50",1.2,colorDefault,IIf(PercOfEMA50>0,colorPaleGreen,colorRose)); 144 | AddColumn(MovTrend,"MA Trend",1.2,colorDefault,IIf(MovTrend,colorPaleGreen,colorRose)); 145 | } 146 | } 147 | 148 | {//POSITION ================================== 149 | /*Position Score*/ 150 | PositionScore = ROC(Close,5); 151 | 152 | /*Position Size*/ 153 | /* PositionRisk = 1; // how much (in percent of equity) we risk in single position 154 | TradeRisk = (BuyPrice - Moving)/BuyPrice; // trade risk in percent equals to max. loss percentage stop 155 | PctSize = PositionRisk / TradeRisk; 156 | PositionSize = -1*PctSize; 157 | */ 158 | //SetPositionSize(5, spsPercentOfEquity); 159 | //End Position Size 160 | 161 | } 162 | 163 | {//STOP ================================== 164 | ApplyStop(stopTypeLoss, stopModePercent, 10); 165 | ApplyStop(stopTypeTrailing, stopModePercent, 25); 166 | ApplyStop(stopTypeProfit, stopModePercent, 30); 167 | ApplyStop(stopTypeNBar,stopModeBars,3); 168 | } -------------------------------------------------------------------------------- /Custom-Formulas/Detecting double tops and bottoms.afl: -------------------------------------------------------------------------------- 1 | _SECTION_BEGIN("Price"); 2 | SetChartOptions(0,chartShowArrows|chartShowDates); 3 | _N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) )); 4 | Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 5 | _SECTION_END(); 6 | 7 | _SECTION_BEGIN("Detecting double tops and bottoms"); 8 | /* Detecting double tops and bottoms (come into view, by Isfandi)*/ 9 | percdiff = 5; /* peak detection threshold */ 10 | fwdcheck = 5; /* forward validity check */ 11 | mindistance = 10; 12 | validdiff = percdiff/400; 13 | 14 | PK= Peak( H, percdiff, 1 ) == High; 15 | TR= Trough( L, percdiff, 1 ) == Low; 16 | 17 | 18 | x = Cum( 1 ); 19 | XPK1 = ValueWhen( PK, x, 1 ); 20 | XPK2 = ValueWhen( PK, x, 2 ); 21 | xTR1 = ValueWhen( Tr, x, 1 ); 22 | xTr2 = ValueWhen( Tr, x, 2 ); 23 | 24 | peakdiff = ValueWhen( PK, H, 1 )/ValueWhen( PK, H, 2 ); 25 | Troughdiff=ValueWhen( tr, L, 1 )/ValueWhen( tr, L, 2 ); 26 | 27 | doubletop = PK AND abs( peakdiff - 1 ) < validdiff AND (Xpk1 -Xpk2)>mindistance AND High > HHV( Ref( H, fwdcheck ), fwdcheck - 1 ); 28 | doubleBot=tr AND abs( troughdiff - 1 ) < validdiff AND (Xtr1 -Xtr2)>mindistance AND Low < LLV( Ref( L, fwdcheck ), fwdcheck - 1 ); 29 | 30 | Buy = doublebot; 31 | Sell = doubletop; 32 | for( i = 0; i < BarCount; i++ ) 33 | { 34 | if( Buy[i] ) PlotText( "BOT " , i, L[ i ],colorBlue ); 35 | if( Sell[i] ) PlotText( "TOP" , i, H[ i ], colorRed ); 36 | } 37 | 38 | 39 | WriteIf( Highest( doubletop ) == 1, "AmiBroker has detected some possible 40 | double top patterns for " + Name() + "\nLook for green arrows on the price 41 | chart.", "There are no double top patterns for " + Name() ); 42 | 43 | WriteIf(Lowest( doublebot)==1,"AmiBroker has detected some possible double 44 | bottom patterns for " + Name() + "\nLook for red arrows on the price 45 | chart.", "There are no double bottom patterns for " + Name() ); 46 | _SECTION_END(); -------------------------------------------------------------------------------- /Custom-Formulas/DochianH.afl: -------------------------------------------------------------------------------- 1 | 2 | field_value = ParamField("Field Value"); 3 | period = Param("Period",20,3,350,1); 4 | Perc = Param("%",100,1,100,1)/100; 5 | prevBack = Param("Ref Bar",-1,-300,0,-1); 6 | DonchianH = Ref(HHV(field_value,period),prevBack)*Perc; 7 | Plot(DonchianH,"Donchian Upper", ParamColor( "Color", colorCycle ), ParamStyle("Style")); -------------------------------------------------------------------------------- /Custom-Formulas/DochianL.afl: -------------------------------------------------------------------------------- 1 | 2 | field_value = ParamField("Field Value"); 3 | period = Param("Period",20,3,350,1); 4 | 5 | DonchianL = Ref(LLV(field_value,period),-1); 6 | Plot(DonchianL,"Donchian Lower", ParamColor( "Color", colorCycle ), ParamStyle("Style")); -------------------------------------------------------------------------------- /Custom-Formulas/Explore Most Active.afl: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////////// 2 | nVolume=Volume; 3 | nValue=(Volume*C); 4 | nSpread=((H-L)/L)*100; 5 | 6 | Filter = C; 7 | 8 | AddTextColumn( FullName(), "Company Name" ); 9 | AddColumn(32,"Candle" ,formatChar, colorDefault,IIf(O<=C,colorGreen,colorRed) ); 10 | AddColumn( nSpread, "Spread%", 1.2 , colorDefault,IIf(O<=C,colorLime,colorRed)); 11 | AddColumn( H, " High ", 1.2 ); 12 | AddColumn( L, " Low ", 1.2 ); 13 | AddColumn( O, " Open ", 1.2 ); 14 | AddColumn( C, "Close", 1.2, IIf(C < Ref(C,-1), colorRed, IIf(C > Ref(C,-1),colorGreen,colorDefault))); 15 | AddColumn( nVolume, "Most Active Volume", 1, IIf(V > Ref(V,-1), colorGreen, colorRed),-1,120); 16 | AddColumn( nValue, "Most Actie Value",1,21,colorWhite,120); 17 | AddColumn(ROC(C,1),"Top Gainers/Top Losers",1.2,colorDefault,IIf(ROC(C,1)<0,colorRed,IIf(ROC(C,1)>0,colorLime,colorLightGrey)),150); 18 | //////////////////////////////////////////////////////////////////////////////////////// -------------------------------------------------------------------------------- /Custom-Formulas/FL.afl: -------------------------------------------------------------------------------- 1 | Filter = 1; 2 | nextHHV = Ref(HHV(C,5),5); 3 | Buy = IIf(C <= nextHHV, 1, 0); 4 | AddColumn(C,"Close"); 5 | AddColumn(nextHHV,"NextHHV"); 6 | AddColumn(Buy,"Buy"); 7 | -------------------------------------------------------------------------------- /Custom-Formulas/Formula 1.afl: -------------------------------------------------------------------------------- 1 | AddTextColumn( GetBaseIndex(), "SET"); -------------------------------------------------------------------------------- /Custom-Formulas/IBD RS RANKING 1.afl: -------------------------------------------------------------------------------- 1 | _SECTION_BEGIN("IBD RS RANKING"); 2 | //IBD RS RANKING 3 | //13 = Quaterly/ 130 = Haft-Year/ 260 = Yearly 4 | monthROC = (C - Ref(C, -4)) / Ref(C, -4) * 100; 5 | quaterROC = (C - Ref(C, -12)) / Ref(C, -12) * 100; 6 | halfYearROC = (C - Ref(C, -23)) / Ref(C, -23) * 100; 7 | YearROC = (C - Ref(C, -52)) / Ref(C, -52) * 100; 8 | RSW = (0.2*monthROC) + (0.3*quaterROC) + (0.2*halfYearROC) + (0.3*YearROC); 9 | Plot(RSW,"RANKING IBD" ,colorBrightGreen,styleLine) ; 10 | Plot(EMA(RSW,10),"10Ws AVG" ,colorRed,styleLine|styleDashed|styleNoLabel); 11 | 12 | BuyIBD=RSW>EMA(RSW,10) AND RSW>65; 13 | SellIBD=RSW>40 AND RSWEMA(RSW,10) AND RSW>65; 13 | SellIBD=RSW>40 AND RSW= hzone; 21 | AddTextColumn( Name(), "Stock"); 22 | AddColumn(CRS_SCORE,"CRS-RATING"); 23 | AddColumn(RSI(14),"RSI14",1.2,colorDefault, 24 | IIf(RSI(14)>=66.67, colorPaleGreen 25 | ,IIf(RSI(14)<=33.33 ,colorPink 26 | ,colorWhite) 27 | ) 28 | ); 29 | AddColumn(rocStrength,"rocStrength",1.2,colorDefault,IIf(rocStrength,colorTurquoise,colorWhite)); 30 | } -------------------------------------------------------------------------------- /Custom-Formulas/NS-EMA.afl: -------------------------------------------------------------------------------- 1 | period = Param("Period", 260, 20, 520, 5); 2 | {//New High - New Low 3 | nul = IsNull(Close); 4 | ExpMovAvg = EMA(Close, period); 5 | abvMA = IIf(nul,0,Close) > ExpMovAvg; 6 | belMA = IIf(nul,0,Close) <= ExpMovAvg; 7 | } 8 | {//Add to Composite 9 | AddToComposite( IIf(nul,0,abvMA), "~AbvBelMA", "H" ); 10 | AddToComposite( IIf(nul,0,belMA), "~AbvBelMA", "L" ); 11 | AddToComposite( IIf(IIf(nul,0,Close) > 0, 1,0), "~AbvBelMA", "I"); //Counting Number of Stocks 12 | } 13 | {//Calculate in % 14 | pctAbvMA = 100*foreign( "~AbvBelMA", "H")/foreign( "~AbvBelMA", "I"); 15 | } 16 | {// Plotting 17 | //Graph0 = pctAbvMA; 18 | Plot(pctAbvMA, "% Above "+period+" EMA", ParamColor("Color",16), ParamStyle("Style",4)); 19 | } -------------------------------------------------------------------------------- /Custom-Formulas/NS-HL.afl: -------------------------------------------------------------------------------- 1 | function Months(m){return 252/(12/m);} 2 | period = Param("Period", 260, 20, 520, 5); 3 | {//New High - New Low 4 | prevHigh = Ref( HHV(Close, period), -1); 5 | newHigh = Cross(Close, prevHigh); 6 | prevLow = Ref( LLV(Close, period), -1); 7 | newLow = Cross(prevLow, Close); 8 | } 9 | {//Add to Composite 10 | AddToComposite( newHigh, "~newHL", "H" ); 11 | AddToComposite( newLow, "~newHL", "L" ); 12 | AddToComposite( IIf(Close > 0, 1,0), "~newHL", "I"); //Counting Number of Stocks 13 | } 14 | {//Calculate in % 15 | pctNH = 100*foreign( "~newHL", "H")/foreign( "~newHL", "I"); 16 | } 17 | {// Plotting 18 | Plot(foreign( "~newHL", "H"), "New High "+period, ParamColor("Color",16), ParamStyle("Style",4)); 19 | Plot(foreign( "~newHL", "L"), "New Low "+period, ParamColor("Color",10), ParamStyle("Style",4)); 20 | } -------------------------------------------------------------------------------- /Custom-Formulas/NS-RSI.afl: -------------------------------------------------------------------------------- 1 | //************************************************ 2 | // Number of Stock that RSI Greater than X value 3 | //************************************************ 4 | period = Param("RSI-Period", 14, 5, 60, 1); 5 | bull = 66.67; 6 | bear = 33.33; 7 | {//New High - New Low 8 | nul = IsNull(Close); 9 | aRSI = RSIa(Close, period); 10 | rsiBull = aRSI >= bull; 11 | rsiBear = aRSI <= bear; 12 | } 13 | {//Add to Composite 14 | AddToComposite( rsiBull, "~NS_RSI", "H" ); 15 | AddToComposite( rsiBear, "~NS_RSI", "L" ); 16 | AddToComposite( IIf(IIf(nul,0,Close) > 0, 1,0), "~NS_RSI", "I"); //Counting Number of Stocks 17 | } 18 | {//Calculate in % 19 | pctRsiBull = 100*foreign( "~NS_RSI", "H")/foreign( "~NS_RSI", "I"); 20 | } 21 | {// Plotting 22 | //Graph0 = pctAbvMA; 23 | Plot(pctRsiBull, "% RSI "+period+" GTR "+bull, ParamColor("Color",16), ParamStyle("Style",4)); 24 | } -------------------------------------------------------------------------------- /Custom-Formulas/P-L Over time.afl: -------------------------------------------------------------------------------- 1 | _SECTION_BEGIN("Profit/Loss % Change over Time"); 2 | // PARAMETERS 3 | TtD_Param = ParamList("Period","Day to Date|Week to Date|Month to Date|Year to Date",0); 4 | 5 | // VARIABLES 6 | FDayMonth = BarsSince(Month() != Ref(Month(),-1)); 7 | FDayYear = BarsSince(Year() != Ref(Year(),-1)); 8 | TtD_Period = IIf(TtD_Param == "Day to Date",1, 9 | IIf(TtD_Param == "Week to Date",DayOfWeek(), 10 | IIf(TtD_Param == "Month to Date",FDayMonth, 11 | IIf(TtD_Param == "Year to Date",FDayYear,0)))); 12 | // FORMULA 13 | TtD_Change = 100 * (Close - Ref(Close, -TtD_Period) ) / Ref(Close, -TtD_Period); 14 | 15 | _SECTION_END(); 16 | 17 | _SECTION_BEGIN("Explorer"); 18 | // FILTER 19 | Filter = 1; 20 | // DISPLAY COLUMNS 21 | AddColumn(TtD_Change,"P/L % Change",1.2,IIf(TtD_Change>0,colorGreen,colorRed)); 22 | _SECTION_END(); -------------------------------------------------------------------------------- /Custom-Formulas/PPBP.afl: -------------------------------------------------------------------------------- 1 | {//Options ===================================== 2 | SetOption("InitialEquity",600000); 3 | SetOption("MinShares",1); 4 | SetOption("NoDefaultColumns", True ); 5 | numStocks = 100; 6 | SetOption( "MaxOpenPositions", numStocks ); 7 | SetOption("CommissionMode", 1); 8 | SetOption("CommissionAmount", 0.2); 9 | settradedelays( 1, 1, 1, 1 ); 10 | //RoundLotSize = 100; 11 | slippage = 0.03; 12 | BuyPrice = Open+(Open*slippage);//Open Next day 13 | SellPrice = Open-(Open*slippage); 14 | //BuyPrice = Max(Low,EMA(Close,20)); 15 | } 16 | 17 | { //Moving Average 18 | S_MA = EMA(Close, Param("Short MA", 10, 5, 35,1)); 19 | L_MA = EMA(Close, Param("Longs MA", 50, 35, 100,1)); 20 | MA_UP = S_MA > L_MA; 21 | C_GTR_S_MA = Close > S_MA; 22 | MA_Cond = MA_UP AND C_GTR_S_MA; 23 | } 24 | { // Price Pattern 25 | Bull_Day = Close > Open; 26 | Bear_Day = Open > Close; 27 | Just_Start = Close <= S_MA*1.05; 28 | } 29 | {// Volume 30 | V_Bear_Day = IIf(Bear_Day, Volume, 0); 31 | V_Cond = Volume >= HHV(V_Bear_Day, 10); 32 | } 33 | {// Buy & Sell 34 | Buy = V_Cond AND MA_Cond AND Bull_Day AND Just_Start; 35 | Sell = Cross(S_MA,Close); 36 | } 37 | {// Filter 38 | Filter = V_Cond AND MA_Cond AND Bull_Day AND Just_Start; 39 | } 40 | {// Position Size 41 | PositionSize = 100; 42 | } -------------------------------------------------------------------------------- /Custom-Formulas/Price (foreign) - IBD.afl: -------------------------------------------------------------------------------- 1 | Ticker = ParamStr("Symbol", Name() ); 2 | PlotForeign( Ticker, Ticker, ParamColor("Color", colorCycle ), styleLine | ParamStyle("Style")); -------------------------------------------------------------------------------- /Custom-Formulas/Price 5.afl: -------------------------------------------------------------------------------- 1 | _SECTION_BEGIN("Price-Bar"); 2 | SetChartOptions(0,chartShowArrows|chartShowDates); 3 | _N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) )); 4 | PreviousBar = Ref(C,-1); 5 | Color=IIf(C<=PreviousBar,ParamColor("Bearish",colorRed),ParamColor("Bullish",colorBlack)); 6 | Plot( C, "Close", Color, styleBar | styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 7 | _SECTION_END(); 8 | 9 | _SECTION_BEGIN("Volume"); 10 | Plot( Volume, _DEFAULT_NAME(), ParamColor("Color", colorBlueGrey ), ParamStyle( "Style", styleHistogram | styleOwnScale | styleThick, maskHistogram ) ); 11 | _SECTION_END(); 12 | 13 | _SECTION_BEGIN("Volume At Price"); 14 | PlotVAPOverlay( Param("Lines", 300, 100, 1000, 1 ), Param("Width", 5, 1, 100, 1 ), ParamColor("Color", colorCycle ), ParamToggle("Side", "Left|Right" ) | 4*ParamToggle("Z-order", "On top|Behind", 1 ) ); 15 | 16 | _SECTION_END(); -------------------------------------------------------------------------------- /Custom-Formulas/Price-Bar-IBD.afl: -------------------------------------------------------------------------------- 1 | SetChartOptions(0,chartShowArrows|chartShowDates); 2 | _N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) )); 3 | PreviousBar = Ref(C,-1); 4 | Color=IIf(C<=PreviousBar,ParamColor("Bearish",colorRed),ParamColor("Bullish",colorBlack)); 5 | Plot( C, "Close", Color, styleBar | styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); -------------------------------------------------------------------------------- /Custom-Formulas/Price-Bar.afl: -------------------------------------------------------------------------------- 1 | SetChartOptions(0,chartShowArrows|chartShowDates); 2 | _N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) )); 3 | Plot( C, "Close", ParamColor("Color", colorDefault ), styleBar | styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 4 | 5 | _SECTION_BEGIN("EMA"); 6 | P = ParamField("Price field",-1); 7 | Periods = Param("Periods", 15, 2, 300, 1, 10 ); 8 | Plot( EMA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") ); 9 | _SECTION_END(); 10 | 11 | _SECTION_BEGIN("Volume At Price"); 12 | PlotVAPOverlay( Param("Lines", 300, 100, 1000, 1 ), Param("Width", 5, 1, 100, 1 ), ParamColor("Color", colorCycle ), ParamToggle("Side", "Left|Right" ) | 4*ParamToggle("Z-order", "On top|Behind", 1 ) ); 13 | 14 | _SECTION_END(); 15 | 16 | _SECTION_BEGIN("EMA1"); 17 | P = ParamField("Price field",-1); 18 | Periods = Param("Periods", 15, 2, 300, 1, 10 ); 19 | Plot( EMA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") ); 20 | _SECTION_END(); 21 | 22 | _SECTION_BEGIN("Price-Bar"); 23 | SetChartOptions(0,chartShowArrows|chartShowDates); 24 | _N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) )); 25 | PreviousBar = Ref(C,-1); 26 | Color=IIf(C<=PreviousBar,ParamColor("Bearish",colorRed),ParamColor("Bullish",colorBlack)); 27 | Plot( C, "Close", Color, styleBar | styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 28 | _SECTION_END(); 29 | 30 | _SECTION_BEGIN("EMA2"); 31 | P = ParamField("Price field",-1); 32 | Periods = Param("Periods", 15, 2, 300, 1, 10 ); 33 | Plot( EMA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") ); 34 | _SECTION_END(); 35 | 36 | _SECTION_BEGIN("Volume1"); 37 | Plot( Volume, _DEFAULT_NAME(), ParamColor("Color", colorBlueGrey ), ParamStyle( "Style", styleHistogram | styleOwnScale | styleThick, maskHistogram ) ); 38 | _SECTION_END(); 39 | 40 | _SECTION_BEGIN("DochianH"); 41 | 42 | field_value = ParamField("Field Value"); 43 | period = Param("Period",20,3,350,1); 44 | Perc = Param("%",100,1,100,1)/100; 45 | prevBack = Param("Ref Bar",-1,-300,0,-1); 46 | DonchianH = Ref(HHV(field_value,period),prevBack)*Perc; 47 | Plot(DonchianH,"Donchian Upper", ParamColor( "Color", colorCycle ), ParamStyle("Style")); 48 | _SECTION_END(); -------------------------------------------------------------------------------- /Custom-Formulas/PullBack.afl: -------------------------------------------------------------------------------- 1 | {//Options ===================================== 2 | SetOption("InitialEquity",600000); 3 | SetOption("MinShares",100); 4 | RoundLotSize = 100; 5 | 6 | SetOption("CommissionMode", 1); 7 | SetOption("CommissionAmount", 0.2); 8 | 9 | slippage = 0.01; 10 | 11 | numStocks = 10; 12 | SetOption( "MaxOpenPositions", numStocks ); 13 | 14 | settradedelays( 1, 1, 1, 1 ); 15 | BuyPrice = Open+(Open*slippage);//Open Next day 16 | SellPrice = Open-(Open*slippage); 17 | //BuyPrice = Max(Low,EMA(Close,20)); 18 | 19 | } 20 | 21 | {//MKC ===================================== 22 | SET = Foreign("SET","CLOSE"); 23 | } 24 | 25 | {//SIGNAL ================================== 26 | {//Liquidity 27 | Liq = MA(Volume*Avg,20) > 10000000; 28 | } 29 | 30 | {//Indicator 31 | Indy = RSI(55) > 50; 32 | RSI_BO = RSI(55) >= Ref(HHV(RSI(55),55),-1); 33 | ADX_Range = 20; 34 | ADX_Value = ADX(ADX_Range); 35 | Plus_DI = PDI(ADX_Range); 36 | Minus_DI = MDI(ADX_Range); 37 | ADX_UpTrend = Plus_DI > Minus_DI; 38 | ADX_Strength = IIf(ADX_Value >= 20,1,0); 39 | ADX_Translation = IIF(ADX_UpTrend AND ADX_Strength,1, 40 | IIF(ADX_UpTrend AND (ADX_Strength != 1),2,3) 41 | ); 42 | } 43 | 44 | {//Strength 45 | H260 = HHV(High,252); 46 | P_H260 = Ref(H260,-1); 47 | BO_260 = Cross(Close,P_H260); 48 | H130 = HHV(High,130); 49 | P_H130 = Ref(H130,-1); 50 | BO_130 = Cross(Close,P_H130); 51 | hZone = H260*0.85; 52 | rocStrength = ROC(Close,10) > ROC(Foreign("SET","Close"),10) 53 | AND ROC(Close,20) > ROC(Foreign("SET","Close"),20) 54 | AND ROC(Close,50) > ROC(Foreign("SET","Close"),50) 55 | AND ROC(Close,260) > ROC(Foreign("SET","Close"),260); 56 | strength = Close >= hZone AND rocStrength; 57 | } 58 | 59 | {//Breakout 60 | ShortPeriod = HHV(H,10); 61 | BO_SP = Cross(C,Ref(ShortPeriod,-1)); 62 | } 63 | 64 | {// Price action on Moving Average 65 | Mov0 = EMA(Close,10); 66 | Mov1 = EMA(Close,20); 67 | Mov2 = EMA(Close,50); 68 | //Price cross EMA 69 | pAc1 = Low <= Mov1 AND Close > Mov1; 70 | //In case that Low not completely touch MA AND Close going up 71 | pAc2 = Low >= Mov1 72 | AND Low <= EMA(Close,20)*1.015; //Percent of low than come to EMA zone but not touch. 73 | P_EMA50 = Close <= EMA(Close,50)*1.03 AND Close >= EMA(Close,50); 74 | {// Mov Avg 75 | MovTrend = IIf(Mov0 > Mov1 AND Mov1 > Mov2,1,0); 76 | } 77 | {// Keltner 78 | Periods = 130; 79 | Width = 5; 80 | 81 | CenterLine = MA( Close, Periods ); 82 | KTop = CenterLine + Width * ATR( Periods ); 83 | 84 | P_KTOP = Close >= KTop*0.98; 85 | } 86 | } 87 | 88 | 89 | {//Buy 90 | buyCon1 = (pAc1 OR pAc2 );//Price 91 | buyCon2 = 1;//Volume 92 | buyCon3 = Indy;//Indicator 93 | Buy = buyCon1; 94 | } 95 | 96 | {//Sell 97 | sellCon1 = MACD() < 0; 98 | Sell = 0; 99 | } 100 | 101 | {//Filter 102 | Filter = ((RSI_BO ) OR (buyCon1) OR BO_260) AND Liq; 103 | AddColumn((Close-Mov1)*100/Mov1,"% of MA20",1.2,colorDefault,IIf((Close-Mov1)*100/Mov1>0,colorPaleGreen,colorRose)); 104 | AddColumn((Close-Mov2)*100/Mov2,"% of MA50",1.2,colorDefault,IIf((Close-Mov2)*100/Mov2>0,colorPaleGreen,colorRose)); 105 | AddColumn((Close-H260)*100/H260,"% of YearHigh",1.2,colorDefault,IIf((Close-H260)*100/H260>=0,colorPaleGreen,colorRose)); 106 | AddColumn(H260,"Year High"); 107 | AddColumn(RSI(55),"RSI55",1.2,colorDefault, 108 | IIf(RSI(55)>=55 AND RSI(55)<=60, colorPaleGreen 109 | ,IIf(RSI(55)>=60 AND RSI(55)<=65,colorTurquoise 110 | ,IIf(RSI(55)>=65 AND RSI(55)<=70,colorPaleBlue 111 | ,IIf(RSI(55)>=50 AND RSI(55)<=55,colorLightYellow 112 | ,IIf(RSI(55)>=45 AND RSI(55)<=50,colorRose 113 | ,IIf(RSI(55)>=40 AND RSI(55)<=45,colorPink 114 | ,colorWhite) 115 | ) 116 | ) 117 | ) 118 | ) 119 | ) 120 | ); 121 | AddColumn(RSI_BO,"RSI BO",1.2,colorDefault,IIf(RSI_BO,colorPaleGreen,colorRose)); 122 | AddColumn(Strength,"Strength",1.2,colorDefault,IIf(Strength,colorTurquoise,colorWhite)); 123 | AddColumn(C >= hzone,"85% of High260"); 124 | AddColumn(Buy,"PB EMA20",1.2,IIf(Buy,colorPaleGreen,colorBlack)); 125 | AddColumn(P_EMA50,"PB EMA50",1.2,IIf(P_EMA50,colorPaleGreen,colorBlack)); 126 | AddColumn((Close-KTop)*100/KTop,"% of Keltner130-5",1.2,colorDefault,IIf((Close-KTop)*100/KTop>=0,colorPaleGreen,colorRose)); 127 | AddColumn(BO_SP,"2W B.O",1.2,colorDefault,IIf(BO_SP,colorPaleGreen,colorRose)); 128 | AddColumn(BO_130,"26W B.O",1.2,colorDefault,IIf(BO_130,colorPaleGreen,colorRose)); 129 | AddColumn(BO_260,"52W B.O",1.2,colorDefault,IIf(BO_260,colorPaleGreen,colorRose)); 130 | AddColumn(ROC(Close,260),"ROC Year"); 131 | AddColumn(ROC(Close,10),"ROC 2Ws"); 132 | AddColumn(MovTrend,"MA Trend",1.2,colorDefault,IIf(MovTrend,colorPaleGreen,colorRose)); 133 | } 134 | } 135 | 136 | {//POSITION ================================== 137 | /*Position Score*/ 138 | PositionScore = ROC(Close,5); 139 | 140 | /*Position Size*/ 141 | /* PositionRisk = 1; // how much (in percent of equity) we risk in single position 142 | TradeRisk = (BuyPrice - Moving)/BuyPrice; // trade risk in percent equals to max. loss percentage stop 143 | PctSize = PositionRisk / TradeRisk; 144 | PositionSize = -1*PctSize; 145 | */ 146 | //SetPositionSize(5, spsPercentOfEquity); 147 | //End Position Size 148 | 149 | } 150 | 151 | {//STOP ================================== 152 | ApplyStop(stopTypeLoss, stopModePercent, 10); 153 | ApplyStop(stopTypeTrailing, stopModePercent, 25); 154 | ApplyStop(stopTypeProfit, stopModePercent, 30); 155 | ApplyStop(stopTypeNBar,stopModeBars,3); 156 | } -------------------------------------------------------------------------------- /Custom-Formulas/RANKING KAKA.afl: -------------------------------------------------------------------------------- 1 | percent=Param("percent",10,-20,20,1); 2 | Days=Param("Lookback Days",10,1,100,1); 3 | 4 | 5 | if(percent>0){ 6 | Filter =((C-LLV(C,Days))*100)/C>percent ; 7 | AddColumn(((C-LLV(C,Days))*100)/C,"Percentage change"); 8 | AddColumn(LLV(C,Days),"Lowest Closing "+Days+" days back"); 9 | 10 | } 11 | else if(percent<0){ 12 | Filter =((C-HHV(C,Days))*100)/C 0 , Positive, Negative), styleNoTitle | ParamStyle("Histogram style", styleHistogram | styleNoLabel, maskHistogram ) ); -------------------------------------------------------------------------------- /Custom-Formulas/ROC_vs_SET_RANK.afl: -------------------------------------------------------------------------------- 1 | {// ROC vs SET Ranking 2 | Month_ROC = ROC(Close,4) - ROC(Foreign("SET","Close"),4); 3 | Quarter_ROC = ROC(Close,12) - ROC(Foreign("SET","Close"),12); 4 | HY_ROC = ROC(Close,26) - ROC(Foreign("SET","Close"),26); 5 | Y_ROC = ROC(Close,26) - ROC(Foreign("SET","Close"),26); 6 | Short_RANK = 0.5*Month_ROC + 0.3*Quarter_ROC + 0.15*HY_ROC + 0.05*HY_ROC; 7 | Medium_RANK = 0.25*Month_ROC + 0.25*Quarter_ROC + 0.25*HY_ROC + 0.25*HY_ROC; 8 | Long_RANK = 0.05*Month_ROC + 0.15*Quarter_ROC + 0.3*HY_ROC + 0.5*HY_ROC; 9 | } 10 | Plot( Short_RANK, _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") ); -------------------------------------------------------------------------------- /Custom-Formulas/RSI - Relative Strength Index 4.afl: -------------------------------------------------------------------------------- 1 | _SECTION_BEGIN("Price"); 2 | SetChartOptions(0,chartShowArrows|chartShowDates); 3 | _N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) )); 4 | Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 5 | _SECTION_END(); -------------------------------------------------------------------------------- /Custom-Formulas/RSI-Explore.afl: -------------------------------------------------------------------------------- 1 | {//Option 2 | SetOption("NoDefaultColumns", True ); 3 | } 4 | {//MKC ===================================== 5 | SET = Foreign("SET","CLOSE"); 6 | } 7 | {//RSI Condition 8 | RSI_Period = Param("RSI PERIOD", 52, 1, 200, 1); 9 | myRSI = RSI(RSI_Period); 10 | RSI_high_Period = Param("RSI High Period",20,10,200,1); 11 | RSI_PrevHigh = Ref( HHV(myRSI,RSI_high_Period),-1); 12 | RSI_Since = BarsSince(RSI_PrevHigh < Ref(RSI_PrevHigh,-2)); 13 | RSI_BO = Cross(myRSI, RSI_PrevHigh); 14 | RSI_1stBOMonth = RSI_BO AND RSI_Since > 1; 15 | RSI_ROC = ROC(myRSI, RSI_high_Period); 16 | } 17 | {//RSI LEVELING 18 | myRSI_TR = Param("RSI TR" , 1 , 0 , 4.99, 0.01); 19 | lv45 = ( myRSI > 45 - myRSI_TR ) AND ( myRSI < 45 + myRSI_TR ); 20 | lv50 = ( myRSI > 50 - myRSI_TR ) AND ( myRSI < 50 + myRSI_TR ); 21 | lv55 = ( myRSI > 55 - myRSI_TR ) AND ( myRSI < 55 + myRSI_TR ); 22 | lv60 = ( myRSI > 60 - myRSI_TR ) AND ( myRSI < 60 + myRSI_TR ); 23 | lv65 = ( myRSI > 65 - myRSI_TR ) AND ( myRSI < 65 + myRSI_TR ); 24 | lv70 = ( myRSI > 70 - myRSI_TR ) AND ( myRSI < 70 + myRSI_TR ); 25 | RSI_LV = lv45 OR lv50 OR lv55 OR lv50 OR lv65 OR lv70; 26 | } 27 | rsiCon = RSI_BO OR ( RSI_LV AND myRSI >= 49.5); 28 | {//Liq 29 | Million = Param("Million Value", 5, 1, 1000,1); 30 | LiqCon = Avg* EMA(Volume, 20) > (1000000*Million); 31 | } 32 | {// Explorer 33 | Filter = rsiCon AND LiqCon; 34 | AddTextColumn( Name(), "Stock"); 35 | AddColumn(myRSI,"RSI"); 36 | AddColumn(RSI_PrevHigh,"RSI PrvHigh"); 37 | AddColumn(Ref(RSI_PrevHigh,-2),"RSI PrvHigh-2"); 38 | AddColumn(RSI_BO,"RSI-BO"); 39 | AddColumn(RSI_1stBOMonth,"RSI-1st-BO-Month"); 40 | AddColumn(RSI_ROC,"RSI ROC"); 41 | AddColumn(RSI_LV,"RSI@LV"); 42 | AddColumn(RSI_Since, "RSI Since"); 43 | } 44 | {// Charting // 45 | Plot( myRSI, "RSI55",IIf(myRSI > 55, colorGreen, colorRed),styleThick); 46 | } 47 | -------------------------------------------------------------------------------- /Custom-Formulas/Strength.afl: -------------------------------------------------------------------------------- 1 | TimeFrameSet( inWeekly ); 2 | field_value = ParamField("Field Value"); 3 | Perc = Param("%",100,1,100,1)/100; 4 | YtdHigh = Ref(HHV(field_value,52),-1)*Perc; 5 | TimeFrameRestore(); 6 | Plot(YtdHigh,"YTD High", ParamColor( "Color", colorCycle ), ParamStyle("Style")); -------------------------------------------------------------------------------- /Custom-Formulas/SupportResistance-Auto.afl: -------------------------------------------------------------------------------- 1 | _SECTION_BEGIN("SupportResistance"); 2 | // START SCRIPT UNTUK SUPPORT / RESISTANT 3 | // S/R RECODE by Stefanus Wardoyo @6March2014 - stefanus.wardoyo@infinitstudio.com 4 | 5 | WarnaResistant = ParamColor("Garis Resistant",colorBlack); 6 | WarnaSupport = ParamColor("Garis Support",colorRed); 7 | R1_show = 0; 8 | S1_show = 0; 9 | 10 | SRStyle = ParamStyle("S/R Style",styleDashed); 11 | 12 | if (ParamToggle("Garis Support&Resistance", "Off|On", 1 )) 13 | { 14 | // RESISTANT 15 | LastHighestValue = LastVisibleValue(Ref(H,-1)); 16 | if (LastVisibleValue(H) == H[LastValue(BarIndex())]) 17 | LastHighestValue = LastVisibleValue(H); 18 | 19 | i = 1; 20 | 21 | if (LastHighestValue < HighestVisibleValue(H)) 22 | { 23 | while (LastVisibleValue(ValueWhen(H <= Ref(H,-1) AND Ref(H,-2) <= Ref(H, -1),Ref(H, -1), i)) < LastHighestValue) 24 | i++; 25 | 26 | R1 = LastVisibleValue(ValueWhen(H <= Ref(H,-1) AND Ref(H,-2) <= Ref(H, -1),Ref(H, -1), i)); 27 | 28 | R1x = LastVisibleValue(ValueWhen(H <= Ref(H,-1) AND Ref(H,-2) <= Ref(H, -1),Ref(BarIndex(), -1), i)); 29 | Plot(IIf(BarIndex() >= R1x,LastValue(R1),Null),"R1",WarnaResistant ,SRStyle); 30 | PlotText("R1 : " + R1, BarCount + 1, LastValue(R1), WarnaResistant); 31 | R1_show = 1; 32 | 33 | i++; 34 | 35 | if (HighestVisibleValue( H ) > R1) 36 | { 37 | while (LastVisibleValue(ValueWhen(H <= Ref(H,-1) AND Ref(H,-2) <= Ref(H, -1), Ref(H,-1), i)) <= R1) 38 | i++; 39 | 40 | R2 = LastVisibleValue(ValueWhen(H <= Ref(H,-1) AND Ref(H,-2) <= Ref(H, -1), Ref(H,-1), i)); 41 | R2x = LastVisibleValue(ValueWhen(H <= Ref(H,-1) AND Ref(H,-2) <= Ref(H, -1),Ref(BarIndex(), -1), i)); 42 | 43 | Plot(IIf(BarIndex() >= R2x,LastValue(R2),Null),"R2",WarnaResistant ,SRStyle); 44 | PlotText("R2 : " + R2, BarCount + 1, LastValue(R2), WarnaResistant); 45 | i++; 46 | if (HighestVisibleValue( H )> R2) 47 | { 48 | while (LastVisibleValue(ValueWhen(H <= Ref(H,-1) AND Ref(H,-2) <= Ref(H, -1), Ref(H,-1), i)) <= R2) 49 | i++; 50 | R3 = LastVisibleValue(ValueWhen(H <= Ref(H,-1) AND Ref(H,-2) <= Ref(H, -1), Ref(H,-1), i)); 51 | R3x = LastVisibleValue(ValueWhen(H <= Ref(H,-1) AND Ref(H,-2) <= Ref(H, -1),Ref(BarIndex(), -1), i)); 52 | 53 | Plot(IIf(BarIndex() >= R3x,LastValue(R3),Null),"R3",WarnaResistant ,SRStyle); 54 | PlotText("R3 : " + R3, BarCount + 1, LastValue(R3), WarnaResistant); 55 | } 56 | } 57 | } 58 | else if (LastHighestValue == HighestVisibleValue(H)) 59 | { 60 | R1 = LastVisibleValue(ValueWhen(H <= Ref(H,-1) AND Ref(H,-2) <= Ref(H, -1),Ref(H, -1), i)); 61 | R1x = LastVisibleValue(ValueWhen(H <= Ref(H,-1) AND Ref(H,-2) <= Ref(H, -1),Ref(BarIndex(), -1), i)); 62 | if (R1 == LastHighestValue) 63 | { 64 | Plot(IIf(BarIndex() >= R1x,LastValue(R1),Null),"R1",WarnaResistant ,SRStyle); 65 | PlotText("R1 : " + R1, BarCount + 1, LastValue(R1), WarnaResistant); 66 | R1_show = 1; 67 | } 68 | } 69 | 70 | // SUPPORT 71 | LastLowestValue = LastVisibleValue(Ref(L,-1)); 72 | if (LastVisibleValue(L) == L[LastValue(BarIndex())]) 73 | LastLowestValue = LastVisibleValue(L); 74 | 75 | i = 1; 76 | 77 | if (LastLowestValue > LowestVisibleValue(L)) 78 | { 79 | while (LastVisibleValue(ValueWhen(L >= Ref(L,-1) AND Ref(L,-2) >= Ref(L, -1),Ref(L, -1), i)) > LastLowestValue) 80 | i++; 81 | 82 | S1 = LastVisibleValue(ValueWhen(L >= Ref(L,-1) AND Ref(L,-2) >= Ref(L, -1),Ref(L, -1), i)); 83 | S1x = LastVisibleValue(ValueWhen(L >= Ref(L,-1) AND Ref(L,-2) >= Ref(L, -1),Ref(BarIndex(), -1), i)); 84 | Plot(IIf(BarIndex() >= S1x,LastValue(S1),Null),"S1",WarnaSupport ,SRStyle); 85 | PlotText("S1 : " + S1, BarCount + 1, LastValue(S1), WarnaSupport); 86 | S1_show = 1; 87 | i++; 88 | 89 | if (LowestVisibleValue( L ) < S1) 90 | { 91 | while (LastVisibleValue(ValueWhen(L >= Ref(L,-1) AND Ref(L,-2) >= Ref(L, -1), Ref(L,-1), i)) >= S1) 92 | i++; 93 | 94 | S2 = LastVisibleValue(ValueWhen(L >= Ref(L,-1) AND Ref(L,-2) >= Ref(L, -1), Ref(L,-1), i)); 95 | S2x = LastVisibleValue(ValueWhen(L >= Ref(L,-1) AND Ref(L,-2) >= Ref(L, -1), Ref(BarIndex(),-1), i)); 96 | 97 | Plot(IIf(BarIndex() >= S2x,LastValue(S2),Null),"S2",WarnaSupport ,SRStyle); 98 | PlotText("S2 : " + S2, BarCount + 1, LastValue(S2), WarnaSupport); 99 | i++; 100 | if (LowestVisibleValue( L )< S2) 101 | { 102 | while (LastVisibleValue(ValueWhen(L >= Ref(L,-1) AND Ref(L,-2) >= Ref(L, -1), Ref(L,-1), i)) >= S2) 103 | i++; 104 | S3 = LastVisibleValue(ValueWhen(L >= Ref(L,-1) AND Ref(L,-2) >= Ref(L, -1), Ref(L,-1), i)); 105 | S3x = LastVisibleValue(ValueWhen(L >= Ref(L,-1) AND Ref(L,-2) >= Ref(L, -1), Ref(BarIndex(),-1), i)); 106 | Plot(IIf(BarIndex() >= S3x,LastValue(S3),Null),"S3",WarnaSupport ,SRStyle); 107 | PlotText("S3 : " + S3, BarCount + 1, LastValue(S3), WarnaSupport); 108 | } 109 | } 110 | } 111 | else if (LastLowestValue == LowestVisibleValue(L)) 112 | { 113 | S1 = LastVisibleValue(ValueWhen(L >= Ref(L,-1) AND Ref(L,-2) >= Ref(L, -1),Ref(L, -1), i)); 114 | S1x = LastVisibleValue(ValueWhen(L >= Ref(L,-1) AND Ref(L,-2) >= Ref(L, -1),Ref(BarIndex(), -1), i)); 115 | if (S1 == LastLowestValue) 116 | { 117 | Plot(IIf(BarIndex() >= S1x,LastValue(S1),Null),"S1",WarnaSupport ,SRStyle); 118 | PlotText("S1 : " + S1, BarCount + 1, LastValue(S1), WarnaSupport); 119 | S1_show = 1; 120 | } 121 | } 122 | 123 | if (S1_show AND R1_show) 124 | { 125 | SR = Prec((1-(S1/R1))*100,2); 126 | } 127 | } 128 | 129 | // END SCRIPT UNTUK SUPPORT / RESISTANT 130 | _SECTION_END(); 131 | 132 | Plot(C,"",colorBlack,styleCandle); -------------------------------------------------------------------------------- /Custom-Formulas/SupportResistance.afl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////// 2 | 3 | _SECTION_BEGIN("SupportResistance"); 4 | 5 | // START SCRIPT UNTUK SUPPORT / RESISTANT 6 | 7 | // S/R RECODE by Stefanus Wardoyo @6March2014 - stefanus.wardoyo@infinitstudio.com 8 | 9 | 10 | WarnaResistant = ParamColor("Warna Garis Resistant",colorBlack); 11 | 12 | WarnaSupport = ParamColor("Warna Garis Support",colorRed); 13 | 14 | R1_show = 0; 15 | 16 | S1_show = 0; 17 | 18 | 19 | SRStyle = ParamStyle("S/R Style",styleThick); 20 | 21 | 22 | if (ParamToggle("Garis Support&Resistance", "Tidak|Ya", 1 )) 23 | 24 | { 25 | 26 | // RESISTANT 27 | 28 | LastHighestValue = LastVisibleValue(Ref(H,-1)); 29 | 30 | if (LastVisibleValue(H) == H[LastValue(BarIndex())]) 31 | 32 | LastHighestValue = LastVisibleValue(H); 33 | 34 | 35 | i = 1; 36 | 37 | 38 | 39 | if (LastHighestValue < HighestVisibleValue(H)) 40 | 41 | { 42 | 43 | while (LastVisibleValue(ValueWhen(H <= Ref(H,-1) AND Ref(H,-2) <= Ref(H, -1),Ref(H, -1), i)) < LastHighestValue) 44 | 45 | i++; 46 | 47 | 48 | R1 = LastVisibleValue(ValueWhen(H <= Ref(H,-1) AND Ref(H,-2) <= Ref(H, -1),Ref(H, -1), i)); 49 | 50 | 51 | R1x = LastVisibleValue(ValueWhen(H <= Ref(H,-1) AND Ref(H,-2) <= Ref(H, -1),Ref(BarIndex(), -1), i)); 52 | 53 | Plot(IIf(BarIndex() >= R1x,LastValue(R1),Null),"R1",WarnaResistant ,SRStyle); 54 | 55 | PlotText("R1 : " + R1, BarCount + 1, LastValue(R1), WarnaResistant); 56 | 57 | R1_show = 1; 58 | 59 | 60 | i++; 61 | 62 | 63 | if (HighestVisibleValue( H ) > R1) 64 | 65 | { 66 | 67 | while (LastVisibleValue(ValueWhen(H <= Ref(H,-1) AND Ref(H,-2) <= Ref(H, -1), Ref(H,-1), i)) <= R1) 68 | 69 | i++; 70 | 71 | 72 | R2 = LastVisibleValue(ValueWhen(H <= Ref(H,-1) AND Ref(H,-2) <= Ref(H, -1), Ref(H,-1), i)); 73 | 74 | R2x = LastVisibleValue(ValueWhen(H <= Ref(H,-1) AND Ref(H,-2) <= Ref(H, -1),Ref(BarIndex(), -1), i)); 75 | 76 | 77 | 78 | Plot(IIf(BarIndex() >= R2x,LastValue(R2),Null),"R2",WarnaResistant ,SRStyle); 79 | 80 | PlotText("R2 : " + R2, BarCount + 1, LastValue(R2), WarnaResistant); 81 | 82 | i++; 83 | 84 | if (HighestVisibleValue( H )> R2) 85 | 86 | { 87 | 88 | while (LastVisibleValue(ValueWhen(H <= Ref(H,-1) AND Ref(H,-2) <= Ref(H, -1), Ref(H,-1), i)) <= R2) 89 | 90 | i++; 91 | 92 | R3 = LastVisibleValue(ValueWhen(H <= Ref(H,-1) AND Ref(H,-2) <= Ref(H, -1), Ref(H,-1), i)); 93 | 94 | R3x = LastVisibleValue(ValueWhen(H <= Ref(H,-1) AND Ref(H,-2) <= Ref(H, -1),Ref(BarIndex(), -1), i)); 95 | 96 | 97 | Plot(IIf(BarIndex() >= R3x,LastValue(R3),Null),"R3",WarnaResistant ,SRStyle); 98 | 99 | PlotText("R3 : " + R3, BarCount + 1, LastValue(R3), WarnaResistant); 100 | 101 | } 102 | 103 | } 104 | 105 | } 106 | 107 | else if (LastHighestValue == HighestVisibleValue(H)) 108 | 109 | { 110 | 111 | R1 = LastVisibleValue(ValueWhen(H <= Ref(H,-1) AND Ref(H,-2) <= Ref(H, -1),Ref(H, -1), i)); 112 | 113 | R1x = LastVisibleValue(ValueWhen(H <= Ref(H,-1) AND Ref(H,-2) <= Ref(H, -1),Ref(BarIndex(), -1), i)); 114 | 115 | if (R1 == LastHighestValue) 116 | 117 | { 118 | 119 | Plot(IIf(BarIndex() >= R1x,LastValue(R1),Null),"R1",WarnaResistant ,SRStyle); 120 | 121 | PlotText("R1 : " + R1, BarCount + 1, LastValue(R1), WarnaResistant); 122 | 123 | R1_show = 1; 124 | 125 | } 126 | 127 | } 128 | 129 | 130 | // SUPPORT 131 | 132 | LastLowestValue = LastVisibleValue(Ref(L,-1)); 133 | 134 | if (LastVisibleValue(L) == L[LastValue(BarIndex())]) 135 | 136 | LastLowestValue = LastVisibleValue(L); 137 | 138 | 139 | i = 1; 140 | 141 | 142 | if (LastLowestValue > LowestVisibleValue(L)) 143 | 144 | { 145 | 146 | while (LastVisibleValue(ValueWhen(L >= Ref(L,-1) AND Ref(L,-2) >= Ref(L, -1),Ref(L, -1), i)) > LastLowestValue) 147 | 148 | i++; 149 | 150 | 151 | S1 = LastVisibleValue(ValueWhen(L >= Ref(L,-1) AND Ref(L,-2) >= Ref(L, -1),Ref(L, -1), i)); 152 | 153 | S1x = LastVisibleValue(ValueWhen(L >= Ref(L,-1) AND Ref(L,-2) >= Ref(L, -1),Ref(BarIndex(), -1), i)); 154 | 155 | Plot(IIf(BarIndex() >= S1x,LastValue(S1),Null),"S1",WarnaSupport ,SRStyle); 156 | 157 | PlotText("S1 : " + S1, BarCount + 1, LastValue(S1), WarnaSupport); 158 | 159 | S1_show = 1; 160 | 161 | i++; 162 | 163 | 164 | if (LowestVisibleValue( L ) < S1) 165 | 166 | { 167 | 168 | while (LastVisibleValue(ValueWhen(L >= Ref(L,-1) AND Ref(L,-2) >= Ref(L, -1), Ref(L,-1), i)) >= S1) 169 | 170 | i++; 171 | 172 | 173 | S2 = LastVisibleValue(ValueWhen(L >= Ref(L,-1) AND Ref(L,-2) >= Ref(L, -1), Ref(L,-1), i)); 174 | 175 | S2x = LastVisibleValue(ValueWhen(L >= Ref(L,-1) AND Ref(L,-2) >= Ref(L, -1), Ref(BarIndex(),-1), i)); 176 | 177 | 178 | Plot(IIf(BarIndex() >= S2x,LastValue(S2),Null),"S2",WarnaSupport ,SRStyle); 179 | 180 | PlotText("S2 : " + S2, BarCount + 1, LastValue(S2), WarnaSupport); 181 | 182 | i++; 183 | 184 | if (LowestVisibleValue( L )< S2) 185 | 186 | { 187 | 188 | while (LastVisibleValue(ValueWhen(L >= Ref(L,-1) AND Ref(L,-2) >= Ref(L, -1), Ref(L,-1), i)) >= S2) 189 | 190 | i++; 191 | 192 | S3 = LastVisibleValue(ValueWhen(L >= Ref(L,-1) AND Ref(L,-2) >= Ref(L, -1), Ref(L,-1), i)); 193 | 194 | S3x = LastVisibleValue(ValueWhen(L >= Ref(L,-1) AND Ref(L,-2) >= Ref(L, -1), Ref(BarIndex(),-1), i)); 195 | 196 | Plot(IIf(BarIndex() >= S3x,LastValue(S3),Null),"S3",WarnaSupport ,SRStyle); 197 | 198 | PlotText("S3 : " + S3, BarCount + 1, LastValue(S3), WarnaSupport); 199 | 200 | } 201 | 202 | } 203 | 204 | } 205 | 206 | else if (LastLowestValue == LowestVisibleValue(L)) 207 | 208 | { 209 | 210 | S1 = LastVisibleValue(ValueWhen(L >= Ref(L,-1) AND Ref(L,-2) >= Ref(L, -1),Ref(L, -1), i)); 211 | 212 | S1x = LastVisibleValue(ValueWhen(L >= Ref(L,-1) AND Ref(L,-2) >= Ref(L, -1),Ref(BarIndex(), -1), i)); 213 | 214 | if (S1 == LastLowestValue) 215 | 216 | { 217 | 218 | Plot(IIf(BarIndex() >= S1x,LastValue(S1),Null),"S1",WarnaSupport ,SRStyle); 219 | 220 | PlotText("S1 : " + S1, BarCount + 1, LastValue(S1), WarnaSupport); 221 | 222 | S1_show = 1; 223 | 224 | } 225 | 226 | } 227 | 228 | 229 | if (S1_show AND R1_show) 230 | 231 | { 232 | 233 | SR = Prec((1-(S1/R1))*100,2); 234 | 235 | } 236 | 237 | } 238 | 239 | 240 | // END SCRIPT UNTUK SUPPORT / RESISTANT 241 | 242 | _SECTION_END(); 243 | 244 | 245 | ///////////////////////////////////////////////////////////////////////////// -------------------------------------------------------------------------------- /Custom-Formulas/Volume Price Analysis - V.1.0.afl: -------------------------------------------------------------------------------- 1 | //Volume Price Analysis AFL - VPA Version 1.0 2 | //AFL by Karthikmarar. Detailed explanation available at http://www.vpanalysis.blogspot.com 3 | //==================================================================================== 4 | _SECTION_BEGIN("Volume Price Analysis - V.1.0"); 5 | SetChartOptions(0,chartShowArrows|chartShowDates); 6 | //======================================================================================= 7 | DTL=Param("Linear regression period",60,10,100,10); 8 | wbf=Param("WRB factor",1.5,1.3,2.5,.1); 9 | nbf=Param("NRB factor",0.7,0.3,0.9,0.1); 10 | TL=LinRegSlope(MA(C, DTL),2); 11 | Vlp=Param("Volume lookback period",30,20,300,10); 12 | Vrg=MA(V,Vlp); 13 | St = StDev(Vrg,Vlp); 14 | Vp3 = Vrg + 3*st; 15 | Vp2 = Vrg + 2*st;; 16 | Vp1 = Vrg + 1*st;; 17 | Vn1 = Vrg -1*st; 18 | Vn2 = Vrg -2*st; 19 | rg=(H-L); 20 | arg=Wilders(rg,30); 21 | wrb=rg>(wbf*arg); 22 | nrb=rg<(nbf*arg); 23 | Vl=VRef(C,-1); 25 | dnbar=CRef(V,-1) AND Ref(V,-1)>Ref(V,-2); 27 | Cloc=C-L; 28 | x=rg/Cloc; 29 | x1=IIf(Cloc=0,arg,x); 30 | Vb=V>Vrg OR V>Ref(V,-1); 31 | ucls=x1<2; 32 | dcls=x1>2; 33 | mcls=x1<2.2 AND x1>1.8 ; 34 | Vlcls=x1>4; 35 | Vhcls=x1<1.35; 36 | j=MA(C,5); 37 | TLL=LinRegSlope(j,40) ; 38 | Tlm=LinRegSlope(j,15) ; 39 | tls=LinRegSlope(j,5); 40 | mp=(H+L)/2; 41 | _SECTION_END(); 42 | //========================================================================================== 43 | _SECTION_BEGIN("VSA"); 44 | utbar=wrb AND dcls AND tls>0 ; 45 | utcond1=Ref(utbar,-1) AND dnbar ; 46 | utcond2=Ref(utbar,-1) AND dnbar AND V>Ref(V,-1); 47 | utcond3=utbar AND V> 2*Vrg; 48 | trbar=Ref(V,-1)>Vrg AND Ref(upbar,-1) AND Ref(wrb,-1) AND dnbar AND dcls AND wrb AND tll>0 AND H==HHV(H,10); 49 | Hutbar=Ref(upbar,-1) AND Ref(V,-1)>1.5*Vrg AND dnbar AND dcls AND NOT wrb AND NOT utbar; 50 | Hutcond=Ref(Hutbar,-1) AND dnbar AND dcls AND NOT utbar; 51 | tcbar=Ref(upbar,-1) AND H==HHV(H,5)AND dnbar AND (dcls OR mcls) AND V>vrg AND NOT wrb AND NOT Hutbar ; 52 | Scond1=(utcond1 OR utcond2 OR utcond3) ; 53 | Scond2=Ref(scond1,-1)==0; 54 | scond=scond1 AND scond2; 55 | stdn0= tll<0 AND V>Ref(V,-1) AND Ref(dnbar,-1) AND upbar AND (ucls OR mcls) AND tls<0 AND tlm<0; 56 | stdn= V>Ref(V,-1) AND Ref(dnbar,-1) AND upbar AND (ucls OR mcls) AND tls<0 AND tlm<0; 57 | stdn1= tll<0 AND V>(vrg*1.5) AND Ref(dnbar,-1) AND upbar AND (ucls OR mcls)AND tls<0 AND tlm<0; 58 | stdn2=tls<0 AND Ref(V,-1)Vrg; 59 | bycond1= stdn OR stdn1; 60 | bycond= upbar AND Ref(bycond1,-1); 61 | stvol= L==LLV(L,5) AND (ucls OR mcls) AND V>1.5*Vrg AND tll<0; 62 | ndbar=upbar AND nrb AND Vl AND dcls ; 63 | nsbar=dnbar AND nrb AND Vl AND dcls ; 64 | nbbar= C>Ref(C,-1) AND Vl AND nrb AND x1<2; 65 | nbbar= IIf(C>Ref(C,-1) AND V0 AND tlm>0 AND wrb; 68 | lvtbar2= Ref(Lvtbar,-1) AND upbar AND ucls; 69 | dbar= V>2*Vrg AND dcls AND upbar AND tls>0 AND tlm>0 AND NOT Scond1 AND NOT utbar; 70 | eftup=H>Ref(H,-1) AND L>Ref(L,-1) AND C>Ref(C,-1) AND C>=((H-L)*0.7+L) AND rg>arg AND V>Ref(V,-1); 71 | eftupfl=Ref(eftup,-1) AND (utbar OR utcond1 OR utcond2 OR utcond3); 72 | eftdn=Harg AND V>Ref(V,-1); 73 | _SECTION_END(); 74 | //======================================================================================================================= 75 | _SECTION_BEGIN("Chart"); 76 | Vcolor=IIf(tls>0 AND tlm>0 AND tll>0,colorLime,IIf(tls>0 AND tlm>0 AND tll<0,colorGreen, 77 | IIf(tls>0 AND tlm<0 AND tll<0,colorPaleGreen,IIf(tls<0 AND tlm<0 AND tll<0,colorRed,IIf(tls<0 AND tlm>0 AND tll>0,colorPaleGreen, 78 | IIf(tls<0 AND tlm<0 AND tll>0,colorOrange,colorBlue)))))); 79 | GraphXSpace = 5; 80 | PlotOHLC( Open, High, Low, Close, "", vcolor, styleBar | styleThick ); 81 | _SECTION_END(); 82 | //============================================================================================================================ 83 | // commentary 84 | _SECTION_BEGIN("Commentary"); 85 | Vpc= utbar OR utcond1 OR utcond2 OR utcond3 OR stdn0 OR stdn1 OR stdn2 OR stdn OR lvtbar1 OR Lvtbar OR Lvtbar2 OR Hutbar OR Hutcond OR ndbar OR stvol OR tcbar; 86 | 87 | if( Status("action") == actionCommentary ) 88 | ( 89 | printf ( "=========================" +"\n")); 90 | printf ( "VOLUME PRICE ANALYSIS" +"\n"); 91 | printf ( "www.vpanalysis.blogspot.com" +"\n"); 92 | printf ( "=========================" +"\n"); 93 | printf ( Name() + " - " +Interval(2) + " - " + Date() +" - " +"\n"+"High-"+H+"\n"+"Low-"+L+"\n"+"Open-"+O+"\n"+ 94 | "Close-"+C+"\n"+ "Volume= "+ WriteVal(V)+"\n"); 95 | WriteIf(Vpc,"=======================",""); 96 | WriteIf(Vpc,"VOLUME ANALYSIS COMMENTARY:\n",""); 97 | 98 | WriteIf(utbar , "Up-thrusts are designed to catch stops and to mislead as many traders as possible. 99 | They are normally seen after there has been weakness in the background. The market makers know that the 100 | market is weak, so the price is marked up to catch stops, encourage traders to go long in a weak market, 101 | AND panic traders that are already Short into covering their very good position.","")+ 102 | WriteIf(utcond3,"This upthrust bar is at high volume.This is a sure sign of weakness. One may even seriously 103 | consider ending the Longs AND be ready to reverse","")+WriteIf(utbar OR utcond3," Also note that A wide spread 104 | down-bar that appears immediately after any up-thrust, tends to confirm the weakness (the market makers are 105 | locking in traders into poor positions). 106 | With the appearance of an upthrust you should 107 | certainly be paying attention to your trade AND your stops. On many upthrusts you will find that the market will 108 | 'test' almost immediately.","")+WriteIf(utcond1 , "A wide spread down bar following a Upthrust Bar. 109 | This confirms weakness. The Smart Money is locking in Traders into poor positions",""); 110 | WriteIf(utcond2 , "Also here the volume is high( Above Average).This is a sure sign of weakness. The Smart Money is 111 | locking in Traders into poor positions","")+WriteIf(stdn, "Strength Bar. The stock has been in a down Trend. An upbar 112 | with higher Volume closing near the High is a sign of strength returning. The downtrend is likely to reverse soon. ","")+ 113 | WriteIf(stdn1,"Here the volume is very much above average. This makes this indication more stronger. ","")+ 114 | WriteIf(bycond,"The previous bar saw strength coming back. This upbar confirms strength. ","")+ 115 | WriteIf(Hutbar," A pseudo Upthrust. This normally appears after an Up Bar with above average volume. This looks like an upthrust bar 116 | closing down near the Low. But the Volume is normally Lower than average. this is a sign of weakness.If the Volume is High then weakness 117 | increases. Smart Money is trying to trap the retailers into bad position. ","")+ 118 | WriteIf(Hutcond, "A downbar after a pseudo Upthrust Confirms weakness. If the volume is above average the weakness is increased. ","")+ 119 | WriteIf(Lvtbar2,"The previous bar was a successful Test of supply. The current bar is a upbar with higher volume. This confirms strength","")+ 120 | WriteIf(dbar,"A wide range, high volume bar in a up trend closing down is an indication the Distribution is in progress. The smart money 121 | is Selling the stock to the late Comers rushing to Buy the stock NOT to be Left Out Of a Bullish move. ","")+ 122 | WriteIf(Lvtbar2,"The previous bar was a successful Test of supply. The current bar is a upbar with higher volume. This confirms strength","")+ 123 | WriteIf(tcbar,"The stock has been moving up on high volume. The current bar is a Downbar with high volume. Indicates weakness and probably end of the up move","")+ 124 | WriteIf(eftup,"Effort to Rise bar. This normally found in the beginning of a Markup Phase and is bullish sign.These may be found at the top of an Upmove as the Smart money makes a 125 | last effort to move the price to the maximum","")+ 126 | WriteIf(eftdn,"Effort to Fall bar. This normally found in the beginning of a Markdown phase.","")+ 127 | 128 | WriteIf(nsbar,"No Supply. A no supply bar indicates supply has been removed and the Smart money can markup the price. It is better to wait for confirmation","")+ 129 | WriteIf(stvol,"Stopping Volume. This will be an downbar during a bearish period closing towards the Top accompanied by High volume. 130 | A stopping Volume normally indicates that smart money is absorbing the supply which is a Indication that they are Bullishon the MArket. 131 | Hence we Can expect a reversal in the down trend. ","")+ 132 | WriteIf(ndbar, "No Demand 133 | Brief Description: 134 | Any up bar which closes in the middle OR Low, especially if the Volume has fallen off, 135 | is a potential sign of weakness. 136 | 137 | Things to Look Out for: 138 | if the market is still strong, you will normally see signs of strength in the next few bars, 139 | which will most probably show itself as a: 140 | * Down bar with a narrow spread, closing in the middle OR High. 141 | * Down bar on Low Volume.",""); 142 | _SECTION_END(); 143 | 144 | //========================================================================================= 145 | //ploting the chart shapes 146 | _SECTION_BEGIN("Indications"); 147 | PlotShapes( shapeSmallSquare*(utbar AND NOT scond) , colorRed, 0, H, 10 ); 148 | PlotShapes(shapeSmallCircle*trbar, colorBlue, 0, H, 20 ); 149 | PlotShapes(shapeSmallDownTriangle*scond, colorRed, 0, H,-20); 150 | PlotShapes(shapeSmallSquare*stdn, colorLime, 0, L, -20 ); 151 | PlotShapes(shapeSmallSquare*stdn1, colorLime, 0, L, -20 ); 152 | PlotShapes(shapeSmallSquare*lvtbar1, colorLime, 0, L, -20 ); 153 | PlotShapes(shapeSmallUpTriangle*lvtbar2, colorYellow, 0, L, -20 ); 154 | PlotShapes(shapeHollowSmallCircle*stvol, colorLime, 0, L, -10 ); 155 | PlotShapes(shapeSmallUpTriangle*bycond, colorLime, 0, L, -20 ); 156 | PlotShapes(shapeSmallSquare*(Hutbar) , colorBlue, 0, H, 10 ); 157 | PlotShapes(shapeSmallDownTriangle*(Hutcond) , colorBlue, 0, H, -20 ); 158 | PlotShapes(shapeSmallDownTriangle*tcbar , colorYellow, 0, H, -20 ); 159 | PlotShapes(shapeSmallUpTriangle*stdn2, colorAqua, 0, L, -20 ); 160 | PlotShapes(shapeSmallSquare*(dbar) , colorBlue, 0, H, 10 ); 161 | PlotShapes(shapeSmallSquare*lvtbar, colorCustom12, 0, L, -20); 162 | PlotShapes(shapeSmallSquare*(ndbar) , colorBlue, 0, H, 10 ); 163 | PlotShapes(shapeSmallCircle*nsbar, colorLime, 0, L, -20 ); 164 | PlotShapes(shapeSmallCircle*eftup, colorTurquoise, 0, mp, 0 ); 165 | PlotShapes(shapeSmallCircle*eftdn, colorYellow, 0, mp, 0 ); 166 | 167 | _SECTION_END(); 168 | //====================================================================================================================================================================================== 169 | //TITLE 170 | _SECTION_BEGIN("Title"); 171 | if( Status("action") == actionIndicator ) 172 | ( 173 | Title = EncodeColor(colorWhite)+ "Volume Price Analysis" + " - " + Name() + " - " + EncodeColor(colorRed)+ Interval(2) + EncodeColor(colorWhite) + 174 | " - " + Date() +" - " +EncodeColor(colorLime)+ "Volume= "+WriteVal(V)+"--"+EncodeColor(colorYellow)+ 175 | WriteIf (utbar, " An Upthrust Bar. A sign of weakness. ","")+ 176 | WriteIf (utcond1, " A downbar after an Upthrust. Confirm weakness. ","")+ 177 | WriteIf (utcond2 AND NOT utcond1, " A High Volume downbar after an Upthrust. Confirm weakness.","")+ 178 | WriteIf (utcond3, "This upthrust at very High Voume, Confirms weakness","")+ 179 | WriteIf (stdn1, "Strength seen returning after a down trend. High volume adds to strength. ","")+ 180 | WriteIf (stdn0 AND NOT stdn, "Strength seen returning after a down trend. ","")+ 181 | WriteIf (stdn AND NOT stdn1, "Strength seen returning after a long down trend. ","")+ 182 | WriteIf (Lvtbar, "Test for supply. ","")+ 183 | WriteIf (Lvtbar2, "An Upbar closing near High after a Test confirms strength. ","")+ 184 | WriteIf (bycond, "An Upbar closing near High. Confirms return of Strength. ","")+ 185 | WriteIf (dbar, "A High Volume Up Bar closing down in a uptrend shows Distribution. ","")+ 186 | WriteIf (Hutbar, "Psuedo UpThrust. A Sign of Weakness. ","")+ 187 | WriteIf (Hutcond, "A Down Bar closing down after a Pseudo Upthrust confirms weakness. ","")+ 188 | WriteIf (Lvtbar1, "Test for supply in a uptrend. Sign of Strength. ","")+ 189 | WriteIf (stdn2, "High volume upbar closing on the high indicates strength. ","")+ 190 | WriteIf (Tcbar, "High volume Downbar after an upmove on high volume indicates weakness. ","")+ 191 | WriteIf (ndbar, "No Demand. A sign of Weakness. ","")+ 192 | WriteIf (nsbar, "No Supply. A sign of Strength. ","")+ 193 | WriteIf (eftup, "Effort to Rise. Bullish sign ","")+ 194 | WriteIf (eftdn, "Effort to Fall. Bearish sign ","")+ 195 | WriteIf (eftupfl, "Effort to Move up has failed. Bearish sign ","")+ 196 | WriteIf (stvol, "Stopping volume. Normally indicates end of bearishness is nearing. ","")+ 197 | ("\n Volume: ")+WriteIf(V>Vp2,EncodeColor(colorLime)+"Very High",WriteIf(V>Vp1,EncodeColor(colorLime)+" High",WriteIf(V>Vrg,EncodeColor(colorLime)+"Above Average", 198 | WriteIf(VVn1,EncodeColor(colorRed)+"Less than Average",WriteIf(V(arg*2),EncodeColor(colorLime)+" Wide",WriteIf(rg>arg,EncodeColor(colorLime)+" Above Average",EncodeColor(colorRed)+" Narrow"))+ 200 | (EncodeColor(colorYellow)+" Close: ")+WriteIf(Vhcls,EncodeColor(colorLime)+"Very High",WriteIf(ucls,EncodeColor(colorLime)+"High",WriteIf(mcls,EncodeColor(colorYellow)+"Mid", 201 | WriteIf(dcls,EncodeColor(colorRed)+"Down","Very Low"))))+ 202 | ("\n Trend: ")+WriteIf(tls>0,EncodeColor(colorLime)+" Short Term-UP",EncodeColor(colorRed)+" Short Term-Down")+ 203 | WriteIf(tlm>0,EncodeColor(colorLime)+" MID Term-UP",EncodeColor(colorRed)+" Mid Term-Down")+ 204 | WriteIf(tll>0,EncodeColor(colorLime)+" Long Term-Up",EncodeColor(colorRed)+" Long term-Down")); 205 | _SECTION_END(); 206 | //============================================================================================================================================================================================ 207 | _SECTION_BEGIN("Exploration"); 208 | 209 | Filter= utbar OR utcond2 OR utcond3 OR stdn OR stdn0 OR stdn1 OR stdn2; 210 | 211 | AddColumn(utcond3,"weekness coming in",1,colorWhite,IIf(utcond3,colorRed,colorWhite)); 212 | AddColumn(utcond2,"sure weakness",1,colorWhite,IIf(utcond2,colorRed,colorWhite)); 213 | AddColumn(utbar,"sure weakness",1,colorWhite,IIf(utbar,colorRed,colorWhite)); 214 | AddColumn(stdn ,"Strength after long dtrend",1,colorWhite,IIf(stdn,colorLime,colorWhite)); 215 | AddColumn(stdn0 ,"Strength after dtrend",1,colorWhite,IIf(stdn0,colorLime,colorWhite)); 216 | AddColumn(stdn1 ,"Strength stronger",1,colorWhite,IIf(stdn1,colorLime,colorWhite)); 217 | AddColumn(stdn2 ,"strength",1,colorWhite,IIf(stdn2,colorLime,colorWhite)); 218 | _SECTION_END(); 219 | //===================================================================== 220 | //background stock name (works only on Amibroker version 5.00 onwards. 221 | //===================================================================== 222 | _SECTION_BEGIN("Name"); 223 | GfxSetOverlayMode(1); 224 | GfxSelectFont("Tahoma", Status("pxheight")/6 ); 225 | GfxSetTextAlign( 6 );// center alignment 226 | //GfxSetTextColor( ColorRGB( 200, 200, 200 ) ); 227 | GfxSetTextColor( ColorHSB( 42, 42, 42 ) ); 228 | GfxSetBkMode(0); // transparent 229 | GfxTextOut( Name(), Status("pxwidth")/2, Status("pxheight")/12 ); 230 | GfxSelectFont("Tahoma", Status("pxheight")/12 ); 231 | GfxTextOut( "VPA", Status("pxwidth")/2, Status("pxheight")/3 ); 232 | GfxSelectFont("Tahoma", Status("pxheight")/36 ); 233 | GfxTextOut( "www.vpanalysis.blogspot.com", Status("pxwidth")/2, Status("pxheight")/2 ); 234 | _SECTION_END(); 235 | //================================== 236 | -------------------------------------------------------------------------------- /Custom-Formulas/Volume Spread Analysis.afl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anattapol/amibroker-afl/b1991f7963bb19ba58d9a3521d897aa815255506/Custom-Formulas/Volume Spread Analysis.afl -------------------------------------------------------------------------------- /Custom-Formulas/Volume-IBD.afl: -------------------------------------------------------------------------------- 1 | PreviousBar = Ref(C,-1); 2 | Color=IIf(C<=PreviousBar,ParamColor("Bearish",colorRed),ParamColor("Bullish",colorBlack)); 3 | Plot( Volume, _DEFAULT_NAME(), Color, ParamStyle( "Style", styleHistogram | styleOwnScale | styleThick, maskHistogram ) ); -------------------------------------------------------------------------------- /Custom-Formulas/Zone - RSI.afl: -------------------------------------------------------------------------------- 1 | _SECTION_BEGIN("Zone - RSI"); 2 | //PlotOHLC(70,70,65,65,"",colorPaleBlue,styleCloud); 3 | //PlotOHLC(65,65,60,60,"",colorPaleTurquoise,styleCloud); 4 | //PlotOHLC(60,60,55,55,"",colorPaleGreen,styleCloud); 5 | //PlotOHLC(55,55,50,50,"",colorLightYellow,styleCloud); 6 | //PlotOHLC(50,50,45,45,"",colorRose,styleCloud ); 7 | //PlotOHLC(45,45,40,40,"",colorPink,styleCloud ); 8 | Plot(70,"",colorBlue,styleLine); 9 | Plot(65,"",colorGreen,styleLine); 10 | Plot(60,"",colorAqua,styleLine); 11 | Plot(55,"",colorBlack,styleLine); 12 | Plot(50,"",colorDarkYellow,styleLine); 13 | Plot(45,"",colorRed,styleLine); 14 | //Plot(66.67,"",colorBlue,styleLine); 15 | _SECTION_END(); 16 | -------------------------------------------------------------------------------- /Custom-Formulas/chaloke-v1.afl: -------------------------------------------------------------------------------- 1 | ///// Chaloke.com Peak-Trough System 1.0 ///// 2 | 3 | X=1; 4 | Constant= 0.000; 5 | 6 | UpperO= Ref(Peak(C,X),-1); 7 | LowerO= Ref(Trough(C,X),-1); 8 | Upper= UpperO*(1 + Constant ); 9 | Lower= LowerO*(1 - Constant ); 10 | 11 | Buy = Cross(C, Upper); 12 | Sell= Cross(Lower,C); 13 | 14 | Color=IIf(BarsSince(Buy)= KTop; 19 | PriceColor = IIf( P >= KSuper, colorPink, 20 | IIf( P >= KTop AND KGoUp , colorGreen, 21 | IIf( P >= KTop AND KGoDown, colorGold, 22 | IIf( P >= CenterLine AND P < KTop AND KGoUp, colorBlue, colorRed) 23 | ) 24 | ) 25 | ); 26 | HitKSuper = Cross(P, KSuper) 27 | OR ( L<= KSuper AND H > KSuper); 28 | PriceColor = IIf( HitKSuper, colorBlack, PriceColor); 29 | PriceColor = IIf( myRSI >= 54.55, IIf(PriceColor == colorPink, colorBrightGreen, PriceColor), PriceColor); 30 | pctC2K = (Close - KTop)/KTop* 100; 31 | Plot( C, "Close", PriceColor, styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 32 | // Plot(KSuper, "K Super",colorBlack); 33 | // Plot(KTop, "K Top",colorGrey40); 34 | } 35 | {//EMA 36 | EMAPeriods = Param("EMA Periods", 18, 2, 300, 1, 10 ); 37 | movAvg = EMA( P, EMAPeriods ); 38 | EMAColor = IIf( Ref(movAvg, -1) > movAvg, colorRed, colorGold); 39 | Plot( movAvg,"EMA Avg", EMAColor, styleLine | styleThick ); 40 | } 41 | {// Liquidity 42 | liq = MA(Volume,10) * MA(Avg,10) > 10000000; 43 | } 44 | {// Filter 45 | Filter = (Ref(PriceColor,-1) != colorPink AND PriceColor == colorPink) OR 46 | (Ref(PriceColor,-1) != colorBrightGreen AND PriceColor == colorBrightGreen) OR 47 | (PriceColor == colorBlack); 48 | AddTextColumn( Name(), "Stock"); 49 | AddColumn(pctC2K,"% to Keltner"); 50 | } 51 | {//Back Testing Option 52 | SetOption("InitialEquity", 100000); 53 | SetOption("MaxOpenPositions", 100 ); 54 | PositionSize = -2; // invest 2% of portfolio equity in single trade 55 | priceRange = C > 0.8; 56 | } 57 | {// Buy-Sell 58 | Buy = (PriceColor == colorBrightGreen) AND (Ref(PriceColor,-1) != colorBrightGreen) AND liq; 59 | Sell = (PriceColor != colorBrightGreen) AND (Ref(PriceColor,-1) == colorBrightGreen); 60 | } 61 | {//Apply Stop 62 | //ApplyStop(stopTypeNBar, stopModeBars, 5); 63 | } -------------------------------------------------------------------------------- /Custom-Formulas/my_MFI.afl: -------------------------------------------------------------------------------- 1 | _SECTION_BEGIN("MFI"); 2 | periods = Param( "Periods", 14, 2, 200, 1 ); 3 | oversold = Param( "oversold", 30, 1, 100, 1 ); 4 | Plot( MFI(periods), _DEFAULT_NAME(), ParamColor("Color", colorCycle ), ParamStyle("Style") ); 5 | Plot( oversold, "Oversold", ParamColor("Color", colorCycle ), ParamStyle("Style") ); 6 | _SECTION_END(); 7 | -------------------------------------------------------------------------------- /Custom-Formulas/squeeze.afl: -------------------------------------------------------------------------------- 1 | 2 | top = ParamField("top"); 3 | bottom = ParamField("bottom"); 4 | 5 | //Plot(DonchianH,"Donchian Upper", ParamColor( "Color", colorCycle ), ParamStyle("Style")); 6 | PlotOHLC(top,top,bottom,bottom,"squeeze zone",ParamColor( "Color", colorCycle ),styleCloud ); 7 | -------------------------------------------------------------------------------- /Custom-Formulas/stock-200ma.afl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anattapol/amibroker-afl/b1991f7963bb19ba58d9a3521d897aa815255506/Custom-Formulas/stock-200ma.afl -------------------------------------------------------------------------------- /Custom-Formulas/support_line.afl: -------------------------------------------------------------------------------- 1 | // define reusable function 2 | function SupResLevels( bars, colorUp, ColorDn ) 3 | { 4 | bi = BarIndex(); 5 | lvbi = LastValue( bi ); 6 | 7 | // return HHV value only for bars starting from the bar where HHV level was established 8 | hv = IIf( bi >= lvbi - LastValue( HHVBars( High, bars ) ), LastValue( HHV( High, bars ) ), Null ); 9 | 10 | // the same approach for LLV 11 | lv = IIf( bi >= lvbi - LastValue( LLVBars( Low, bars ) ), LastValue( LLV( Low, bars ) ), Null ); 12 | 13 | // plot levels 14 | Plot( hv, "hv", colorUp, styleDashed ); 15 | Plot( lv, "lv", ColorDn, styleDashed ); 16 | } 17 | 18 | // price plot 19 | Plot( Close, "Close", colorDefault, styleBar ); 20 | 21 | // call function with various parameters 22 | SupResLevels( 10, colorGreen, colorRed ); 23 | SupResLevels( 50, colorGreen, colorRed ); -------------------------------------------------------------------------------- /Custom-Formulas/volume at price group.afl: -------------------------------------------------------------------------------- 1 | _SECTION_BEGIN("Customized VAP"); 2 | segment = Param("Enter the segment value in days", 2,2,100,1); 3 | MyInterval = Null; 4 | 5 | // Now we will have to create group of candles as per the segment value entered above 6 | // and keep them under one segment 7 | 8 | for(i=0;i tgt; 5 | state = IIf(a>b,-1,IIf(a==b,0,1)); 6 | Color = IIf(state == 0, colorBlack, IIf(state == 1, colorLime, IIf(state == -1, colorRed, 0))); 7 | 8 | //Plot(state, "", color, styleHistogram); 9 | 10 | SetChartOptions( 0, chartShowDates | chartShowArrows | chartLogarithmic | chartWrapTitle ); 11 | _N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) )); 12 | Plot( C, "Close", color, styleNoTitle |styleBar ); 13 | 14 | _SECTION_END(); 15 | 16 | _SECTION_BEGIN("DispMA"); 17 | P = ParamField("Field"); 18 | Type = ParamList("Type", "Simple,Exponential,Double Exponential,Tripple Exponential,Wilders,Weighted"); 19 | Periods = Param("Periods",30, 2, 300 ); 20 | Displacement = Param("Displacement", 15, -50, 50 ); 21 | m = 0; 22 | 23 | if( Type == "Simple" ) m = MA( P, Periods ); 24 | if( Type == "Exponential" ) m = EMA( P, Periods ); 25 | if( Type == "Double Exponential" ) m = DEMA( P, Periods ); 26 | if( Type == "Tripple Exponential" ) m = TEMA( P, Periods ); 27 | if( Type == "Wilders" ) m = Wilders( P, Periods ); 28 | if( Type == "Weighted" ) m = WMA( P, Periods ); 29 | 30 | Plot( m, _DEFAULT_NAME(), ParamColor("Color", ColorCycle), ParamStyle("Style"), 0, 0, Displacement ); 31 | _SECTION_END(); 32 | 33 | _SECTION_BEGIN("DispMA1"); 34 | P = ParamField("Field"); 35 | Type = ParamList("Type", "Simple,Exponential,Double Exponential,Tripple Exponential,Wilders,Weighted"); 36 | Periods = Param("Periods",30, 2, 300 ); 37 | Displacement = Param("Displacement", 15, -50, 50 ); 38 | m = 0; 39 | 40 | if( Type == "Simple" ) m = MA( P, Periods ); 41 | if( Type == "Exponential" ) m = EMA( P, Periods ); 42 | if( Type == "Double Exponential" ) m = DEMA( P, Periods ); 43 | if( Type == "Tripple Exponential" ) m = TEMA( P, Periods ); 44 | if( Type == "Wilders" ) m = Wilders( P, Periods ); 45 | if( Type == "Weighted" ) m = WMA( P, Periods ); 46 | 47 | Plot( m, _DEFAULT_NAME(), ParamColor("Color", ColorCycle), ParamStyle("Style"), 0, 0, Displacement ); 48 | _SECTION_END(); 49 | --------------------------------------------------------------------------------