Horizontal line in the highest price

 

Hi,

I'm trying to plot horizontal line in the highest price in daily time frame, the line will consist of two things " highest price + Spread"

The line it is drawn nicely, but i'm unable to add spread to it.

Alse I would like to have the line "name" above the line (ex: DLine) "This is not necessarily", But it you can...


any help will be highly appreciated


//+------------------------------------------------------------------+
//|                                               Daily_High_Low.mq4 |
//|                                                 Copyright 2015,  |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2015, "
#property link      "https://www.mql5.com"
#property strict
#property indicator_chart_window


extern color LineColor_D1   = C'92,92,92';

extern bool  Daily            = true;
extern int   Dstyle           = 4;
extern int   DWidth           =1;


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- 
   
//---
   return(INIT_SUCCEEDED);
  }
  
  
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {

   double SPREAD = MarketInfo (Symbol(), MODE_SPREAD);

      double CLOSE = iClose(NULL,0,0);
      double bsl = High[0] + (Ask - Bid);
      double ssl = Low[0] - (Ask - Bid);
      
      double sslline = DoubleToStr((ssl - CLOSE)/Point,5);
      double bslline = DoubleToStr((bsl - CLOSE)/Point,5);
      
      double SPRD = (Ask - Bid)/Point;

      SPREAD = (DoubleToStr(SPRD,Digits-5));


//////////////////////////////////////////////////////////////////////////////////////////////////|

            double PriceHigh=iHigh(Symbol(),PERIOD_D1,0);

            if(Daily)
            {
               ObjectCreate("highLineD1",OBJ_HLINE,0,0,PriceHigh);
               
               ObjectCreate ("highLineD1", OBJ_LABEL, OBJ_PERIOD_D1, Time[0], OBJ_PERIOD_D1);
               ObjectSetText("highLineD1","Test", 14, "Arial", clrWhite);

               ObjectSet("highLineD1",OBJPROP_COLOR,LineColor_D1);
               ObjectSet("highLineD1",OBJPROP_WIDTH,DWidth);
               ObjectSet("highLineD1",OBJPROP_STYLE,Dstyle);
               ObjectSet("highLineD1", OBJPROP_XDISTANCE, 0 + 2);
               ObjectSet("highLineD1", OBJPROP_YDISTANCE, -0+ 2);
               ObjectSetText("highLineD1","UpTest", 8, "Arial", clrWhite);

            }

            double PriceLow =iLow(Symbol(),PERIOD_D1,0);
            if(Daily)
            {
               ObjectCreate("lowLineD1",OBJ_HLINE,0,0,PriceLow);
               ObjectSet("lowLineD1",OBJPROP_COLOR,LineColor_D1);
               ObjectSet("lowLineD1",OBJPROP_WIDTH,DWidth);
               ObjectSet("lowLineD1",OBJPROP_STYLE,Dstyle);
               ObjectSetText("lowLineD1","DnTest",10,"Times New Roman",clrWhite);

            }
//*****************************************************************************************
   return(0);
  }

int deinit()
  {

   ObjectDelete("highLineD1");
   ObjectDelete("lowLineD1");
   return(0);
  }
 
FxTrader_: y, but i'm unable to add spread to it.
Why can't you? Where do you add it?
 

Hi WHRoeder


Sorry for that, I would like to add it to the high and plot the line (High + spread),


Thank you for your response.


 
ObjectCreate("highLineD1",OBJ_HLINE,0,0,PriceHigh+Ask-Bid);

you will need to reset the price level as the price changes

ObjectCreate ("highLineD1", OBJ_LABEL, OBJ_PERIOD_D1, Time[0], OBJ_PERIOD_D1);

 You cannot create a label with the same name as the line. None of the highlighted parameters are correct

Reason: