Please help code below strategy in tradescript language

Values

  • ATR = Average True Range value counting with Nbr_Periods as period.
  • ATR Range = Multiplier * ATR.
  • Medium Price = (High + Low)/2.
  • Main Trend Line in Up Trend (Show in Color Lime) = Medium Price - ATR Range.
    Tricky Part: And the value will keep the same as the previous one if the current value from the formula is less than the previous one, but it will rise up if the value is larger.
  • Main Trend Line in Down Trend = Medium Price + ATR Range.
  • Main Trend Line

Conditions

  • Up Trend: Current close price is larger than the "Main Trend Line in Up Trend"
  • Down Trend: Current close price is less than the "Main Trend Line in Down Trend"

Have you got this logic from some afl based code?

In tradescript, the multiplier for ATR can be a constant. Please specify the multiplier

Your  Values are not Clear  

According to me The related syntax for the above strategy is   
 

for buy

TREND(CLOSE, 30)>((HIGH + LOW)/2+TR()) = UP

for sell

TREND(CLOSE, 30)>((HIGH + LOW)/2-TR()) = DOWN



..

Yes this is supertrend afl code logic, when i emailed zerodha team they asked me logic so i gave it here. now why tradescript has fixed multiplier and AFL does not just a question ?
is there any solution around to conver my above code exactly into a real super trend this will help lot of people.