//+--------------------------------------------------------------------------------------+ // F R A C T A L C H A N N E L | // Copyright © RickD BJF Trading Group 2006 | // http://fxstrategy.ca | // | //Experts http://fxstrategy.ca/experts.php SALE! 50% OFF | //Indicators http://fxstrategy.ca/products.php SALE!50% OFF | //Digital Filters Strategy http://fxstrategy.ca/digital_filtrs.php SALE!50% OFF | //Trading Signals http://fxstrategy.ca/signals.php Two weeks FREE! No CC. | // forex calendar, research, article .... | //+--------------------------------------------------------------------------------------+ #property copyright "© RickD BJF Trading Group 2006, modified by Scriptong 2010" #property link "http://fxstrategy.ca/products.php" #property indicator_chart_window #property indicator_buffers 2 #property indicator_color1 Red #property indicator_color2 Blue double FrUp[], FrDn[]; string UpLine = "FChan_Up", DnLine = "FChan_Down"; void init() { SetIndexBuffer(0, FrUp); SetIndexStyle(0, DRAW_SECTION); SetIndexBuffer(1, FrDn); SetIndexStyle(1, DRAW_SECTION); } void deinit() { if (ObjectFind(UpLine) == 0) ObjectDelete(UpLine); if (ObjectFind(DnLine) == 0) ObjectDelete(DnLine); } void ShowLine(string Name, datetime Time2, double Price2, datetime Time1, double Price1) { if (ObjectFind(Name) < 0) { ObjectCreate(Name, OBJ_TREND, 0, Time1, Price1, Time2, Price2); ObjectSet(Name, OBJPROP_RAY, true); if (Name == UpLine) ObjectSet(Name, OBJPROP_COLOR, indicator_color1); else ObjectSet(Name, OBJPROP_COLOR, indicator_color2); } else { ObjectMove(Name, 0, Time1, Price1); ObjectMove(Name, 1, Time2, Price2); } } void start() { int cb = IndicatorCounted(); if (cb > 0) cb--; int limit = Bars - cb; int CUp = 0, CDn = 0; bool ShowUp = false, ShowDn = false; for (int j = 2; j < limit; j++) { FrUp[j] = EMPTY_VALUE; FrDn[j] = EMPTY_VALUE; double fr = iFractals(NULL, 0, MODE_UPPER, j); if (fr > 0) { FrUp[j] = fr; if (CUp != 0 && !ShowUp) { ShowLine(UpLine, Time[CUp], FrUp[CUp], Time[j], fr); ShowUp = true; } CUp = j; } fr = iFractals(NULL, 0, MODE_LOWER, j); if (fr > 0) { FrDn[j] = fr; if (CDn != 0 && !ShowDn) { ShowLine(DnLine, Time[CDn], FrDn[CDn], Time[j], fr); ShowDn = true; } CDn = j; } } }