Code: Select all
//+------------------------------------------------------------------+
//| TRO_SMC_OB_Impulse_Dash.mq4 |
//| Copyright 2026, Forex Scalping |
//| https://forex-scalping.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2026, Forex Scalping"
#property link "https://forex-scalping.com"
#property version "3.08"
#property strict
#property indicator_chart_window
//--- Inputs
input bool DisplayDashboard = true; // Display Dashboard
input int X_Axis = 250; // X-Axis Position
input int Y_Axis = 100; // Y-Axis Position
input color DefaultTextColor = clrDimGray; // Default Text Color
input int ImpulseLookback = 60; // Bars to scan for impulse
input double ImpulseATRMult = 1.5; // Impulse size vs ATR
input bool UseBodyOnly = false; // OB zone: true=body, false=full candle
input int OBLookback = 200; // Bars back to search OBs
input int LiquidityLookback= 30; // Bars for liquidity sweep check
input bool RequireFVG = false; // Require FVG for OB validity
input int LabelBars = 15; // Bars offset for text labels
//--- Chart line colors (one input per drawn line/label)
input color Color_ImpTop = clrRed; // Impulse Top line/label
input color Color_ImpBot = clrBlue; // Impulse Bottom line/label
input color Color_BullOB = clrLightGreen; // Bullish OB line/label
input color Color_BearOB = clrCrimson; // Bearish OB line/label
input color Color_Entry = clrBrown; // Entry line/label
input color Color_Stop = clrDarkOrange; // Stop line/label
input color Color_TP1 = clrGold; // TP1 line/label
input color Color_TP2 = clrGold; // TP2 line/label
//--- Constants
#define OBJ_PREFIX "SMCOB_"
#define OBJ_PANEL OBJ_PREFIX + "Panel"
#define MAX_LINES 18
#define MAX_TRENDLINES 6
#define OBJ_BULL_OB OBJ_PREFIX + "BullOB"
#define OBJ_BEAR_OB OBJ_PREFIX + "BearOB"
#define OBJ_IMPULSE_TOP OBJ_PREFIX + "ImpTop"
#define OBJ_IMPULSE_BOT OBJ_PREFIX + "ImpBot"
#define OBJ_ENTRY OBJ_PREFIX + "Entry"
#define OBJ_STOP OBJ_PREFIX + "Stop"
#define OBJ_TP1 OBJ_PREFIX + "TP1"
#define OBJ_TP2 OBJ_PREFIX + "TP2"
//--- Global state
string g_LineNames[MAX_LINES];
string g_TrendNames[MAX_TRENDLINES];
string g_MyTag = OBJ_PREFIX;
datetime g_LastCalc = 0;
string g_LastSignal = "";
datetime g_SignalTime = 0;
//+------------------------------------------------------------------+
//| Timeframe to string |
//+------------------------------------------------------------------+
string TimeFrameToString(int tf)
{
switch(tf)
{
case PERIOD_M1: return("M1");
case PERIOD_M5: return("M5");
case PERIOD_M15: return("M15");
case PERIOD_M30: return("M30");
case PERIOD_H1: return("H1");
case PERIOD_H4: return("H4");
case PERIOD_D1: return("D1");
case PERIOD_W1: return("W1");
case PERIOD_MN1: return("MN1");
}
return("TF");
}
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
int i;
for(i = 0; i < MAX_LINES; i++)
g_LineNames[i] = OBJ_PREFIX + "Line_" + IntegerToString(i);
for(i = 0; i < MAX_TRENDLINES; i++)
g_TrendNames[i] = OBJ_PREFIX + "Trend_" + IntegerToString(i);
//--- Panel
if(ObjectFind(0, OBJ_PANEL) < 0)
{
ObjectCreate(0, OBJ_PANEL, OBJ_LABEL, 0, 0, 0);
ObjectSetInteger(0, OBJ_PANEL, OBJPROP_CORNER, CORNER_RIGHT_UPPER);
ObjectSetInteger(0, OBJ_PANEL, OBJPROP_XDISTANCE, X_Axis);
ObjectSetInteger(0, OBJ_PANEL, OBJPROP_YDISTANCE, Y_Axis);
ObjectSetInteger(0, OBJ_PANEL, OBJPROP_COLOR, DefaultTextColor);
ObjectSetInteger(0, OBJ_PANEL, OBJPROP_FONTSIZE, 10);
ObjectSetString(0, OBJ_PANEL, OBJPROP_FONT, "Consolas");
ObjectSetString(0, OBJ_PANEL, OBJPROP_TEXT, "=== SMC OB IMPULSE v3.08 ===");
ObjectSetInteger(0, OBJ_PANEL, OBJPROP_SELECTABLE, false);
ObjectSetInteger(0, OBJ_PANEL, OBJPROP_HIDDEN, true);
ObjectSetInteger(0, OBJ_PANEL, OBJPROP_BACK, false);
}
//--- Lines
for(i = 0; i < MAX_LINES; i++)
{
if(ObjectFind(0, g_LineNames[i]) < 0)
{
ObjectCreate(0, g_LineNames[i], OBJ_LABEL, 0, 0, 0);
ObjectSetInteger(0, g_LineNames[i], OBJPROP_CORNER, CORNER_RIGHT_UPPER);
ObjectSetInteger(0, g_LineNames[i], OBJPROP_XDISTANCE, X_Axis);
ObjectSetInteger(0, g_LineNames[i], OBJPROP_YDISTANCE, Y_Axis + 14 + (i * 13));
ObjectSetInteger(0, g_LineNames[i], OBJPROP_COLOR, DefaultTextColor);
ObjectSetInteger(0, g_LineNames[i], OBJPROP_FONTSIZE, 10);
ObjectSetString(0, g_LineNames[i], OBJPROP_FONT, "Consolas");
ObjectSetString(0, g_LineNames[i], OBJPROP_TEXT, "");
ObjectSetInteger(0, g_LineNames[i], OBJPROP_SELECTABLE, false);
ObjectSetInteger(0, g_LineNames[i], OBJPROP_HIDDEN, true);
ObjectSetInteger(0, g_LineNames[i], OBJPROP_BACK, false);
}
}
//--- Named horizontal trendlines
CreateHLine(OBJ_BULL_OB);
CreateHLine(OBJ_BEAR_OB);
CreateHLine(OBJ_IMPULSE_TOP);
CreateHLine(OBJ_IMPULSE_BOT);
CreateHLine(OBJ_ENTRY);
CreateHLine(OBJ_STOP);
CreateHLine(OBJ_TP1);
CreateHLine(OBJ_TP2);
//--- Generic trendlines
for(i = 0; i < MAX_TRENDLINES; i++)
{
if(ObjectFind(0, g_TrendNames[i]) < 0)
{
ObjectCreate(0, g_TrendNames[i], OBJ_TREND, 0, 0, 0, 0, 0);
ObjectSetInteger(0, g_TrendNames[i], OBJPROP_COLOR, DefaultTextColor);
ObjectSetInteger(0, g_TrendNames[i], OBJPROP_WIDTH, 1);
ObjectSetInteger(0, g_TrendNames[i], OBJPROP_RAY_RIGHT, false);
ObjectSetInteger(0, g_TrendNames[i], OBJPROP_SELECTABLE, false);
ObjectSetInteger(0, g_TrendNames[i], OBJPROP_HIDDEN, true);
ObjectSetInteger(0, g_TrendNames[i], OBJPROP_BACK, true);
}
}
g_SignalTime = TimeCurrent();
TRO();
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Helper: Create horizontal trendline |
//+------------------------------------------------------------------+
void CreateHLine(string name)
{
if(ObjectFind(0, name) < 0)
{
ObjectCreate(0, name, OBJ_TREND, 0, 0, 0, 0, 0);
ObjectSetInteger(0, name, OBJPROP_COLOR, DefaultTextColor);
ObjectSetInteger(0, name, OBJPROP_WIDTH, 1);
ObjectSetInteger(0, name, OBJPROP_RAY_RIGHT, false);
ObjectSetInteger(0, name, OBJPROP_SELECTABLE, false);
ObjectSetInteger(0, name, OBJPROP_HIDDEN, true);
ObjectSetInteger(0, name, OBJPROP_BACK, true);
ObjectSetInteger(0, name, OBJPROP_STYLE, STYLE_SOLID);
}
}
//+------------------------------------------------------------------+
//| Helper: Update horizontal trendline |
//+------------------------------------------------------------------+
void UpdateHLine(string name, datetime t1, datetime t2, double price, color clr, int width)
{
ObjectSetInteger(0, name, OBJPROP_TIME1, t1);
ObjectSetDouble(0, name, OBJPROP_PRICE1, price);
ObjectSetInteger(0, name, OBJPROP_TIME2, t2);
ObjectSetDouble(0, name, OBJPROP_PRICE2, price);
ObjectSetInteger(0, name, OBJPROP_COLOR, clr);
ObjectSetInteger(0, name, OBJPROP_WIDTH, width);
}
//+------------------------------------------------------------------+
//| Helper: Hide horizontal trendline |
//+------------------------------------------------------------------+
void HideHLine(string name)
{
ObjectSetInteger(0, name, OBJPROP_TIME1, 0);
ObjectSetInteger(0, name, OBJPROP_TIME2, 0);
}
//+------------------------------------------------------------------+
//| Draw price box (right price arrow) |
//+------------------------------------------------------------------+
void DrawPriceBox(string name, double price, color clr, datetime LabelTime)
{
string objName = g_MyTag + name + "BOX";
if(ObjectFind(0, objName) == -1)
{
ObjectCreate(0, objName, OBJ_ARROW, 0, Time[0], price);
ObjectSetInteger(0, objName, OBJPROP_ARROWCODE, SYMBOL_RIGHTPRICE);
ObjectSetInteger(0, objName, OBJPROP_SELECTABLE, false);
ObjectSetInteger(0, objName, OBJPROP_HIDDEN, true);
}
ObjectMove(0, objName, 0, Time[0], price);
ObjectSetInteger(0, objName, OBJPROP_COLOR, clr);
}
//+------------------------------------------------------------------+
//| Draw price label text |
//+------------------------------------------------------------------+
void DrawPriceLabel(string name, double price, color clr, datetime LabelTime)
{
string objName = g_MyTag + name + "LBL";
double pipSize = Point;
if(Digits == 3 || Digits == 5) pipSize = Point * 10.0;
double dPips = (Bid - price) / pipSize;
string tfStr = TimeFrameToString(Period());
string displayText = tfStr + " " + name + " " + DoubleToStr(dPips, 1);
if(ObjectFind(0, objName) < 0)
{
ObjectCreate(0, objName, OBJ_TEXT, 0, LabelTime, price);
ObjectSetInteger(0, objName, OBJPROP_SELECTABLE, false);
ObjectSetInteger(0, objName, OBJPROP_HIDDEN, true);
ObjectSetInteger(0, objName, OBJPROP_BACK, false);
}
ObjectSetInteger(0, objName, OBJPROP_COLOR, clr);
ObjectSetInteger(0, objName, OBJPROP_ANCHOR, ANCHOR_RIGHT_UPPER);
ObjectSetString(0, objName, OBJPROP_FONT, "Arial");
ObjectSetInteger(0, objName, OBJPROP_FONTSIZE, 10);
ObjectMove(0, objName, 0, LabelTime, price);
ObjectSetString(0, objName, OBJPROP_TEXT, displayText);
}
//+------------------------------------------------------------------+
//| Hide price box and its label |
//+------------------------------------------------------------------+
void HidePriceBox(string name)
{
string objBox = g_MyTag + name + "BOX";
string objLbl = g_MyTag + name + "LBL";
if(ObjectFind(0, objBox) >= 0) ObjectDelete(0, objBox);
if(ObjectFind(0, objLbl) >= 0) ObjectDelete(0, objLbl);
}
//+------------------------------------------------------------------+
//| Helper: Format distance in pips with sign |
//+------------------------------------------------------------------+
string FormatPips(double price, double curPrice)
{
double pipSize = Point;
if(Digits == 3 || Digits == 5) pipSize = Point * 10.0;
double diff = curPrice - price;
double pips = diff / pipSize;
string sign = "+";
if(pips < 0.0) sign = "";
return(sign + DoubleToString(pips, 1));
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
int i;
for(i = 0; i < MAX_LINES; i++)
ObjectDelete(0, g_LineNames[i]);
for(i = 0; i < MAX_TRENDLINES; i++)
ObjectDelete(0, g_TrendNames[i]);
ObjectDelete(0, OBJ_PANEL);
ObjectDelete(0, OBJ_BULL_OB);
ObjectDelete(0, OBJ_BEAR_OB);
ObjectDelete(0, OBJ_IMPULSE_TOP);
ObjectDelete(0, OBJ_IMPULSE_BOT);
ObjectDelete(0, OBJ_ENTRY);
ObjectDelete(0, OBJ_STOP);
ObjectDelete(0, OBJ_TP1);
ObjectDelete(0, OBJ_TP2);
//--- Remove price-box objects
HidePriceBox("IMP TOP");
HidePriceBox("IMP BOT");
HidePriceBox("BULL OB");
HidePriceBox("BEAR OB");
HidePriceBox("ENTRY");
HidePriceBox("STOP");
HidePriceBox("TP1");
HidePriceBox("TP2");
TRO();
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[])
{
//--- Local declarations at top of function
int i, j;
int lineIdx;
double curOpen, curHigh, curLow, curClose;
datetime curTime;
datetime calcStart;
datetime labelTime;
double atrVal;
//--- Impulse detection
int impulseStartBar;
int impulseEndBar;
bool bullImpulse;
bool bearImpulse;
bool hasImpulse;
double impulseHigh;
double impulseLow;
double impulseSize;
int impulseDir;
//--- Origin / OB
int obBar;
double obHigh, obLow, obOpen, obClose;
double obTop, obBot;
bool hasOB;
bool obBullish;
bool obMitigated;
//--- Liquidity sweep
bool sweepOK;
double priorSwingLow;
double priorSwingHigh;
//--- FVG / imbalance
bool hasFVG;
double fvgTop, fvgBot;
//--- Entry / stop / targets
double entryPrice;
double stopPrice;
double tp1, tp2;
double riskPoints;
double rewardPoints;
double rrRatio;
bool priceReturned;
//--- Signal
string signalText;
string stepText;
//--- Distance strings
string distImpTop, distImpBot, distOB, distEntry, distStop, distTP1, distTP2;
//--- Read bar data once
curTime = time[0];
curOpen = open[0];
curHigh = high[0];
curLow = low[0];
curClose = close[0];
atrVal = iATR(NULL, 0, 14, 1);
if(atrVal <= 0.0) atrVal = (curHigh - curLow);
//--- Initialize defaults
impulseStartBar = -1;
impulseEndBar = -1;
bullImpulse = false;
bearImpulse = false;
hasImpulse = false;
impulseHigh = 0.0;
impulseLow = 0.0;
impulseSize = 0.0;
impulseDir = 0;
obBar = -1;
obHigh = 0.0;
obLow = 0.0;
obOpen = 0.0;
obClose = 0.0;
obTop = 0.0;
obBot = 0.0;
hasOB = false;
obBullish = false;
obMitigated= false;
sweepOK = false;
priorSwingLow = 0.0;
priorSwingHigh = 0.0;
hasFVG = false;
fvgTop = 0.0;
fvgBot = 0.0;
entryPrice = 0.0;
stopPrice = 0.0;
tp1 = 0.0;
tp2 = 0.0;
riskPoints = 0.0;
rewardPoints = 0.0;
rrRatio = 0.0;
priceReturned= false;
signalText = "WAIT";
stepText = "Step 1: Scanning";
distImpTop = "-";
distImpBot = "-";
distOB = "-";
distEntry = "-";
distStop = "-";
distTP1 = "-";
distTP2 = "-";
//=================================================================
// STEP 1: Find the impulse (strong BOS/CHoCH move)
//=================================================================
int lookback = ImpulseLookback;
if(lookback > rates_total - 5) lookback = rates_total - 5;
double minImpulse = atrVal * ImpulseATRMult;
for(i = 2; i < lookback; i++)
{
if(close[i] > high[i+1] && (close[i] - open[i]) > minImpulse && close[i] > open[i])
{
bullImpulse = true;
impulseStartBar= i + 1;
impulseEndBar = i;
impulseHigh = high[i];
impulseLow = low[i+1];
impulseSize = close[i] - low[i+1];
impulseDir = 1;
hasImpulse = true;
break;
}
if(close[i] < low[i+1] && (open[i] - close[i]) > minImpulse && close[i] < open[i])
{
bearImpulse = true;
impulseStartBar= i + 1;
impulseEndBar = i;
impulseHigh = high[i+1];
impulseLow = low[i];
impulseSize = high[i+1] - close[i];
impulseDir = -1;
hasImpulse = true;
break;
}
}
//=================================================================
// STEP 2: Find the origin - last opposite candle before impulse
//=================================================================
if(hasImpulse)
{
stepText = "Step 2: Finding origin";
int originSearch = impulseStartBar;
int originLimit = originSearch + 10;
if(originLimit > rates_total - 2) originLimit = rates_total - 2;
for(j = originSearch; j < originLimit; j++)
{
obOpen = open[j];
obClose = close[j];
obHigh = high[j];
obLow = low[j];
if(impulseDir == 1 && obClose < obOpen)
{
obBar = j;
obBullish = true;
hasOB = true;
break;
}
if(impulseDir == -1 && obClose > obOpen)
{
obBar = j;
obBullish = false;
hasOB = true;
break;
}
}
if(hasOB)
{
if(UseBodyOnly)
{
obTop = MathMax(obOpen, obClose);
obBot = MathMin(obOpen, obClose);
}
else
{
obTop = obHigh;
obBot = obLow;
}
}
}
//=================================================================
// STEP 3: Check for liquidity sweep before the OB
//=================================================================
if(hasOB)
{
stepText = "Step 3: Liquidity check";
int liqLook = LiquidityLookback;
int liqStart = obBar + 1;
if(liqStart + liqLook > rates_total - 2) liqLook = rates_total - 2 - liqStart;
if(liqLook < 1) liqLook = 1;
priorSwingLow = low[liqStart];
priorSwingHigh = high[liqStart];
for(j = liqStart; j < liqStart + liqLook; j++)
{
if(low[j] < priorSwingLow) priorSwingLow = low[j];
if(high[j] > priorSwingHigh) priorSwingHigh = high[j];
}
if(obBullish && priorSwingLow < obLow) sweepOK = true;
if(!obBullish && priorSwingHigh > obHigh) sweepOK = true;
}
//=================================================================
// STEP 4: Look for imbalance (FVG) left behind by the impulse
//=================================================================
if(hasImpulse)
{
stepText = "Step 4: Imbalance check";
int fvgSearch = impulseEndBar;
int fvgLimit = fvgSearch + 5;
if(fvgLimit > rates_total - 3) fvgLimit = rates_total - 3;
for(j = fvgSearch; j < fvgLimit; j++)
{
if(impulseDir == 1 && high[j+2] < low[j])
{
fvgTop = low[j];
fvgBot = high[j+2];
hasFVG = true;
break;
}
if(impulseDir == -1 && low[j+2] > high[j])
{
fvgTop = low[j+2];
fvgBot = high[j];
hasFVG = true;
break;
}
}
}
//=================================================================
// STEP 5 & 6: Zone marked; check for return
//=================================================================
if(hasOB && (!RequireFVG || hasFVG))
{
stepText = "Step 6: Awaiting return";
for(i = 1; i < obBar && i < rates_total - 1; i++)
{
if(obBullish && low[i] <= obTop && high[i] >= obBot)
{
priceReturned = true;
break;
}
if(!obBullish && high[i] >= obBot && low[i] <= obTop)
{
priceReturned = true;
break;
}
}
for(i = 1; i < obBar && i < rates_total - 1; i++)
{
if(obBullish && close[i] < obBot)
{
obMitigated = true;
break;
}
if(!obBullish && close[i] > obTop)
{
obMitigated = true;
break;
}
}
}
//=================================================================
// STEP 7: Confirm on lower timeframe (CHoCH / rejection)
//=================================================================
bool confirmed = false;
if(hasOB && priceReturned && !obMitigated)
{
stepText = "Step 7: Confirmation";
if(obBullish)
{
if(curLow <= obTop && close[0] > open[0] && close[0] > close[1])
confirmed = true;
}
if(!obBullish)
{
if(curHigh >= obBot && close[0] < open[0] && close[0] < close[1])
confirmed = true;
}
}
//--- Entry / Stop / Targets
if(hasOB)
{
if(obBullish)
{
entryPrice = obTop;
stopPrice = obBot - (atrVal * 0.3);
}
else
{
entryPrice = obBot;
stopPrice = obTop + (atrVal * 0.3);
}
riskPoints = MathAbs(entryPrice - stopPrice);
if(riskPoints > 0.0)
{
if(obBullish)
{
tp1 = entryPrice + riskPoints;
tp2 = entryPrice + (riskPoints * 2.0);
if(impulseHigh > tp2) tp2 = impulseHigh;
}
else
{
tp1 = entryPrice - riskPoints;
tp2 = entryPrice - (riskPoints * 2.0);
if(impulseLow < tp2) tp2 = impulseLow;
}
rewardPoints = MathAbs(tp2 - entryPrice);
rrRatio = rewardPoints / riskPoints;
}
}
//--- Final signal
if(hasOB && !obMitigated && priceReturned && confirmed)
{
if(obBullish) signalText = "BUY";
else signalText = "SELL";
}
else if(hasOB && !obMitigated && priceReturned)
{
signalText = "WAIT";
stepText = "Step 7: Awaiting confirmation";
}
//--- Update signal time
if(signalText != "WAIT")
{
if(signalText != g_LastSignal)
{
g_LastSignal = signalText;
g_SignalTime = curTime;
}
}
else
{
g_LastSignal = signalText;
g_SignalTime = curTime;
}
//--- Compute distance strings (pips from current price)
if(hasImpulse)
{
distImpTop = FormatPips(impulseHigh, curClose);
distImpBot = FormatPips(impulseLow, curClose);
}
if(hasOB)
{
if(obBullish)
distOB = FormatPips(obTop, curClose);
else
distOB = FormatPips(obBot, curClose);
}
if(hasOB && !obMitigated)
{
distEntry = FormatPips(entryPrice, curClose);
distStop = FormatPips(stopPrice, curClose);
distTP1 = FormatPips(tp1, curClose);
distTP2 = FormatPips(tp2, curClose);
}
//--- Only update display on new bar
if(curTime == g_LastCalc && prev_calculated > 0)
return(rates_total);
g_LastCalc = curTime;
//=================================================================
// Dashboard update
//=================================================================
if(DisplayDashboard)
{
lineIdx = 0;
ObjectSetString(0, OBJ_PANEL, OBJPROP_TEXT, "=== SMC OB IMPULSE v3.08 ===");
ObjectSetInteger(0, OBJ_PANEL, OBJPROP_COLOR, DefaultTextColor);
//--- Line 0: Impulse status
if(lineIdx < MAX_LINES)
{
ObjectSetString(0, g_LineNames[lineIdx], OBJPROP_TEXT,
"Impulse: " + (hasImpulse ? (impulseDir == 1 ? "BULL" : "BEAR") : "NONE"));
ObjectSetInteger(0, g_LineNames[lineIdx], OBJPROP_COLOR, DefaultTextColor);
ObjectSetInteger(0, g_LineNames[lineIdx], OBJPROP_YDISTANCE, Y_Axis + 14 + (lineIdx * 13));
lineIdx++;
}
//--- Line 1: Impulse size
if(lineIdx < MAX_LINES)
{
ObjectSetString(0, g_LineNames[lineIdx], OBJPROP_TEXT,
"ImpSize: " + DoubleToString(impulseSize / Point, 1) + " pts");
ObjectSetInteger(0, g_LineNames[lineIdx], OBJPROP_COLOR, DefaultTextColor);
ObjectSetInteger(0, g_LineNames[lineIdx], OBJPROP_YDISTANCE, Y_Axis + 14 + (lineIdx * 13));
lineIdx++;
}
//--- Line 2: Impulse High + distance
if(lineIdx < MAX_LINES)
{
ObjectSetString(0, g_LineNames[lineIdx], OBJPROP_TEXT,
"ImpHigh: " + DoubleToString(impulseHigh, Digits) + " (" + distImpTop + " pips)");
ObjectSetInteger(0, g_LineNames[lineIdx], OBJPROP_COLOR, DefaultTextColor);
ObjectSetInteger(0, g_LineNames[lineIdx], OBJPROP_YDISTANCE, Y_Axis + 14 + (lineIdx * 13));
lineIdx++;
}
//--- Line 3: Impulse Low + distance
if(lineIdx < MAX_LINES)
{
ObjectSetString(0, g_LineNames[lineIdx], OBJPROP_TEXT,
"ImpLow: " + DoubleToString(impulseLow, Digits) + " (" + distImpBot + " pips)");
ObjectSetInteger(0, g_LineNames[lineIdx], OBJPROP_COLOR, DefaultTextColor);
ObjectSetInteger(0, g_LineNames[lineIdx], OBJPROP_YDISTANCE, Y_Axis + 14 + (lineIdx * 13));
lineIdx++;
}
//--- Line 4: OB type
if(lineIdx < MAX_LINES)
{
ObjectSetString(0, g_LineNames[lineIdx], OBJPROP_TEXT,
"OB Type: " + (hasOB ? (obBullish ? "BULLISH" : "BEARISH") : "NONE"));
ObjectSetInteger(0, g_LineNames[lineIdx], OBJPROP_COLOR, DefaultTextColor);
ObjectSetInteger(0, g_LineNames[lineIdx], OBJPROP_YDISTANCE, Y_Axis + 14 + (lineIdx * 13));
lineIdx++;
}
//--- Line 5: OB Top + distance
if(lineIdx < MAX_LINES)
{
ObjectSetString(0, g_LineNames[lineIdx], OBJPROP_TEXT,
"OB Top: " + DoubleToString(obTop, Digits) + " (" + distOB + " pips)");
ObjectSetInteger(0, g_LineNames[lineIdx], OBJPROP_COLOR, DefaultTextColor);
ObjectSetInteger(0, g_LineNames[lineIdx], OBJPROP_YDISTANCE, Y_Axis + 14 + (lineIdx * 13));
lineIdx++;
}
//--- Line 6: OB Bottom
if(lineIdx < MAX_LINES)
{
ObjectSetString(0, g_LineNames[lineIdx], OBJPROP_TEXT,
"OB Bot: " + DoubleToString(obBot, Digits));
ObjectSetInteger(0, g_LineNames[lineIdx], OBJPROP_COLOR, DefaultTextColor);
ObjectSetInteger(0, g_LineNames[lineIdx], OBJPROP_YDISTANCE, Y_Axis + 14 + (lineIdx * 13));
lineIdx++;
}
//--- Line 7: OB Mode
if(lineIdx < MAX_LINES)
{
ObjectSetString(0, g_LineNames[lineIdx], OBJPROP_TEXT,
"OB Zone: " + (UseBodyOnly ? "BODY" : "FULL"));
ObjectSetInteger(0, g_LineNames[lineIdx], OBJPROP_COLOR, DefaultTextColor);
ObjectSetInteger(0, g_LineNames[lineIdx], OBJPROP_YDISTANCE, Y_Axis + 14 + (lineIdx * 13));
lineIdx++;
}
//--- Line 8: Liquidity sweep
if(lineIdx < MAX_LINES)
{
ObjectSetString(0, g_LineNames[lineIdx], OBJPROP_TEXT,
"LiqSweep: " + (sweepOK ? "YES" : "NO"));
ObjectSetInteger(0, g_LineNames[lineIdx], OBJPROP_COLOR, DefaultTextColor);
ObjectSetInteger(0, g_LineNames[lineIdx], OBJPROP_YDISTANCE, Y_Axis + 14 + (lineIdx * 13));
lineIdx++;
}
//--- Line 9: FVG status
if(lineIdx < MAX_LINES)
{
ObjectSetString(0, g_LineNames[lineIdx], OBJPROP_TEXT,
"FVG: " + (hasFVG ? DoubleToString(fvgBot, Digits) + "-" + DoubleToString(fvgTop, Digits) : "NONE"));
ObjectSetInteger(0, g_LineNames[lineIdx], OBJPROP_COLOR, DefaultTextColor);
ObjectSetInteger(0, g_LineNames[lineIdx], OBJPROP_YDISTANCE, Y_Axis + 14 + (lineIdx * 13));
lineIdx++;
}
//--- Line 10: Mitigated
if(lineIdx < MAX_LINES)
{
ObjectSetString(0, g_LineNames[lineIdx], OBJPROP_TEXT,
"Mitigated:" + (obMitigated ? " YES" : " NO"));
ObjectSetInteger(0, g_LineNames[lineIdx], OBJPROP_COLOR, DefaultTextColor);
ObjectSetInteger(0, g_LineNames[lineIdx], OBJPROP_YDISTANCE, Y_Axis + 14 + (lineIdx * 13));
lineIdx++;
}
//--- Line 11: Returned
if(lineIdx < MAX_LINES)
{
ObjectSetString(0, g_LineNames[lineIdx], OBJPROP_TEXT,
"Returned: " + (priceReturned ? "YES" : "NO"));
ObjectSetInteger(0, g_LineNames[lineIdx], OBJPROP_COLOR, DefaultTextColor);
ObjectSetInteger(0, g_LineNames[lineIdx], OBJPROP_YDISTANCE, Y_Axis + 14 + (lineIdx * 13));
lineIdx++;
}
//--- Line 12: Entry + distance
if(lineIdx < MAX_LINES)
{
ObjectSetString(0, g_LineNames[lineIdx], OBJPROP_TEXT,
"Entry: " + DoubleToString(entryPrice, Digits) + " (" + distEntry + " pips)");
ObjectSetInteger(0, g_LineNames[lineIdx], OBJPROP_COLOR, DefaultTextColor);
ObjectSetInteger(0, g_LineNames[lineIdx], OBJPROP_YDISTANCE, Y_Axis + 14 + (lineIdx * 13));
lineIdx++;
}
//--- Line 13: Stop + distance
if(lineIdx < MAX_LINES)
{
ObjectSetString(0, g_LineNames[lineIdx], OBJPROP_TEXT,
"Stop: " + DoubleToString(stopPrice, Digits) + " (" + distStop + " pips)");
ObjectSetInteger(0, g_LineNames[lineIdx], OBJPROP_COLOR, DefaultTextColor);
ObjectSetInteger(0, g_LineNames[lineIdx], OBJPROP_YDISTANCE, Y_Axis + 14 + (lineIdx * 13));
lineIdx++;
}
//--- Line 14: TP1 + distance
if(lineIdx < MAX_LINES)
{
ObjectSetString(0, g_LineNames[lineIdx], OBJPROP_TEXT,
"TP1(1R): " + DoubleToString(tp1, Digits) + " (" + distTP1 + " pips)");
ObjectSetInteger(0, g_LineNames[lineIdx], OBJPROP_COLOR, DefaultTextColor);
ObjectSetInteger(0, g_LineNames[lineIdx], OBJPROP_YDISTANCE, Y_Axis + 14 + (lineIdx * 13));
lineIdx++;
}
//--- Line 15: TP2 + distance
if(lineIdx < MAX_LINES)
{
ObjectSetString(0, g_LineNames[lineIdx], OBJPROP_TEXT,
"TP2(2R): " + DoubleToString(tp2, Digits) + " (" + distTP2 + " pips)");
ObjectSetInteger(0, g_LineNames[lineIdx], OBJPROP_COLOR, DefaultTextColor);
ObjectSetInteger(0, g_LineNames[lineIdx], OBJPROP_YDISTANCE, Y_Axis + 14 + (lineIdx * 13));
lineIdx++;
}
//--- Line 16: RR
if(lineIdx < MAX_LINES)
{
ObjectSetString(0, g_LineNames[lineIdx], OBJPROP_TEXT,
"RR: 1:" + DoubleToString(rrRatio, 2));
ObjectSetInteger(0, g_LineNames[lineIdx], OBJPROP_COLOR, DefaultTextColor);
ObjectSetInteger(0, g_LineNames[lineIdx], OBJPROP_YDISTANCE, Y_Axis + 14 + (lineIdx * 13));
lineIdx++;
}
//--- Line 17: Signal + Time (LAST LINE)
if(lineIdx < MAX_LINES)
{
ObjectSetString(0, g_LineNames[lineIdx], OBJPROP_TEXT,
"SIGNAL: " + signalText + " @ " + TimeToString(g_SignalTime, TIME_DATE|TIME_MINUTES));
ObjectSetInteger(0, g_LineNames[lineIdx], OBJPROP_COLOR, DefaultTextColor);
ObjectSetInteger(0, g_LineNames[lineIdx], OBJPROP_YDISTANCE, Y_Axis + 14 + (lineIdx * 13));
lineIdx++;
}
//--- Hide unused lines
for(i = lineIdx; i < MAX_LINES; i++)
ObjectSetString(0, g_LineNames[i], OBJPROP_TEXT, "");
}
//=================================================================
// Update trendlines and price boxes
//=================================================================
calcStart = time[MathMin(100, rates_total - 1)];
//--- Label placement time (near right edge, offset LabelBars back)
int labelBarIdx = LabelBars;
if(labelBarIdx >= rates_total) labelBarIdx = rates_total - 1;
if(labelBarIdx < 1) labelBarIdx = 1;
labelTime = time[labelBarIdx];
//--- Impulse Top
if(hasImpulse)
{
UpdateHLine(OBJ_IMPULSE_TOP, calcStart, curTime, impulseHigh, Color_ImpTop, 1);
DrawPriceBox("IMP TOP", impulseHigh, Color_ImpTop, labelTime);
DrawPriceLabel("IMP TOP", impulseHigh, Color_ImpTop, labelTime);
}
else
{
HideHLine(OBJ_IMPULSE_TOP);
HidePriceBox("IMP TOP");
}
//--- Impulse Bottom
if(hasImpulse)
{
UpdateHLine(OBJ_IMPULSE_BOT, calcStart, curTime, impulseLow, Color_ImpBot, 1);
DrawPriceBox("IMP BOT", impulseLow, Color_ImpBot, labelTime);
DrawPriceLabel("IMP BOT", impulseLow, Color_ImpBot, labelTime);
}
else
{
HideHLine(OBJ_IMPULSE_BOT);
HidePriceBox("IMP BOT");
}
//--- Bullish OB
if(hasOB && obBullish)
{
UpdateHLine(OBJ_BULL_OB, calcStart, curTime, (obTop + obBot) / 2.0, Color_BullOB, 2);
DrawPriceBox("BULL OB", (obTop + obBot) / 2.0, Color_BullOB, labelTime);
DrawPriceLabel("BULL OB", (obTop + obBot) / 2.0, Color_BullOB, labelTime);
}
else
{
HideHLine(OBJ_BULL_OB);
HidePriceBox("BULL OB");
}
//--- Bearish OB
if(hasOB && !obBullish)
{
UpdateHLine(OBJ_BEAR_OB, calcStart, curTime, (obTop + obBot) / 2.0, Color_BearOB, 2);
DrawPriceBox("BEAR OB", (obTop + obBot) / 2.0, Color_BearOB, labelTime);
DrawPriceLabel("BEAR OB", (obTop + obBot) / 2.0, Color_BearOB, labelTime);
}
else
{
HideHLine(OBJ_BEAR_OB);
HidePriceBox("BEAR OB");
}
//--- Entry
if(hasOB && !obMitigated)
{
UpdateHLine(OBJ_ENTRY, calcStart, curTime, entryPrice, Color_Entry, 1);
DrawPriceBox("ENTRY", entryPrice, Color_Entry, labelTime);
DrawPriceLabel("ENTRY", entryPrice, Color_Entry, labelTime);
}
else
{
HideHLine(OBJ_ENTRY);
HidePriceBox("ENTRY");
}
//--- Stop
if(hasOB && !obMitigated)
{
UpdateHLine(OBJ_STOP, calcStart, curTime, stopPrice, Color_Stop, 1);
DrawPriceBox("STOP", stopPrice, Color_Stop, labelTime);
DrawPriceLabel("STOP", stopPrice, Color_Stop, labelTime);
}
else
{
HideHLine(OBJ_STOP);
HidePriceBox("STOP");
}
//--- TP1
if(hasOB && !obMitigated)
{
UpdateHLine(OBJ_TP1, calcStart, curTime, tp1, Color_TP1, 1);
DrawPriceBox("TP1", tp1, Color_TP1, labelTime);
DrawPriceLabel("TP1", tp1, Color_TP1, labelTime);
}
else
{
HideHLine(OBJ_TP1);
HidePriceBox("TP1");
}
//--- TP2
if(hasOB && !obMitigated)
{
UpdateHLine(OBJ_TP2, calcStart, curTime, tp2, Color_TP2, 1);
DrawPriceBox("TP2", tp2, Color_TP2, labelTime);
DrawPriceLabel("TP2", tp2, Color_TP2, labelTime);
}
else
{
HideHLine(OBJ_TP2);
HidePriceBox("TP2");
}
return(rates_total);
}
//+------------------------------------------------------------------+
void TRO()
{
string TRO_OBJ = "TROTAG" ;
ObjectCreate(TRO_OBJ, OBJ_LABEL, 0, 0, 0);
ObjectSetText(TRO_OBJ, CharToStr(78) , 12 , "Wingdings", clrLimeGreen );
ObjectSet(TRO_OBJ, OBJPROP_CORNER, 3);
ObjectSet(TRO_OBJ, OBJPROP_XDISTANCE, 5 );
ObjectSet(TRO_OBJ, OBJPROP_YDISTANCE, 5 );
}
//+------------------------------------------------------------------+