Setting the OBJPROP_TIMEFRAMES of a label unselects a random line in the chart

 

Hello,

I know it sounds strange but after a lot of time stuck with this problem I'm starting to get a little crazy. The thing is I am trying to do an EA to make size positions. Right now, I am in the step of creating the different HLines of the order before creating it. This is done in an indicator because I thought it would be better to let the EA only do price calculations, correct me if it is a bad idea. The thing is that I have a button that let me change to market entry. Once I press that, or start with it by default, I set the OBJPROP_TIMEFRAMES of the Entry horizontal line to NO_PERIODS and its label too. Here is where the problem comes. After some debugging I've found that after setting the label visible periods it unselects the SL horizontal line. It is sure after that cause I have done ChartRedraw() everytime i did one instruction and is always after that line that it happens. I've found another way that is setting the text to " " so it doesn't appear but I would like to know what could be happening in my code because it could cause other bugs in the future. Here is the code:

void ChangeEntryLevelVisibility(long chartIdentifier){
         if(isMarketEntry){
            ObjectSetInteger(chartIdentifier, orderLevels[0].tempVisualOrderLevelID, OBJPROP_TIMEFRAMES, OBJ_NO_PERIODS);
               ChartRedraw(chartIdentifier);

////After the next instruction is when the line is unselected/////////////////
            ObjectSetInteger(chartIdentifier, orderLevels[0].GetTextID(true), OBJPROP_TIMEFRAMES, OBJ_NO_PERIODS);
               ChartRedraw(chartIdentifier);
               ObjectMove(chartIdentifier, "MarketEntry_"+visualOrderID, 0, 0, GetMarketEntryPrice());
            ObjectSetInteger(chartIdentifier, "MarketEntry_"+visualOrderID, OBJPROP_TIMEFRAMES, OBJ_ALL_PERIODS);
               ChartRedraw(chartIdentifier);
            EventChartCustom(chartIdentifier, 2, IsABuyOrder(), 0, "MarketEntry_"+visualOrderID);
         }
         else{
            ObjectSetInteger(chartIdentifier, orderLevels[0].tempVisualOrderLevelID, OBJPROP_TIMEFRAMES, OBJ_ALL_PERIODS);
            ObjectSetInteger(chartIdentifier, orderLevels[0].tempVisualOrderLevelID, OBJPROP_SELECTED, true);
            ObjectSetInteger(chartIdentifier, orderLevels[0].GetTextID(true), OBJPROP_TIMEFRAMES, OBJ_ALL_PERIODS);
            ObjectSetInteger(chartIdentifier, "MarketEntry_"+visualOrderID, OBJPROP_TIMEFRAMES, OBJ_NO_PERIODS);
            EventChartCustom(chartIdentifier, 2, IsABuyOrder(), 0, "");
         }
      }

orderLevels[0] is where the information of the entry level is saved. GetTextID only returns a string with the label object id.
Any idea of why it could be happening?

Documentation on MQL5: Constants, Enumerations and Structures / Objects Constants / Object Types
Documentation on MQL5: Constants, Enumerations and Structures / Objects Constants / Object Types
  • www.mql5.com
When a graphical object is created using the ObjectCreate() function, it's necessary to specify the type of object being created, which can be one...