Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1291

 
Alexey Viktorov:

Straightforward to add to the condition.

Or == 0, more likely. Or better to use search for object by name, if there is no such object, then create one. And it doesn't matter if the button is clicked or not.

I did, but
OBJPROP_STATE

It still changes when the button is clicked.

So far, I've solved it this way

   if(ObjectGet("OrderBuy: "+Symbol(),OBJPROP_PRICE1)!=0)
      {
      Sleep(1);
      name="Button 3";
      ObjectSetInteger(0,name,OBJPROP_STATE,true);
      return;
      }
 
Николай Никитюк:

Hello. 2020.10.28_05:19:00 GMT+3. I translated the LeManTrend_Indicator.mq5 indicator into the fourth version .mq4 .

Have you built the indicator ? I built it, it seems to be the same - I just need to download this indicatorhttps://www.mql5.com/ru/code/9096

BrainTrend1Sig LeManTrend

LeManTrend
LeManTrend
  • www.mql5.com
Индикатор определяет положение тренда на основе текущей цены и максимальных и минимальных цен за три периода.
 
MakarFX:
I did, but

still changes when pressed

So far I've solved it this way.

What is the general problem?

 
Alexey Viktorov:

What is the general task?

When you click on the button, the object is created and the button receives
ObjectSetInteger(0,"Button 3",OBJPROP_STATE,true);

If there is an object, you press the button and it gets

OBJPROP_STATE,false

and you need to keep it true as long as there is an object on the chart

 
MakarFX:
When the button is clicked the object is created and the button receives

if there is an object, you press the button and it gets

and keep it true as long as there's an object on the chart.

Then just return the property back before drawing

   //--- обработка кнопки Создать трендовую линию Buy
   if(sparam=="Button 3")
      {

   if(ObjectGet("OrderBuy: "+Symbol(),OBJPROP_PRICE1)!=0)// Это лучше заменить на if(ObjectFind(ChartID(), "OrderBuy: "+Symbol()) >= 0);
     ObjectSetInteger(0,"Button 3",OBJPROP_STATE,true);
      if(trigger_greateB==true)
         {
         Sleep(100);//А это зачем???
         trigger_greateB=false;
         ObjectSetInteger(0,"Button 3",OBJPROP_STATE,true);
         //--- Определяем координаты
         ChartXYToTimePrice(0,xn,yn+20,window,dt_1,price_1);
         ChartXYToTimePrice(0,xn+100,yn-20,window,dt_2,price_2);
         //--- Создаем трендовую линию Buy
         TrendCreate(0,("OrderBuy: "+Symbol()),0,dt_1,price_1,dt_2,price_2,ColorUP,0,1,false,true,false,false,0);
         return;
         }
      }
 
I do ... you can see in the code
 
MakarFX:
and I do... you can see in the code

Not everything. I highlighted in my example

   if(ObjectGet("OrderBuy: "+Symbol(),OBJPROP_PRICE1)!=0)// Это лучше заменить на if(ObjectFind(ChartID(), "OrderBuy: "+Symbol()) >= 0);
     ObjectSetInteger(0,"Button 3",OBJPROP_STATE,true);
This prevents the button from sticking when pressed if there is a line on the chart.
 
Alexey Viktorov:

Not everything. I highlighted in my example

This prevents the button from sticking when pressed, if there is a line on the chart.

The problem is neither... I just need it to stick, but OBJ_BUTTON itself is clickable, even if it doesn't do anything.

I need to make the button inactive, and it, as I understand it is not possible(

 
MakarFX:

That's not the problem... I just need it to stick, but OBJ_BUTTON itself is clickable, even if it doesn't do anything.

I need to make the button inactive, and this, as I understand it is not possible(

What do you mean by "inactive" or "not clickable"? And what's the point of it?

If you want the button to have the appearance of being clicked, then instead of true on that line, put false and delete the line

         ObjectSetInteger(0,"Button 3",OBJPROP_STATE,true);

which before creating the line...

 
Alexey Viktorov:

What do you mean by "not active" or "not clickable"? And what's the point of that?

If you want the button to have the appearance of being clicked, then instead of true on that line, put false and delete the line

which is before the line is created...

OBJPROP_STATE,true

this is the button's pressed look...

don't bother...it's not relevant anymore.

Thank you.

Reason: