help with the objectset function

 

Hello,

I m trying to create an ea that will move an horizontal line on the High/Low of the previous candle according to certain condition. the compilation is OK, but the ea doesn't work.

void TechnicalAnalysissell()
{
      if (Close[current+1] <= Close[current+2]  && Volume[current+1] == Volume[iHighest(NULL,0,MODE_VOLUME,period,current+1)])
    {
    ObjectSet("BUY", OBJPROP_PRICE1,High[current+1]);
    }
}

if you can highlight the mistaken part, it would be great.

thanks

 

try this:

        if( ObjectFind("BUY") != -1 ) ObjectDelete("BUY");
        ObjectCreate("BUY", OBJ_HLINE, 0, TimeCurrent(), High[current+1]);

Then you can change how your line should look with

ObjectSet(..)

gooly

 
thanks gooly, it seems to work smoothly
 
jopopo: but the ea doesn't work.
    ObjectSet("BUY", OBJPROP_PRICE1,High[current+1]);
  1. "Doesn't work" is meaningless - just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires - meaningless. There are no mind readers here.
  2. Check your return codes and find out if it's even being called. What are Function return values ? How do I use them ? - MQL4 forum
  3. You could use Gooly's suggestion (always delete and create,) or ObjectMove (if move fails, create,) or your ObjectSet (if set fails, create.) All do the same.
  4. Current+1 sounds like EA Builder. We hate EA builder
    • EA builder makes bad code counting up while closing multiple orders.
    • EA builder makes bad code Bars is unreliable (max bars on chart) volume is unreliable (miss ticks) Always use time
    • EA builder makes bad code Not adjusting for 4/5 digit brokers
    • EA builder makes bad code not adjusting for ECN brokers.
    • EA builder makes bad code not checking return codes.
Reason: