A test EA generated by Expert Advisor Studio (2nd pattern)

This EA is generated by Expert Advisor Studio. It is based on the second pattern: Indicator vs Constant Number.

A test EA generated by Expert Advisor Studio (2nd pattern)

registerEA(
   "sample_using_rsi",
   "A test EA based on rsi",
   [{ // parameters
       name: "period",
       value: 14,
       required: true,
       type: PARAMETER_TYPE.INTEGER,
       range: [1, 100]
   }, {
       name: "constant",
       value: 20,
       required: true,
       type: PARAMETER_TYPE.INTEGER,
       range: [1, 100]
   }],
   function (context) { // Init()
       var account = getAccount(context, 0)
       var brokerName = getBrokerNameOfAccount(account)
       var accountId = getAccountIdOfAccount(account)
       var symbolName = "EUR/USD"
       getQuotes(context, brokerName, accountId, symbolName)
       window.chartHandle = getChartHandle(context, brokerName, accountId, symbolName, TIME_FRAME.M1)
       var period = getEAParameter(context, "period")
       var constantNum = getEAParameter(context, "constant")
       window.indiHandle = getIndicatorHandle(context, brokerName, accountId, symbolName, TIME_FRAME.M1, "rsi",
       [{
           name: "period",
           value: period
       }])
   },
   function(context) { // Deinit()
       delete window.currTime
   },
   function(context) { // OnTick()
       var arrTime = getData(context, window.chartHandle, DATA_NAME.TIME)
       if (typeof window.currTime == "undefined") {
           window.currTime = arrTime[arrTime.length - 1]
       } else if (window.currTime != arrTime[arrTime.length - 1]) {
           window.currTime = arrTime[arrTime.length - 1]
       } else {
           return
       }
       var account = getAccount(context, 0)
       var brokerName = getAccountIdOfAccount(account)
       var accountId = getAccountIdOfAccount(account)
       var symbolName = "EUR/USD"
       var arrIndi = getData(context, window.indiHandle, "rsi")
       var period = getEAParameter(context, "period")
       var constantNum = getEAParameter(context, "constant")
       var ask = getAsk(context, brokerName, accountId, symbolName)
       var bid = getBid(context, brokerName, accountId, symbolName)
       var limitPrice = 0.0003
       var stopPrice = 0.0003
       var volume = 0.01
       if (constantNum < arrIndi[arrIndi.length - 3] && constantNum > arrIndi[arrIndi.length - 2]) {
           sendOrder(brokerName, accountId, symbolName, ORDER_TYPE.OP_BUYLIMIT, ask - limitPrice, 0, volume, ask + limitPrice, bid - 3 * stopPrice, "")
       } else if ((100 - constantNum) > arrIndi[arrIndi.length - 3] && (100 - constantNum) < arrIndi[arrIndi.length - 2]) {
           sendOrder(brokerName, accountId, symbolName, ORDER_TYPE.OP_SELLLIMIT, bid + limitPrice, 0, volume, bid - limitPrice, ask + 3 * stopPrice, "")
       }
    }
)