Help with OBJ_TEXT - How to reuse without getting stuck in a OBJECTDELETE loop.

 
I seemed to have coded myself in a corner. 

            ObjectSet("B23",OBJPROP_TIME1,ctime);
            ObjectSet("B23",OBJPROP_PRICE1,C);
This OBJ_TEXT will mark a fractal either low or high as my condition instructs it to do. 

If I delete the object when my condition becomes false then I'm stuck with a false condition and deleted object all the time. 

I can not seem to understand how to use OBJ_TEXT properly. 

This brings me to wondering about all objects such at trend lines, etc. How to remove them once used and condition no longer is true ? 
WHILE still being able to call them back up again for the next condition ? 

I wish I didn't have to ask this but I have not figured out a solution. 

Thanks




 
Agent86:
I seemed to have coded myself in a corner. 

This OBJ_TEXT will mark a fractal either low or high as my condition instructs it to do. 

If I delete the object when my condition becomes false then I'm stuck with a false condition and deleted object all the time. 

I can not seem to understand how to use OBJ_TEXT properly. 

This brings me to wondering about all objects such at trend lines, etc. How to remove them once used and condition no longer is true ? 
WHILE still being able to call them back up again for the next condition ? 

I wish I didn't have to ask this but I have not figured out a solution. 

Thanks




One way is to use a unique id (int) . It only increments and the objects are unique . 
Your code shifts locations of objects and they have a different count ? 
For instance , if you remove fractal 23 , the chart has how many fractals in front of it ? (>23 that you would need to "rename" essentially)

Edit : If you are asking about show/hide the you can use 

//this is for hiding it 
ObjectSetInteger(ChartID(),name,OBJPROP_TIMEFRAMES,OBJ_NO_PERIODS);
//this is for showing it 
ObjectSetInteger(ChartID(),name,OBJPROP_TIMEFRAMES,OBJ_ALL_PERIODS);
 
Agent86:
I seemed to have coded myself in a corner. 

This OBJ_TEXT will mark a fractal either low or high as my condition instructs it to do. 

If I delete the object when my condition becomes false then I'm stuck with a false condition and deleted object all the time. 

I can not seem to understand how to use OBJ_TEXT properly. 

This brings me to wondering about all objects such at trend lines, etc. How to remove them once used and condition no longer is true ? 
WHILE still being able to call them back up again for the next condition ? 

I wish I didn't have to ask this but I have not figured out a solution. 

Thanks




ObjectDelete(0,name) // Just delete it, if condition is still true it will created

// CheckCondition

// Create object
 
Navdeep Singh #:
ObjectDelete(0,name) // Just delete it, if condition is still true it will created

// CheckCondition

// Create object

I don't completely understand this. Every attempt to ObjectDelete() conflicts with another function that needs to use that object or create it again. It loops in ObjectDelete(). 


Thanks

 

If I delete the object when my condition becomes false then I'm stuck with a false condition and deleted object all the time. 

I can not seem to understand how to use OBJ_TEXT properly. 

This brings me to wondering about all objects such at trend lines, etc. How to remove them once used and condition no longer is true ? 
WHILE still being able to call them back up again for the next condition ? 

I wish I didn't have to ask this but I have not figured out a solution. 

Thanks




Hi:)

Well to me you focus on a completely different field than you should have.

You should focus on "flags" -  true or false  and not on the object issues.

bool my_condition=true;

void OnTick()
 {
       if(my_condition==true)
        {
          ObjectCreate(0,"B23",OBJ_TEXT,0,0,0);
          ObjectSetString(0,"B23",OBJPROP_TEXT,"HELLO");
          ObjectSetDouble(0,"B23",OBJPROP_PRICE1,Bid);
          ObjectSetInteger(0,"B23",OBJPROP_TIME1,TimeCurrent());
        } 
       
        if(my_condition==false)
          ObjectDelete(0,"B23"); 
        
        //you need to set your condition to be able to recreate the object  
        if(Bid>=1.12345)
           my_condition=true;
        else
           my_condition=false;      
  }

During the life of a programe, Bid will be higher or lower than the price so this will lock or unlock your condition. If you set your condition to false and do not let it become true again, in this case you will never be able to create the object again.

Cheers

 
Agent86 #:

I don't completely understand this. Every attempt to ObjectDelete() conflicts with another function that needs to use that object or create it again. It loops in ObjectDelete(). 


Thanks

Need to see the more code to fully understand and help you

 
Piotr Latoszynski #:

Hi:)

Well to me you focus on a completely different field than you should have.

You should focus on "flags" -  true or false  and not on the object issues.

During the life of a programe, Bid will be higher or lower than the price so this will lock or unlock your condition. If you set your condition to false and do not let it become true again, in this case you will never be able to create the object again.

