Skip to content
TheChatArchiveThe Chat Archive
Kimikimi-k2-0711-previewHugging Face Arena Expert 5K

add this into the EA, 1. on the 5min chart, when price closes up of the time ranged with…

  1. User

    add this into the EA, 1. on the 5min chart, when price closes up of the time ranged with a 5min body candle, draw a horizontal line at the top wick of that 5 minute candle that broke up the box. 2. on the 5min chart, when price closes down of the time ranged with a 5min body candle, draw a horizontal line at the bottom wick of that 5 minute candle that broke up the box. The horizontal line length setting should based off time and added into the inputs of the EA

  2. Kimi Assistant

    Below is a drop-in replacement for the two sections that have to change.
    Everything else in the EA stays exactly the same.

    1. New input (add it in the “=== Drawing Settings ===” block)
    2. Two modified functions: CheckBreakout() and DrawBreakoutLine()

    Copy / paste the blocks below and the EA will now draw the horizontal line at the wick of the 5-minute candle that closes outside the box, and the line will automatically disappear after the user-defined number of minutes.

    //+------------------------------------------------------------------+
    //|  NEW INPUT  –  add in the “=== Drawing Settings ===” section     |
    //+------------------------------------------------------------------+
    input int      InpBreakoutLineMinutes = 240;     // Breakout-line lifetime in minutes (0 = permanent)
    
    //+------------------------------------------------------------------+
    //|  Replace the old CheckBreakout() with this version               |
    //+------------------------------------------------------------------+
    void CheckBreakout()
    {
       // we look at the bar that just finished (index 1)
       double close = iClose(_Symbol, PERIOD_M5, 1);
       double high  = iHigh (_Symbol, PERIOD_M5, 1);
       double low   = iLow  (_Symbol, PERIOD_M5, 1);
       datetime barTime = iTime(_Symbol, PERIOD_M5, 1);
    
       // Bullish breakout: candle closes above the range high
       if (!highBroken && close > currentHigh)
       {
          highBroken = true;
          DrawBreakoutLine(true, high, barTime, "");   // line at the TOP wick
       }
    
       // Bearish breakout: candle closes below the range low
       if (!lowBroken && close < currentLow)
       {
          lowBroken = true;
          DrawBreakoutLine(false, low, barTime, "");   // line at the BOTTOM wick
       }
    }
    
    //+------------------------------------------------------------------+
    //|  Replace the old DrawBreakoutLine() with this version            |
    //+------------------------------------------------------------------+
    void DrawBreakoutLine(bool isBullish, double price, datetime barTime, string datePrefix)
    {
       string lineName = datePrefix;
       if (datePrefix == "")
       {
          lineName = isBullish ? BULLISH_BREAKOUT_LINE : BEARISH_BREAKOUT_LINE;
       }
       else
       {
          lineName += (isBullish ? "_BullBreak" : "_BearBreak");
       }
    
       color lineColor = isBullish ? InpBullishLineColor : InpBearishLineColor;
    
       // If the line already exists, just move it
       if (ObjectFind(ChartID(), lineName) >= 0)
       {
          ObjectSetDouble(ChartID(), lineName, OBJPROP_PRICE, 0, price);
          ObjectSetInteger(ChartID(), lineName, OBJPROP_TIME, 0, barTime);
    
          if (InpBreakoutLineMinutes > 0)
             ObjectSetInteger(ChartID(), lineName, OBJPROP_TIME, 1,
                              barTime + InpBreakoutLineMinutes * 60);
    
          string labelName = lineName + "_Label";
          if (ObjectFind(ChartID(), labelName) >= 0)
          {
             ObjectMove(ChartID(), labelName, 0, barTime, price);
             ObjectSetString(ChartID(), labelName, OBJPROP_TEXT,
                             TimeToString(barTime, TIME_MINUTES));
          }
          ChartRedraw();
          return;
       }
    
       // Create the horizontal ray/segment
       datetime time2 = InpBreakoutLineMinutes > 0
                        ? barTime + InpBreakoutLineMinutes * 60
                        : 0;                       // 0 = ray to the right (permanent)
    
       if (ObjectCreate(ChartID(), lineName, OBJ_TREND, 0,
                        barTime, price,            // start
                        time2,  price))            // end (ray if time2==0)
       {
          ObjectSetInteger(ChartID(), lineName, OBJPROP_COLOR, lineColor);
          ObjectSetInteger(ChartID(), lineName, OBJPROP_STYLE, InpLineStyle);
          ObjectSetInteger(ChartID(), lineName, OBJPROP_WIDTH, InpLineWidth);
          ObjectSetInteger(ChartID(), lineName, OBJPROP_RAY, time2 == 0);
          ObjectSetInteger(ChartID(), lineName, OBJPROP_BACK, true);
    
          // Time-stamp label
          string labelName = lineName + "_Label";
          if (ObjectCreate(ChartID(), labelName, OBJ_TEXT, 0, barTime, price))
          {
             ObjectSetString(ChartID(), labelName, OBJPROP_TEXT,
                             TimeToString(barTime, TIME_MINUTES));
             ObjectSetInteger(ChartID(), labelName, OBJPROP_COLOR, lineColor);
             ObjectSetInteger(ChartID(), labelName, OBJPROP_ANCHOR, ANCHOR_LEFT_UPPER);
             ObjectSetInteger(ChartID(), labelName, OBJPROP_BACK, true);
          }
       }
    
       ChartRedraw();
    }
    

    What changed?

    • CheckBreakout() now passes the wick price (high for bullish, low for bearish) instead of the close.
    • DrawBreakoutLine() now uses OBJ_TREND instead of OBJ_HLINE so we can give it a finite length controlled by InpBreakoutLineMinutes.
    • If InpBreakoutLineMinutes is set to 0, the line behaves as a permanent ray (same as before).

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.