///////////////////////////////////////////////////////////////////////////// // // TRO Indicators for AmiBroker // // This code contains the TRO indicators for dynamic support and resistance, // Fibs based on the dynamic SRs, buy (and sell) zones, and the TRO slot // machine which displays the candle colors for the day and two user defined // timeframes (default is 5-min and 60-min). You can use the parameter screen // to turn the indicators on and off. // // The dynamic support and resistance is displayed as dots above and below the // price bars. Red is resistance and Blue is support. White dots indicate a // possible bounce trade off the dynamic SRs. The fibs are displayed as dotted // lines. // // The Buy (AND Sell) zones are displayed as colored ranges around the day's open // value (which is displayed as a white line). // // The TRO slot machine is a 4 tiered ribbon at the bottom of the price // chart. The bottom ribbon represents the day candle color (green is up and // red is down). The second and third ribbons are user defined timeframes // which also display the timeframe candle colors. The top ribbon shows sportatic // blocks which represent trade triggers relating to the white dots above and // below the price bars. A blue block is buy and a red block is sell. A trigger // is only displayed if one of the user specified timeframes is pointing in the // direction of the trigger. // // Compiled and written by: dbw451 // Date: July 27, 2007 // // Modifications: // // Note: this code is provided as is and no representations of any kind are // implied or made. As always, trading is at your own risk. // ///////////////////////////////////////////////////////////////////////////// SetChartOptions(0,chartShowArrows|chartShowDates); _N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} O %g, H %g, L %g, C %g (%.1f%%) Vol " +WriteVal( V, 1.0 ) +" {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 )) )); Plot(C, "C", colorWhite, styleCandle ); // Global Variables bDynamic_R = 0; bDynamic_S = 0; _SECTION_BEGIN("Toggles"); bPlotSR = ParamToggle("Dynamic SR","Off|On",True); bPlotFib = ParamToggle("Dynamic Fibs","Off|On",False); bPlotBZ = ParamToggle("Buy Zone","Off|On",True); bPlotSM = ParamToggle("Slot Machine","Off|On",True); _SECTION_END(); _SECTION_BEGIN("DynamicSR"); iPeriods = Param("Num Lookback Bars",5 ,1, 100,1); DayValue = Day(); NewDay[0] = 1; for( i = 1; i < BarCount; i++) { if (DayValue[i] == DayValue[i-1]) NewDay[i] = 0; else NewDay[i] = 1; } BarsSinceOpen = BarsSince(NewDay); PeriodToUse = IIf (BarsSinceOpen < iPeriods, BarsSinceOpen + 1, iPeriods); Dynamic_R = HHV(H,PeriodToUse); Dynamic_S = LLV(L,PeriodToUse); Dynamic_R = HHV(H,PeriodToUse); Dynamic_S = LLV(L,PeriodToUse); Dynamic_R = IIf(H >= Dynamic_R, H, Dynamic_R); Dynamic_S = IIf(H <= Dynamic_S ,L,Dynamic_S); DynamicRange = Dynamic_R - Dynamic_S; bDynamic_R = Ref(H,-1) == Dynamic_R AND Ref(C,-1) < Ref(H,-1); bDynamic_S = Ref(L,-1) == Dynamic_S AND Ref(C,-1) > Ref(L,-1); if(bPlotSR) { Plot(Dynamic_R,"DR", IIf(bDynamic_R, colorWhite, colorRed), styleDots | styleNoLine); Plot(Dynamic_S,"DS", IIf(bDynamic_S, colorWhite, colorBlue), styleDots | styleNoLine); } fib1 = Dynamic_S + .24 * DynamicRange; fib2 = Dynamic_S + .38 * DynamicRange; fib3 = Dynamic_S + .50 * DynamicRange; fib4 = Dynamic_S + .62 * DynamicRange; fib5 = Dynamic_S + .76 * DynamicRange; if(bPlotFib) { Plot(fib1,"F24", colorDarkGreen, styleDashed); Plot(fib2,"F38", colorBrown, styleDashed); Plot(fib3,"F50", colorGrey40, styleDashed); Plot(fib4,"F62", colorDarkYellow, styleDashed); Plot(fib5,"F76", colorDarkGreen, styleDashed); } _SECTION_END(); _SECTION_BEGIN("BuyZone"); // Programmer: Alex Chambers, May 2007 // For use with the BuyZone trading strategy at Kreslik.com // For Amibroker - just drag and drop // I, Alex Chambers, am not responsible for any results you may have from the use of this indicator // You must evaluate yourself the potential for gains AND losses // Please include this and/or any other comment description of any changes you make. // // July 26, 2007 // dbw451: Updated to show graphical zones instead of lines OpenTime = Param("TimeOfOpen",93000,0,160000,500); Points = Param("BuyZonePointsAway",5,0,50,1); Range = Param("BuyZoneRange",3,0,50,1); multiplier = Param("Multiplier",1,0,10000,100); bOpenBar = IIf(TimeNum() >= OpenTime AND TimeNum() < OpenTime+500,1,0); // note: 500 is for 5 minute timeframe dOpenBar = IIf(bOpenBar==1,Open,0); bzOpen = ValueWhen(bOpenBar==1,dOpenBar); bzPoints = Points / multiplier; bzRange = Range / multiplier; bzLongBot = bzOpen + bzPoints; bzLongTop = bzLongBot + bzRange; bzShortTop = bzOpen - bzPoints; bzShortBot = bzShortTop - bzRange; if (bPlotBZ) { Plot (bzOpen,"bzOpen",colorWhite, styleStaircase | styleNoRescale); PlotOHLC( bzLongBot,bzLongTop,bzLongBot,bzLongTop, "", colorPaleGreen, styleCloud | styleNoLabel | styleNoRescale); PlotOHLC( bzShortTop,bzShortBot,bzShortTop,bzShortBot, "", colorLightOrange, styleCloud | styleNoLabel | styleNoRescale); Plot(bzLongTop,"LZtop", colorPaleGreen, styleLine | styleNoRescale); // Plot line so value is displayed on chart axis Plot(bzShortBot,"SZbot", colorLightOrange, styleLine | styleNoRescale); } _SECTION_END(); _SECTION_BEGIN("SlotMachine"); if(bPlotSM) { Row2Minutes = Param("Row2 TimeFrame (min)",5,1,240,1); Row3Minutes = Param("Row3 TimeFrame (min)",60,1,240,1); Row2Time = Row2Minutes * 60; Row3Time = Row3Minutes * 60; TimeFrameSet(Row2Time); btfRow2 = C > O; TimeFrameRestore(); TimeFrameSet(Row3Time); btfRow3 = C > O; TimeFrameRestore(); bRow2 = TimeFrameExpand(btfRow2, Row2Time); bRow3 = TimeFrameExpand(btfRow3, Row3Time); bTrendTrigger = IIf((bDynamic_R AND (!bRow2 OR !bRow3)), 1, IIf((bDynamic_S AND (bRow2 OR bRow3)), 1, 0)); Plot( 1, "Day", IIf( C > bzOpen, colorGreen, colorDarkRed), styleOwnScale|styleArea|styleNoLabel, -0.5, 100 ); Plot( 2, "60min", IIf( bRow3, colorBrightGreen, colorRed), styleOwnScale|styleArea|styleNoLabel, -0.5, 100 ); Plot( 3, "5min", IIf( bRow2, colorGreen, colorDarkRed), styleOwnScale|styleArea|styleNoLabel, -0.5, 100 ); Plot( 4, "Trigger", IIf((bTrendTrigger AND bDynamic_S), colorBlue, IIf((bTrendTrigger AND bDynamic_R), colorRed, colorBlack)), styleOwnScale|styleArea|styleNoLabel, -0.5, 100 ); } _SECTION_END();