Cheers

I see. 

This is exactly the problem I have where condition gets locked to false condition once my condition is true and I need to unlock or change method somehow. 

bool A_high()
   {
      { 
      if(!histo())
         {
         //ObjectDelete("B16");
         val1=0;
         for (int i=histodowncount; val1==0; i++)
            {
            val1=iFractals(NULL, 0, MODE_UPPER, i);
            A = val1;
            atime=Time[i];
            }
            if(A!=0)
               {
               
               //atime=Time[i];
               
               //Print(atime);
               //ObjectSet("B6",OBJPROP_BGCOLOR,clrRed);
               ObjectSet("B16",OBJPROP_TIME1,atime);
               ObjectSet("B16",OBJPROP_PRICE1,A);
               ObjectSet("B16",OBJPROP_ANCHOR,ANCHOR_LOWER);
               ObjectSetString(0,"B16",OBJPROP_TOOLTIP,"A High = "+DoubleToStr(A,4));
               //A_close=Close[i];
               //Print(A, " A high Located at bar ",i," atime = ",atime);
               //Print("A close = ",A_close);
               
               return(true);
               }
             }
      //else ObjectDelete("B16");
        }
    return(false);                 
   }

As you can see my code does exactly as you described. Stuck on false. 
This give me some ideas to work on sort of a toggle switch. 

        //you need to set your condition to be able to recreate the object  
        if(Bid>=1.12345)
           my_condition==true;
        else
           my_condition==false;   

What happens when Bid<1.12345 ?
Bid>=1.12345

Doesn't this make it always false again when Bid goes below 1.12345 ?  
 


 
Navdeep Singh #:

Need to see the more code to fully understand and help you


bool A_high()
   {
      { 
      if(!histo())
         {
         //ObjectDelete("B16");
         val1=0;
         for (int i=histodowncount; val1==0; i++)
            {
            val1=iFractals(NULL, 0, MODE_UPPER, i);
            A = val1;
            atime=Time[i];
            }
            if(A!=0)
               {
               
               //atime=Time[i];
               
               //Print(atime);
               //ObjectSet("B6",OBJPROP_BGCOLOR,clrRed);
               ObjectSet("B16",OBJPROP_TIME1,atime);
               ObjectSet("B16",OBJPROP_PRICE1,A);
               ObjectSet("B16",OBJPROP_ANCHOR,ANCHOR_LOWER);
               ObjectSetString(0,"B16",OBJPROP_TOOLTIP,"A High = "+DoubleToStr(A,4));
               //A_close=Close[i];
               //Print(A, " A high Located at bar ",i," atime = ",atime);
               //Print("A close = ",A_close);
               
               return(true);
               }
             }
      //else ObjectDelete("B16");
        }
    return(false);                 
   }
This is one function that marks A high fractal just before MACD crosses. 

Once this condition is false I want to mark A_low fractal just before MACD crosses instead. 

Both use "B16" object and it seems any deletes when either are false makes it false all the time. 
Files:
 
Lorentzos Roussos #:

One way is to use a unique id (int) . It only increments and the objects are unique . 
Your code shifts locations of objects and they have a different count ? 
For instance , if you remove fractal 23 , the chart has how many fractals in front of it ? (>23 that you would need to "rename" essentially)

Edit : If you are asking about show/hide the you can use 

I need to review this a bit to understand it but........

Do I have this idea correct ?
I would create new object with new incrementing unique id every time condition is true then delete when false ? 

Thanks

 
Agent86 #:

I need to review this a bit to understand it but it sounds like I could use that to create new objects for each condition that becomes true. Then just delete them when false and forget about them once deleted. 

This way there would be no conflict in constantly deleting the old object and trying to bring it back. Just create objects each time with new (id) right ?
Do I have this idea correct ? 

Thanks

I seem to be a bit off topic in what you need to do . I apologize

You want to have a fractal or a "point of interest (time,price)" which has a persistent binary nature and it has to be considered at times , and ignored at other times ,but you don't want to "come back and recapture it" so as to maintain high performance so you would also prefer not deleting it ? 

 
Lorentzos Roussos #:

I seem to be a bit off topic in what you need to do . I apologize

You want to have a fractal or a "point of interest (time,price)" which has a persistent binary nature and it has to be considered at times , and ignored at other times ,but you don't want to "come back and recapture it" so as to maintain high performance so you would also prefer not deleting it ? 

Yes I think I would prefer NOT to delete if performance is effected. 

So the EA looks like this on charts and mostly works, but Text objects tend to linger sometimes. 
So I want to hide or delete as needed without getting stuck in this loops of always false somehow. 

Here is what the program looks like when running. 

Myalert_EA

Reason: