Convert Indicator in Pinescript code to Tradescript and apply to Pi

I have a Pinescript code for an indicator.

I need help to -

  1. Convert it to Tradescript

​2. Apply it to Pi

Hi JD,

We at Zerodha will not be able to help you convert the Pine script to Trade script, but if you have a logic we could code that and give you the same, you could try and Apply on Pi. 

On Pi not all functions are supported right now that is why we have a Pi bridge for Amibroker. 

http://zerodha.com/z-connect/tradezerodha/pi-bridge/pi-bridge-for-amibroker

Hi Bakshy.

I have a pine script logic its simple. But since there are restriction in Trade script i feel difficult to use it on Pi. Could you help me in converting the same.

This is a trend indicator which uses ATR to plot Support/Resistance levels similar as in case of PSAR.
During uptrend support level is plotted below the candles/bars and vice-versa.
The opposite level is plotted when close of candle breaches the S/R level.
In Excel the value of Trend (T) can be obtained using below formula.
Values of “Multiplier” and “Period” are user-defined, the default being 4 & 10 respectively.
Formula:
Upper Band Basic (A) =((High+Low)/2)+(Muliplier x ATR(Period))
Lower Band Basic (B) =((High+Low)/2)-(Multiplier x ATR(Period)
Upper Band Modified (UB) =IF(OR(A<PreviousUB,PreviousClose>PreviousUB),A,PreviousUB)
Lower Band Modified (LB) =IF(OR(B>PreviousLB,PreviousClose<PreviousLB),B,PreviousLB)
Trend (T) =IF(AND(PreviousT=PreviousUB,Close<=UB),UB,IF(AND(PreviousT=PreviousUB,Close>=UB),LB,IF(AND(PreviousT=PreviousLB,Close>=LB),LB,IF(AND(PreviousT=PreviousLB,Close<=LB),UB,””))))