Conditional line in graph

 

I hope someone can help me. What I try to achieve is a conditional line in a graph i.e. for the Stochastics indicator I only want the base line and the signal line to be drawn when they are rising or if the are above 30. How can I do this?

Do I need to add an if statement in this part of the code:

//---- last counted bar will be recounted

if(counted_bars>0) counted_bars--;
int limit=Bars-counted_bars;
//---- signal line is simple movimg average
for(i=0; i<limit; i++)
SignalBuffer[i]=iMAOnArray(MainBuffer,Bars,DPeriod,0,MODE_SMA,i);
//----

Reason: