how to create a line that follows a value

 

Hi, I would like to create in the indicator a line that follows a calculated volume and that changes color (red when sell and green when buy). I tried with OBJ_TREND but I get a straight line (probably combining only two values)


   
   //primo punto
   datetime t1=Time[0];
   double p1=Point*100+Open[0];
//secondo punto
   datetime t2=Time[5000];
   double p2=Point*100+Open[1];
//--- creazione prima parte trendline
   if(!ObjectCreate(obj_name,OBJ_TREND,0,t1,p1,t2,p2))
     {
      Print("errore creazione trendline! codice #",GetLastError());
      return(0);
     }
//--- colore rosso
   ObjectSetInteger(current_chart_id,obj_name,OBJPROP_COLOR,clrRed);

   for(int i=1; i<100000; i++)
     {     
      t2=Time[i];
      p2=Close[i];
      //--- move the 2nd anchor point of the trend line
      ObjectMove(obj_name,1,t2,p2);
      //--- forced chart redraw
      ChartRedraw(current_chart_id);
      Sleep(100);
     }
//--- sleep to see the object
   Sleep(3000);
//--- delete object
   ObjectDelete(obj_name);
   return(0);
   
   
  }




After draw line problem is solved I need If price is up or down to iMA(Symbol(),0,10,0,MODE_EMA,PRICE_CLOSE,i) the line has green or red color. Thank you

Reason: