How to open a trade once a candlestick has closed above a Hline or a object?

 

So technically i want to open a trade once a candlestick has closed above the Hline or aleast find a hline that is near the closed and open a trade base on if its above or below.

How would i write this in code?

 

So technically, in your new bar code, you get the price of the object(s), compare that to the last candle close price, and open an order if it closed above.

Show us your attempt (using the CODE button) and state the nature of your difficulty.
          No free help (2017)

 
William Roeder #:

So technically, in your new bar code, you get the price of the object(s), compare that to the last candle close price, and open an order if it closed above.

Show us your attempt (using the CODE button) and state the nature of your difficulty.
          No free help (2017)

//As far as i got for a sketch this is it

string name;
   double price;

   for(int i =ObjectsTotal(0,0,OBJ_HLINE)-1; i>=0; i--)
     {

      name  = ObjectName(0,i);
      price = ObjectGetDouble(0,name,OBJPROP_PRICE1);

      if(iClose(NULL,PERIOD_CURRENT,0)< price){
         Alert("SELL");
      }else{
        
        Alert("Buy");   

        }

     }
Reason: