Algomojo V1.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © algomojo

//@version=5
library(title="Algomojo", overlay=true)



export algomodule(string br_code="ab",string api_key="",string api_secret="",string strg_name="Tradingview",string Tsym="RELIANCE",string exch="NSE",int qty=1,string prctyp = "MKT", string Pcode = "MIS") =>
    s_prdt_ali = "BO:BO||CNC:CNC||CO:CO||MIS:MIS||NRML:NRML"
    discqty = "0"
    MktPro ="NA"
    Price = "0"
    TrigPrice = "0"
    AMO = "NO"
    Ret = "DAY"
    //Block 2 : Autotrading API data configuration
    if(br_code=="ab" or br_code=="tj" or br_code=="zb")
        //BE - Buy Entry (1x qty), SX - Short Exit (1x qty), BSR - Buy Stop and Reverse (2x qty)
        BE = "{   \"api_key\":\""+api_key+"\", \"api_secret\":\""+api_secret+"\",     \"data\":       {   \"strg_name\":\""+strg_name+"\",         \"s_prdt_ali\":\"BO:BO||CNC:CNC||CO:CO||MIS:MIS||NRML:NRML\",         \"Tsym\":\""+Tsym+"\",         \"exch\":\""+exch+"\",         \"Ttranstype\":\"B\",         \"Ret\":\"DAY\",         \"prctyp\":\""+prctyp+"\",     \"qty\":\""+str.tostring(qty)+"\",       \"discqty\":\"0\",         \"MktPro\":\"NA\",         \"Price\":\"0\",         \"TrigPrice\":\"0\",          \"Pcode\":\""+Pcode+"\",            \"AMO\":\"NO\"       } }"
        SX = "{   \"api_key\":\""+api_key+"\", \"api_secret\":\""+api_secret+"\",     \"data\":       {   \"strg_name\":\""+strg_name+"\",         \"s_prdt_ali\":\"BO:BO||CNC:CNC||CO:CO||MIS:MIS||NRML:NRML\",         \"Tsym\":\""+Tsym+"\",         \"exch\":\""+exch+"\",         \"Ttranstype\":\"B\",         \"Ret\":\"DAY\",         \"prctyp\":\""+prctyp+"\",     \"qty\":\""+str.tostring(qty)+"\",       \"discqty\":\"0\",         \"MktPro\":\"NA\",         \"Price\":\"0\",         \"TrigPrice\":\"0\",         \"Pcode\":\""+Pcode+"\",         \"AMO\":\"NO\"       } }"
        BSR = "{   \"api_key\":\""+api_key+"\", \"api_secret\":\""+api_secret+"\",     \"data\":       {   \"strg_name\":\""+strg_name+"\",         \"s_prdt_ali\":\"BO:BO||CNC:CNC||CO:CO||MIS:MIS||NRML:NRML\",         \"Tsym\":\""+Tsym+"\",         \"exch\":\""+exch+"\",         \"Ttranstype\":\"B\",         \"Ret\":\"DAY\",         \"prctyp\":\""+prctyp+"\",      \"qty\":\""+str.tostring(qty*2)+"\",       \"discqty\":\"0\",         \"MktPro\":\"NA\",         \"Price\":\"0\",         \"TrigPrice\":\"0\",       \"Pcode\":\""+Pcode+"\",        \"AMO\":\"NO\"       } }" 
        //SE - Short Entry (1x qty), Buy Exit - Short Exit (1x qty), SXR - Short Stop and Reveverse (2x qty)
        SE = "{   \"api_key\":\""+api_key+"\", \"api_secret\":\""+api_secret+"\",     \"data\":       {   \"strg_name\":\""+strg_name+"\",         \"s_prdt_ali\":\"BO:BO||CNC:CNC||CO:CO||MIS:MIS||NRML:NRML\",         \"Tsym\":\""+Tsym+"\",         \"exch\":\""+exch+"\",         \"Ttranstype\":\"S\",         \"Ret\":\"DAY\",         \"prctyp\":\""+prctyp+"\",      \"qty\":\""+str.tostring(qty)+"\",       \"discqty\":\"0\",         \"MktPro\":\"NA\",         \"Price\":\"0\",         \"TrigPrice\":\"0\",         \"Pcode\":\""+Pcode+"\",         \"AMO\":\"NO\"       } }"
        BX = "{   \"api_key\":\""+api_key+"\", \"api_secret\":\""+api_secret+"\",     \"data\":       {   \"strg_name\":\""+strg_name+"\",         \"s_prdt_ali\":\"BO:BO||CNC:CNC||CO:CO||MIS:MIS||NRML:NRML\",         \"Tsym\":\""+Tsym+"\",         \"exch\":\""+exch+"\",         \"Ttranstype\":\"S\",         \"Ret\":\"DAY\",         \"prctyp\":\""+prctyp+"\",      \"qty\":\""+str.tostring(qty)+"\",       \"discqty\":\"0\",         \"MktPro\":\"NA\",         \"Price\":\"0\",         \"TrigPrice\":\"0\",         \"Pcode\":\""+Pcode+"\",       \"AMO\":\"NO\"       } }"
        SSR = "{   \"api_key\":\""+api_key+"\", \"api_secret\":\""+api_secret+"\",     \"data\":       {   \"strg_name\":\""+strg_name+"\",         \"s_prdt_ali\":\"BO:BO||CNC:CNC||CO:CO||MIS:MIS||NRML:NRML\",         \"Tsym\":\""+Tsym+"\",         \"exch\":\""+exch+"\",         \"Ttranstype\":\"S\",         \"Ret\":\"DAY\",         \"prctyp\":\""+prctyp+"\",      \"qty\":\""+str.tostring(qty*2)+"\",       \"discqty\":\"0\",         \"MktPro\":\"NA\",         \"Price\":\"0\",         \"TrigPrice\":\"0\",       \"Pcode\":\""+Pcode+"\",         \"AMO\":\"NO\"       } }" 
        [BE,SX,BSR,SE,BX,SSR]



