modify SL of open buy order based on price action

 

Hi,

i am having problems coding this simple sentence where we look back X number of candles and take the lowest value. Than take this lowest value and use it as SL in an open buy order.

im thining of using this line to find the value Low[iLowest(NULL,0,MODE_LOW,10,1)]. It starts by looking at previous candle and checks back to 10th candle. Than saves lowest value of them. After this i have no idea what is the most simple way of modifying the SL with that value.

Thanks for help