{"id":128,"date":"2023-01-03T04:01:00","date_gmt":"2023-01-03T04:01:00","guid":{"rendered":"https:\/\/algomojo.com\/blog\/?p=128"},"modified":"2023-09-13T06:07:22","modified_gmt":"2023-09-13T06:07:22","slug":"send-option-orders-from-futures-or-spot-signals-in-amibroker-using-algomojo-platform","status":"publish","type":"post","link":"https:\/\/algomojo.com\/blog\/send-option-orders-from-futures-or-spot-signals-in-amibroker-using-algomojo-platform\/","title":{"rendered":"Send Smart Options Execution Orders from Futures or Spot Signals in Amibroker using Algomojo Platform"},"content":{"rendered":"\n<p>This tutorial provides instructions on how to utilize simple buy and sell trading signals in Spot\/Future charts to place option orders (including ATM, ITM, and OTM options) on the&nbsp;Algomojo platform. Implementing this system can help traders mitigate risk, particularly in the event of unexpected market movements that may result in significant losses. Additionally, implementing ATM or ITM option buying strategies, as opposed to futures, may help to reduce the risk of extreme black swan events and significantly mitigate the potential for large gap-up or gap-down risks when carrying forward positions.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/algomojo.com\/blog\/wp-content\/uploads\/2021\/01\/Algomojo-Option-Execution-Module.png\"><img loading=\"lazy\" width=\"1024\" height=\"555\" src=\"https:\/\/algomojo.com\/blog\/wp-content\/uploads\/2021\/01\/Algomojo-Option-Execution-Module.png\" alt=\"\" class=\"wp-image-129\"\/><\/a><\/figure>\n\n\n\n<p><strong>Features of the Options Execution Module<\/strong><\/p>\n\n\n\n<p>1)Simple Drag and Drop Module on top of any Amibroker trading strategy with proper buy,sell,short,cover defined variables.<br>2)<a href=\"https:\/\/algomojo.com\/blog\/what-is-placesmartorder-feature-in-algomojo-how-to-build-intelligent-trading-systems-using-placesmartorder\/\">Place Smart Option Orders<\/a>&nbsp;to intelligent send orders by manipulating the current existing positions.<br>3)Place Larger Option Orders by Splitting Larger Orders into multiple small orders.<br>4)Option Strike calculation at Amibroker end (Trades can configure the Underlying symbol as Spot.\/Futures) based on their trading requirement) accordingly, options strikes will be calculated.<\/p>\n\n\n\n<p><strong>Supported Brokers<\/strong><\/p>\n\n\n\n<p><a href=\"https:\/\/algomojo.com\/open-an-account\/\">All Algomojo Supported Brokers<\/a><\/p>\n\n\n\n<p><strong>Supported Amibroker Version<\/strong>: 6.0 or above<\/p>\n\n\n\n<p><strong>Amibroker Option Buying Settings for Placing Ordes in ATM Options (Long Only Options Strategy)<\/strong><\/p>\n\n\n\n<p>Trades can control the CE\/PE Offset Parameters to place orders in various option strikes. To place orders in ATM options one has to set the Offset value as \u201c0\u201d as shown below<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/i0.wp.com\/www.marketcalls.in\/wp-content\/uploads\/2023\/01\/image.png?resize=728%2C693&amp;ssl=1\" alt=\"\" class=\"wp-image-57011\"\/><figcaption>Amibroker Parameter Settings for Place Orders with ATM CE\/PE<\/figcaption><\/figure>\n\n\n\n<p><strong>Amibroker Option Buying Settings for Placing Ordes in ITM Options (Long Only Options Strategy)<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"758\" height=\"661\" src=\"https:\/\/algomojo.com\/blog\/wp-content\/uploads\/2023\/03\/image.png\" alt=\"\" class=\"wp-image-545\"\/><\/figure>\n\n\n\n<p><strong>Strategy Parameter Settings for Option Long and Exit Strategy<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>Trading Signal in Spot\/Futures<\/strong><\/td><td><strong>Orders to be Placed<\/strong><\/td><\/tr><tr><td>Buy Signal<\/td><td>Long Call<\/td><\/tr><tr><td>Sell Signal<\/td><td>Exit Long Call<\/td><\/tr><tr><td>Short Signal<\/td><td>Long Put<\/td><\/tr><tr><td>Cover Signal<\/td><td>Exit Long Put<\/td><\/tr><tr><td>Buy and Cover Signal<\/td><td>Long Call<br>Exit Long Put<\/td><\/tr><tr><td>Short and Cover Signal<\/td><td>Long Put<br>Exit Long Call<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p><strong>Strategy Parameter Settings for Option Short and Exit Strategy<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"758\" height=\"661\" src=\"https:\/\/algomojo.com\/blog\/wp-content\/uploads\/2023\/03\/image-1.png\" alt=\"\" class=\"wp-image-546\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>Trading Signal in Spot\/Futures<\/strong><\/td><td><strong>Orders to be Placed<\/strong><\/td><\/tr><tr><td>Buy Signal<\/td><td>Short Put<\/td><\/tr><tr><td>Sell Signal<\/td><td>Exit Short Put<\/td><\/tr><tr><td>Short Signal<\/td><td>Short Call<\/td><\/tr><tr><td>Cover Signal<\/td><td>Exit Short Call<\/td><\/tr><tr><td>Buy and Cover Signal<\/td><td>Short Put<br>Exit Short Call<\/td><\/tr><tr><td>Short and Cover Signal<\/td><td>Short Call<br>Exit Short Put<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p><strong>To Build this module we need 2 components<\/strong><\/p>\n\n\n\n<p>1)Trading System with Buy\/Sell\/Short\/Cover Signals<br>2)Option Execution Module that needs to be drag and dropped over the Trading System<\/p>\n\n\n\n<p>1)<strong>Building your Trading System<\/strong><\/p>\n\n\n\n<p>Apply the Trading System with your Buy\/Sell\/Short\/Cover variables on the charts.<\/p>\n\n\n\n<p><strong>Here is the sample EMA Crossover Trading System with Buy,Sell,Short,Cover variables.<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-clike\">_SECTION_BEGIN(&quot;EMA Crossover Strategy&quot;);\n\n\/\/ Param controls for EMA values\np1 = Param(&quot;EMA1&quot;, 10, 1, 200, 1);\np2 = Param(&quot;EMA2&quot;, 20, 1, 200, 1);\n\n\/\/ Param controls for EMA line colors\ncol1 = ParamColor(&quot;EMA1 Color&quot;, colorRed);\ncol2 = ParamColor(&quot;EMA2 Color&quot;, colorBlue);\n\n\/\/ Calculate EMAs\nEMA1 = EMA(C, p1);\nEMA2 = EMA(C, p2);\n\n\/\/ Plot EMAs\nPlot(EMA1, &quot;EMA1&quot;, col1, styleThick);\nPlot(EMA2, &quot;EMA2&quot;, col2, styleThick);\n\n\/\/ Set position size\nSetPositionSize(100, spsShares);\n\n\/\/ Generate buy\/sell signals\nBuy = Cross(EMA1, EMA2);\nSell = Cross(EMA2, EMA1);\n\n\/\/ Generate short\/cover signals\nShort = Sell;\nCover = Buy;\n\n\/\/Generate Signals only on close of the candle\nBuy = Ref(Buy,-1);\nSell = Ref(Sell,-1);\nShort = Ref(Short,-1);\nCover = Ref(Cover,-1);\n\n\/\/ Plot buy\/sell signals\nPlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-40);\nPlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-50);\nPlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-45);\nPlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0, H, Offset=40);\nPlotShapes(IIf(Sell, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50);\nPlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);\n\n\/\/ Plot candlestick chart\nPlot(C, &quot;Price&quot;, colorWhite, styleCandle);\n\n_SECTION_END();\n<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote\"><p>Note: Buy\/Sell\/Short\/Cover parameters are mandatory without that execution will not happen properly<\/p><\/blockquote>\n\n\n\n<p>If in case your trading system supports only Buy and Sell and you don\u2019t want to use short and cover variables, in that case, use the below-mentioned logic where initialize short and cover variables to zero.<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-markup\">Buy = your buy trading logic ;\nSell = your sell trading logic ;\n\nshort =0;\ncover =0;<\/code><\/pre>\n\n\n\n<p><strong>2)Main Option Execution Module<\/strong><\/p>\n\n\n\n<p>Copy the Main Execution Module to <strong>Amibroker\\Formulas\\Algomojo <\/strong>folder. Save the AFL under the name&nbsp;<strong>Algomojo Spot Or Future Signals to Option Orders.afl<\/strong><\/p>\n\n\n\n<p>Now Drag and Drop the Module on top of your Charting with Buy\/Sell Trading System<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-clike\">\n\/*\nAlgomojo - Smart Spot\/Futures to Options Trading Module with Split Order Controls\nCreated By : Algomojo\nCreated on : 07 MAR 2023.\nWebsite : www.algomojo.com\n*\/\n\n\n_SECTION_BEGIN(&quot;Algomojo - Broker Controls&quot;);\n\n\n\/\/ Send orders even if Amibroker is minimized or Chart is not active\nRequestTimedRefresh(1, False); \nEnableTextOutput(False);\n\n\/\/Creating Input Controls for Setting Order Related Information\n\nbroker =Paramlist(&quot;Broker&quot;,&quot;an|ab|fs|fp|fy|gc|pt|sm|tc|up|zb|ze&quot;,0);\nver = ParamStr(&quot;API Version &quot;,&quot;v1&quot;);\napikey = ParamStr(&quot;apikey&quot;,&quot;xxxxxxxxxxxxxxxxxx&quot;); \/\/Enter your API key here\napisecret = ParamStr(&quot;secretkey&quot;,&quot;xxxxxxxxxxxxxxxxxx&quot;); \/\/Enter your API secret key here\n\n_SECTION_END();\n\n\n_SECTION_BEGIN(&quot;Algomojo - Order Controls&quot;);\n\nstrategy = ParamStr(&quot;Strategy Name&quot;, &quot;Test Strategy&quot;);\n\nspot = Paramlist(&quot;Spot Symbol&quot;,&quot;NIFTY|BANKNIFTY|FINNIFTY&quot;);\nexpiry = ParamStr(&quot;Expiry Date&quot;,&quot;29MAR23&quot;);\n\nexchange = ParamList(&quot;Exchange&quot;,&quot;NFO|MCX&quot;,0); \nSymbol = ParamStr(&quot;Underlying Symbol&quot;,&quot;NIFTY-I.NFO&quot;);\niInterval= Param(&quot;Strike Interval&quot;,50,1,10000,1);\nStrikeCalculation = Paramlist(&quot;Strike Calculation&quot;,&quot;PREVOPEN|PREVCLOSE|TODAYSOPEN&quot;,0);\nLotSize = Param(&quot;Lot Size&quot;,50,1,10000,1);\n\noffsetCE = Param(&quot;CE Offset&quot;,0,-40,40,1);\noffsetPE = Param(&quot;PE Offset&quot;,0,-40,40,1);\n\npricetype = ParamList(&quot;Order Type&quot;,&quot;MARKET&quot;,0);\nproduct = ParamList(&quot;Product&quot;,&quot;MIS|NRML&quot;,1);\ntradetype = ParamList(&quot;Option Trade Type&quot;,&quot;BUY|SELL&quot;,0);\n\nquantity = Param(&quot;quanity(Lot Size)&quot;,1,0,10000)*LotSize;\nprice = 0; \ndisclosed_quantity = 0;\ntrigger_price = 0;\namo = &quot;NO&quot;;\nsplitorder = ParamList(&quot;To Split Orders&quot;,&quot;NO|YES&quot;,0);\nsplit_quantity = Param(&quot;Split Quantity&quot;,500,1,100000,1);\n\nVoiceAlert = ParamList(&quot;Voice Alert&quot;,&quot;Disable|Enable&quot;,1);\n\nEntrydelay = Param(&quot;Entry Delay&quot;,0,0,1,1);\nExitdelay = Param(&quot;Exit Delay&quot;,0,0,1,1);\nEnableAlgo = ParamList(&quot;AlgoStatus&quot;,&quot;Disable|Enable|LongOnly|ShortOnly&quot;,0);\nresp = &quot;&quot;;\n\n\n\/\/Static Variables for Order protection\n\nstatic_name_ = Name()+GetChartID()+interval(2)+strategy;\nstatic_name_algo = Name()+GetChartID()+interval(2)+strategy+&quot;algostatus&quot;;\n\n\nAlgoBuy = lastvalue(Ref(Buy,-Entrydelay));\nAlgoSell = lastvalue(Ref(Sell,-Exitdelay));\nAlgoShort = lastvalue(Ref(Short,-Entrydelay));\nAlgoCover = lastvalue(Ref(Cover,-Exitdelay));\n\n\/\/Plots Dashboard\n\nGfxSelectFont( &quot;BOOK ANTIQUA&quot;, 14, 100 );\nGfxSetBkMode( 1 );\nif (EnableAlgo != &quot;&quot;)\n{\nAlgoStatus = EnableAlgo;\nGfxSetTextColor( IIf(EnableAlgo == &quot;Enable&quot;, colorGreen, \n\t\t\t\t\tIIf(EnableAlgo == &quot;LongOnly&quot;,colorYellow,\n\t\t\t\t\t\tIIf(EnableAlgo == &quot;ShortOnly&quot;,colorOrange,colorRed)) ));\nGfxTextOut( &quot;Algostatus : &quot;+AlgoStatus , 20, 40);\nStaticVarSet(static_name_algo, IIf(EnableAlgo == &quot;Enable&quot;, 1,\nIIf(EnableAlgo == &quot;LongOnly&quot;, 2, IIf(EnableAlgo == &quot;ShortOnly&quot;, 3, 0))));\n\/\/_TRACE(&quot;Algo Status : &quot;+EnableAlgo);\n}\n\n\n\n\n\n\/\/optionCEtype = WriteIf(offsetCE == 0, &quot;ATM CE&quot;, WriteIf(offsetCE&lt;0,&quot;ITM&quot;+abs(offsetCE)+&quot; CE&quot;,&quot;OTM&quot;+abs(offsetCE)+&quot; CE&quot;));\n\/\/optionPEtype = WriteIf(offsetPE == 0, &quot;ATM PE&quot;, WriteIf(offsetPE&lt;0,&quot;ITM&quot;+abs(offsetPE)+&quot; PE&quot;,&quot;OTM&quot;+abs(offsetPE)+&quot; PE&quot;));\n\nif(StrikeCalculation==&quot;PREVOPEN&quot;)\n{\nSetForeign(Symbol);\nspotC = Ref(OPEN,-1);\nRestorePriceArrays();\n}\n\nif(StrikeCalculation==&quot;PREVCLOSE&quot;)\n{\nSetForeign(Symbol);\nspotC = Ref(Close,-1);\nRestorePriceArrays();\n}\n\nif(StrikeCalculation==&quot;TODAYSOPEN&quot;)\n{\nSetForeign(Symbol);\nspotC = TimeFrameGetPrice(&quot;O&quot;,inDaily);\nRestorePriceArrays();\n}\n\n\/\/Maintain Array to Store ATM Strikes for each and every bar\nstrike = IIf(spotC % iInterval &gt; iInterval\/2, spotC - (spotC%iInterval) + iInterval,\n\t\t\tspotC - (spotC%iInterval));\n\t\t\t\n\/\/Entry Strikes\t\n\t\t\nstrikeCE = strike + (offsetCE * iInterval);\nstrikePE = strike - (offsetPE * iInterval);\n\nbuycontinue = Flip(Buy,Sell);\nshortcontinue  = Flip(Short,Cover);\n\nentrysym = &quot;&quot;;\nexitsym = &quot;&quot;;\n\n\/\/Exit Strikes\nif(tradetype==&quot;BUY&quot;)\n{\nExitStrikeCE = ValueWhen(Ref(Buy,-Entrydelay),strikeCE); \nExitStrikePE = ValueWhen(Ref(Short,-Entrydelay),strikePE);\n\nif(broker==&quot;tc&quot; OR broker ==&quot;fs&quot;)\n{\nentrysym = WriteIf(buycontinue OR sell,spot+expiry+&quot;C&quot;+strikeCE,WriteIf(shortcontinue OR cover,spot+expiry+&quot;P&quot;+strikePE,&quot;&quot;));\nexitsym = WriteIf(buycontinue OR sell,spot+expiry+&quot;P&quot;+ExitStrikePE,WriteIf(shortcontinue OR cover,spot+expiry+&quot;C&quot;+ExitStrikeCE,&quot;&quot;));\n}\nelse\n{\nentrysym = WriteIf(buycontinue OR sell,spot+expiry+strikeCE+&quot;CE&quot;,WriteIf(shortcontinue OR cover,spot+expiry+strikePE+&quot;PE&quot;,&quot;&quot;));\nexitsym = WriteIf(buycontinue OR sell,spot+expiry+ExitStrikePE+&quot;PE&quot;,WriteIf(shortcontinue OR cover,spot+expiry+ExitStrikeCE+&quot;CE&quot;,&quot;&quot;));\n}\n\n\n}\nif(tradetype==&quot;SELL&quot;)\n{\nExitStrikeCE = ValueWhen(Ref(Short,-Entrydelay),strikeCE); \nExitStrikePE = ValueWhen(Ref(Buy,-Entrydelay),strikePE);\nif(broker==&quot;tc&quot; OR broker ==&quot;fs&quot;)\n{\nentrysym = WriteIf(buycontinue OR sell,spot+expiry+&quot;P&quot;+strikePE,WriteIf(shortcontinue OR cover,spot+expiry+&quot;C&quot;+strikeCE,&quot;&quot;));\nexitsym = WriteIf(buycontinue OR sell,spot+expiry+&quot;C&quot;+ExitStrikeCE,WriteIf(shortcontinue OR cover,spot+expiry+&quot;P&quot;+ExitStrikePE,&quot;&quot;));\n}\nelse\n{\nentrysym = WriteIf(buycontinue OR sell,spot+expiry+&quot;P&quot;+strikePE,WriteIf(shortcontinue OR cover,spot+expiry+&quot;P&quot;+strikeCE,&quot;&quot;));\nexitsym = WriteIf(buycontinue OR sell,spot+expiry+&quot;C&quot;+ExitStrikeCE,WriteIf(shortcontinue OR cover,spot+expiry+&quot;C&quot;+ExitStrikePE,&quot;&quot;));\n}\n}\n\nprintf(&quot;\\n\\n\\nEntry Symbol : &quot;+entrysym);\nprintf(&quot;\\nExit Symbol : &quot;+exitsym);\n\n\n_SECTION_END();\n\n\n\n\/\/Buy and Sell Order Functions\nfunction Placeorder(action,OptionType,orderqty)\n{\n\t\n    algomojo=CreateObject(&quot;AMAMIBRIDGE.Main&quot;);\n    \n    if(broker==&quot;tc&quot; OR broker==&quot;fs&quot; )\n\t{\n\t\tif(OptionType==&quot;CE&quot;) OptType = &quot;C&quot;;\n\t\tif(OptionType==&quot;PE&quot;) OptType = &quot;P&quot;;\n\t\ttradingsymbol = spot+expiry+OptType+VarGetText(&quot;strike&quot;+OptionType);\n    }\n    else\n\t{\n\t\ttradingsymbol = spot+expiry+VarGetText(&quot;strike&quot;+OptionType)+OptionType;\n    }\n    api_data = &quot;{ \\&quot;broker\\&quot;: \\&quot;&quot;+broker+&quot;\\&quot;,\n            \\&quot;strategy\\&quot;:\\&quot;&quot;+strategy+&quot;\\&quot;,\n            \\&quot;exchange\\&quot;:\\&quot;&quot;+exchange+&quot;\\&quot;,\n            \\&quot;symbol\\&quot;:\\&quot;&quot;+tradingsymbol+&quot;\\&quot;,\n            \\&quot;action\\&quot;:\\&quot;&quot;+action+&quot;\\&quot;,\n            \\&quot;product\\&quot;:\\&quot;&quot;+product+&quot;\\&quot;,\n            \\&quot;pricetype\\&quot;:\\&quot;&quot;+pricetype+&quot;\\&quot;,\n            \\&quot;quantity\\&quot;:\\&quot;&quot;+orderqty+&quot;\\&quot;,\n            \\&quot;price\\&quot;:\\&quot;&quot;+price+&quot;\\&quot;,      \n            \\&quot;disclosed_quantity\\&quot;:\\&quot;&quot;+disclosed_quantity+&quot;\\&quot;,\n            \\&quot;trigger_price\\&quot;:\\&quot;&quot;+trigger_price+&quot;\\&quot;,\n            \\&quot;amo\\&quot;:\\&quot;&quot;+amo+&quot;\\&quot;,\n            \\&quot;splitorder\\&quot;:\\&quot;&quot;+splitorder+&quot;\\&quot;,\n            \\&quot;split_quantity\\&quot;:\\&quot;&quot;+split_quantity+&quot;\\&quot;\n          \n        }&quot;; \n    \n    _TRACE(&quot;API Request&quot;+api_data);\n    resp=algomojo.AMDispatcher(apikey, apisecret,&quot;PlaceOrder&quot;,api_data,&quot;am&quot;,ver);\n    _TRACE(&quot;API Response : &quot;+resp);\n    \n    if(VoiceAlert == &quot;Enable&quot;)\n\tSay( &quot;Order Placed&quot; ); \n}\n\nfunction ExitOrder(action,OptionType)\n{\n\n\n algomojo=CreateObject(&quot;AMAMIBRIDGE.Main&quot;);\n \nif(broker==&quot;tc&quot; or broker==&quot;fs&quot;)\n{\n\tif(OptionType==&quot;CE&quot;) OptType = &quot;C&quot;;\n\tif(OptionType==&quot;PE&quot;) OptType = &quot;P&quot;;\n\ttradingsymbol = spot+expiry+OptType+VarGetText(&quot;ExitStrike&quot;+OptionType);\n}\n\nelse\n{\n\ttradingsymbol = spot+expiry+VarGetText(&quot;ExitStrike&quot;+OptionType)+OptionType;\n}\n\napi_data = &quot;{ \\&quot;broker\\&quot;: \\&quot;&quot;+broker+&quot;\\&quot;,\n            \\&quot;strategy\\&quot;:\\&quot;&quot;+strategy+&quot;\\&quot;,\n            \\&quot;exchange\\&quot;:\\&quot;&quot;+exchange+&quot;\\&quot;,\n            \\&quot;symbol\\&quot;:\\&quot;&quot;+tradingsymbol+&quot;\\&quot;,\n            \\&quot;action\\&quot;:\\&quot;&quot;+action+&quot;\\&quot;,\n            \\&quot;product\\&quot;:\\&quot;&quot;+product+&quot;\\&quot;,\n            \\&quot;pricetype\\&quot;:\\&quot;&quot;+pricetype+&quot;\\&quot;,\n            \\&quot;quantity\\&quot;:\\&quot;&quot;+&quot;0&quot;+&quot;\\&quot;,\n            \\&quot;price\\&quot;:\\&quot;&quot;+price+&quot;\\&quot;,\n            \\&quot;position_size\\&quot;:\\&quot;&quot;+&quot;0&quot;+&quot;\\&quot;,            \n            \\&quot;disclosed_quantity\\&quot;:\\&quot;&quot;+disclosed_quantity+&quot;\\&quot;,\n            \\&quot;trigger_price\\&quot;:\\&quot;&quot;+trigger_price+&quot;\\&quot;,\n            \\&quot;amo\\&quot;:\\&quot;&quot;+amo+&quot;\\&quot;,\n            \\&quot;splitorder\\&quot;:\\&quot;&quot;+splitorder+&quot;\\&quot;,\n            \\&quot;split_quantity\\&quot;:\\&quot;&quot;+split_quantity+&quot;\\&quot;\n          \n        }&quot;; \n\n_TRACE(&quot;Broker API Request&quot;+api_data);\nresp=algomojo.AMDispatcher(apikey, apisecret,&quot;PlaceSmartOrder&quot;,api_data,&quot;am&quot;,ver);\n\n_TRACE(&quot;API Response : &quot;+resp);\n\nif(VoiceAlert == &quot;Enable&quot;)\n\tSay( &quot;Order Placed&quot; );\n\nreturn resp;\n\n}\n\n\n\nif(EnableAlgo != &quot;Disable&quot;)\n    {\n        lasttime = StrFormat(&quot;%0.f&quot;,LastValue(BarIndex()));\n        \n        SetChartBkColor(colorDarkGrey);\n        if(EnableAlgo == &quot;Enable&quot;)\n        {   \n            if (AlgoBuy==True AND AlgoCover == True AND StaticVarGet(static_name_+&quot;buyCoverAlgo&quot;)==0 AND StaticVarGetText(static_name_+&quot;buyCoverAlgo_barvalue&quot;) != lasttime )\n            {\n            \n\t\t\t\tif(tradetype==&quot;BUY&quot;)\n\t\t\t\t{\n\t\t\t\t\/\/Long Call and Exit Long Put Option\n\t\t\t\tExitOrder(&quot;SELL&quot;,&quot;PE&quot;); \n\t\t\t\tPlaceOrder(&quot;BUY&quot;,&quot;CE&quot;,quantity);\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif(tradetype==&quot;SELL&quot;)\n\t\t\t\t{\n\t\t\t\t\/\/Short Put and Exit Short Call Option\n\t\t\t\tExitOrder(&quot;BUY&quot;,&quot;CE&quot;); \n\t\t\t\tPlaceOrder(&quot;SELL&quot;,&quot;PE&quot;,quantity);\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t\n                StaticVarSetText(static_name_+&quot;buyCoverAlgo_barvalue&quot;,lasttime);  \n                StaticVarSet(static_name_+&quot;buyCoverAlgo&quot;,1); \/\/Algo Order was triggered, no more order on this bar\n                \n        \n            }\n            else if ((AlgoBuy != True OR AlgoCover != True))\n            {   \n                StaticVarSet(static_name_+&quot;buyCoverAlgo&quot;,0);\n                StaticVarSetText(static_name_+&quot;buyCoverAlgo_barvalue&quot;,&quot;&quot;);\n            }\n            \n            if (AlgoBuy==True AND AlgoCover != True AND StaticVarGet(static_name_+&quot;buyAlgo&quot;)==0 AND StaticVarGetText(static_name_+&quot;buyAlgo_barvalue&quot;) != lasttime)\n            {\n            \n\t\t\t\tif(tradetype==&quot;BUY&quot;)\n\t\t\t\t{\n\t\t\t\t\/\/Long Call and Exit Long Put Option\n\t\t\t\tPlaceOrder(&quot;BUY&quot;,&quot;CE&quot;,quantity);\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif(tradetype==&quot;SELL&quot;)\n\t\t\t\t{\n\t\t\t\t\/\/Short Put\n\t\t\t\tPlaceOrder(&quot;SELL&quot;,&quot;PE&quot;,quantity);\n\t\t\t\t\t\n\t\t\t\t}\n                StaticVarSetText(static_name_+&quot;buyAlgo_barvalue&quot;,lasttime); \n                StaticVarSet(static_name_+&quot;buyAlgo&quot;,1); \/\/Algo Order was triggered, no more order on this bar\n                \n            }\n            else if (AlgoBuy != True)\n            {   \n                StaticVarSet(static_name_+&quot;buyAlgo&quot;,0);\n                StaticVarSetText(static_name_+&quot;buyAlgo_barvalue&quot;,&quot;&quot;);\n                \n            }\n            if (AlgoSell==true AND AlgoShort != True AND StaticVarGet(static_name_+&quot;sellAlgo&quot;)==0 AND StaticVarGetText(static_name_+&quot;sellAlgo_barvalue&quot;) != lasttime)\n            {     \n\t\t\t\t\n\t\t\t\tif(tradetype==&quot;BUY&quot;)\n\t\t\t\t{\n\t\t\t\t\/\/Exit Long Call Option\n\t\t\t\t\n\t\t\t\tExitOrder(&quot;SELL&quot;,&quot;CE&quot;); \n\t\t\t\t\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif(tradetype==&quot;SELL&quot;)\n\t\t\t\t{\n\t\t\t\t\/\/Exit Short Put Option\n\t\t\t\tExitOrder(&quot;BUY&quot;,&quot;PE&quot;); \n\t\t\t\t\n\t\t\t\t}\n                \n                StaticVarSetText(static_name_+&quot;sellAlgo_barvalue&quot;,lasttime);\n                StaticVarSet(static_name_+&quot;sellAlgo&quot;,1); \/\/Algo Order was triggered, no more order on this bar\n                \n            }\n            else if (AlgoSell != True )\n            {   \n                StaticVarSet(static_name_+&quot;sellAlgo&quot;,0);\n                StaticVarSetText(static_name_+&quot;sellAlgo_barvalue&quot;,&quot;&quot;);\n            }\n            if (AlgoShort==True AND AlgoSell==True AND  StaticVarGet(static_name_+&quot;ShortSellAlgo&quot;)==0 AND StaticVarGetText(static_name_+&quot;ShortSellAlgo_barvalue&quot;) != lasttime)\n            {\n            \n\t\t\t\tif(tradetype==&quot;BUY&quot;)\n\t\t\t\t{\n\t\t\t\t\/\/Long Put and Exit Long Call Option\n\t\t\t\tExitOrder(&quot;SELL&quot;,&quot;CE&quot;); \n\t\t\t\tPlaceOrder(&quot;BUY&quot;,&quot;PE&quot;,quantity);\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif(tradetype==&quot;SELL&quot;)\n\t\t\t\t{\n\t\t\t\t\/\/Short Call and Exit Short Put Option\n\t\t\t\tExitOrder(&quot;BUY&quot;,&quot;PE&quot;);\n\t\t\t\tPlaceOrder(&quot;SELL&quot;,&quot;CE&quot;,quantity);\n\t\t\t\t \n\t\t\t\t\n\t\t\t\t}\n                StaticVarSetText(static_name_+&quot;ShortsellAlgo_barvalue&quot;,lasttime);\n                StaticVarSet(static_name_+&quot;ShortSellAlgo&quot;,1); \/\/Algo Order was triggered, no more order on this bar\n                \n            }\n            else if ((AlgoShort != True OR AlgoSell != True))\n            {   \n                StaticVarSet(static_name_+&quot;ShortSellAlgo&quot;,0);\n                StaticVarSetText(static_name_+&quot;ShortsellAlgo_barvalue&quot;,&quot;&quot;);\n            }\n                \n            if (AlgoShort==True  AND  AlgoSell != True AND StaticVarGet(static_name_+&quot;ShortAlgo&quot;)==0 AND  StaticVarGetText(static_name_+&quot;ShortAlgo_barvalue&quot;) != lasttime)\n            {\n\t\t\t\tif(tradetype==&quot;BUY&quot;)\n\t\t\t\t{\n\t\t\t\t\/\/Long Put\n\t\t\t\tPlaceOrder(&quot;BUY&quot;,&quot;PE&quot;,quantity);\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif(tradetype==&quot;SELL&quot;)\n\t\t\t\t{\n\t\t\t\t\/\/Short Call\n\t\t\t\tPlaceOrder(&quot;SELL&quot;,&quot;CE&quot;,quantity);\n\t\t\t\t\t\t\t\n\t\t\t\t}\n                StaticVarSetText(static_name_+&quot;ShortAlgo_barvalue&quot;,lasttime); \n                StaticVarSet(static_name_+&quot;ShortAlgo&quot;,1); \/\/Algo Order was triggered, no more order on this bar\n                \n            }\n            else if (AlgoShort != True )\n            {   \n                StaticVarSet(static_name_+&quot;ShortAlgo&quot;,0);\n                StaticVarSetText(static_name_+&quot;ShortAlgo_barvalue&quot;,&quot;&quot;);\n            }\n            if (AlgoCover==true AND AlgoBuy != True AND StaticVarGet(static_name_+&quot;CoverAlgo&quot;)==0 AND StaticVarGetText(static_name_+&quot;CoverAlgo_barvalue&quot;) != lasttime)\n            {\n\t\t\t\t\n\t\t\t\tif(tradetype==&quot;BUY&quot;)\n\t\t\t\t{\n\t\t\t\t\/\/Exit Long Put Option\n\t\t\t\t\n\t\t\t\tExitOrder(&quot;SELL&quot;,&quot;PE&quot;); \n\t\t\t\t\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif(tradetype==&quot;SELL&quot;)\n\t\t\t\t{\n\t\t\t\t\/\/Exit Short Call Option\n\t\t\t\tExitOrder(&quot;BUY&quot;,&quot;CE&quot;); \n\t\t\t\t\n\t\t\t\t}\n               \n                StaticVarSetText(static_name_+&quot;CoverAlgo_barvalue&quot;,lasttime); \n                StaticVarSet(static_name_+&quot;CoverAlgo&quot;,1); \/\/Algo Order was triggered, no more order on this bar\n                \n            }\n            else if (AlgoCover != True )\n            {   \n                StaticVarSet(static_name_+&quot;CoverAlgo&quot;,0);\n                StaticVarSetText(static_name_+&quot;CoverAlgo_barvalue&quot;,&quot;&quot;);\n            }\n        }\n        \n      else if(EnableAlgo == &quot;LongOnly&quot;)\n        {\n        \n\t\t\t if (AlgoBuy==True AND StaticVarGet(static_name_+&quot;buyAlgo&quot;)==0 AND StaticVarGetText(static_name_+&quot;buyAlgo_barvalue&quot;) != lasttime)\n            {\n            \n\t\t\t\tif(tradetype==&quot;BUY&quot;)\n\t\t\t\t{\n\t\t\t\t\/\/Long Call and Exit Long Put Option\n\t\t\t\tPlaceOrder(&quot;BUY&quot;,&quot;CE&quot;,quantity);\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif(tradetype==&quot;SELL&quot;)\n\t\t\t\t{\n\t\t\t\t\/\/Short Put\n\t\t\t\tPlaceOrder(&quot;SELL&quot;,&quot;PE&quot;,quantity);\n\t\t\t\t\t\n\t\t\t\t}\n                StaticVarSetText(static_name_+&quot;buyAlgo_barvalue&quot;,lasttime);\n                StaticVarSet(static_name_+&quot;buyAlgo&quot;,1); \/\/Algo Order was triggered, no more order on this bar\n                \n            }\n            \n            \n            else if (AlgoBuy != True )\n            {  \n                StaticVarSet(static_name_+&quot;buyAlgo&quot;,0);\n                StaticVarSetText(static_name_+&quot;buyAlgo_barvalue&quot;,&quot;&quot;);\n            \n            }\n            \n             if (AlgoSell==True AND StaticVarGet(static_name_+&quot;sellAlgo&quot;)==0 AND StaticVarGetText(static_name_+&quot;sellAlgo_barvalue&quot;) != lasttime)\n            { \n            \n\t\t\t\tif(tradetype==&quot;BUY&quot;)\n\t\t\t\t{\n\t\t\t\t\/\/Exit Long Call Option\n\t\t\t\t\n\t\t\t\tExitOrder(&quot;SELL&quot;,&quot;CE&quot;); \n\t\t\t\t\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif(tradetype==&quot;SELL&quot;)\n\t\t\t\t{\n\t\t\t\t\/\/Exit Short Put Option\n\t\t\t\tExitOrder(&quot;BUY&quot;,&quot;PE&quot;); \n\t\t\t\t\n\t\t\t\t}\n                StaticVarSet(static_name_+&quot;sellAlgo&quot;,1);\n                StaticVarSetText(static_name_+&quot;sellAlgo_barvalue&quot;,lasttime);\n            }\n            else if (AlgoSell != True )\n            {  \n                StaticVarSet(static_name_+&quot;sellAlgo&quot;,0);\n                StaticVarSetText(static_name_+&quot;sellAlgo_barvalue&quot;,&quot;&quot;);\n            \n            }\n            \n        } \n        else if(EnableAlgo == &quot;ShortOnly&quot;)\n        {\n            if (AlgoShort==True AND StaticVarGet(static_name_+&quot;ShortAlgo&quot;)==0 AND StaticVarGetText(static_name_+&quot;ShortAlgo_barvalue&quot;) != lasttime)\n            {\n\t\t\t\tif(tradetype==&quot;BUY&quot;)\n\t\t\t\t{\n\t\t\t\t\/\/Long Put\n\t\t\t\tPlaceOrder(&quot;BUY&quot;,&quot;PE&quot;,quantity);\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif(tradetype==&quot;SELL&quot;)\n\t\t\t\t{\n\t\t\t\t\/\/Short Call\n\t\t\t\tPlaceOrder(&quot;SELL&quot;,&quot;CE&quot;,quantity);\n\t\t\t\t\t\t\t\n\t\t\t\t}\n                StaticVarSetText(static_name_+&quot;ShortAlgo_barvalue&quot;,lasttime); \n                StaticVarSet(static_name_+&quot;ShortAlgo&quot;,1); \/\/Algo Order was triggered, no more order on this bar\n                \n            }\n            else if (AlgoShort != True )\n            {   \n                StaticVarSet(static_name_+&quot;ShortAlgo&quot;,0);\n                StaticVarSetText(static_name_+&quot;ShortAlgo_barvalue&quot;,&quot;&quot;);\n            }\n            if (AlgoCover==true AND StaticVarGet(static_name_+&quot;CoverAlgo&quot;)==0 AND StaticVarGetText(static_name_+&quot;CoverAlgo_barvalue&quot;) != lasttime)\n            {\n            \n\t\t\t\tif(tradetype==&quot;BUY&quot;)\n\t\t\t\t{\n\t\t\t\t\/\/Exit Long Put Option\n\t\t\t\t\n\t\t\t\tExitOrder(&quot;SELL&quot;,&quot;PE&quot;); \n\t\t\t\t\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif(tradetype==&quot;SELL&quot;)\n\t\t\t\t{\n\t\t\t\t\/\/Exit Short Call Option\n\t\t\t\tExitOrder(&quot;BUY&quot;,&quot;CE&quot;); \n\t\t\t\t\n\t\t\t\t}\n               \n                StaticVarSetText(static_name_+&quot;CoverAlgo_barvalue&quot;,lasttime); \n                StaticVarSet(static_name_+&quot;CoverAlgo&quot;,1); \/\/Algo Order was triggered, no more order on this bar\n                \n            }\n            else if (AlgoCover != True)\n            {   \n                StaticVarSet(static_name_+&quot;CoverAlgo&quot;,0);\n                StaticVarSetText(static_name_+&quot;CoverAlgo_barvalue&quot;,&quot;&quot;);\n            }\n        } \n        \n    }\n    \n  \n_SECTION_END();<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>3)Ensure Log Window is open to capture the Trace Logs<\/p>\n\n\n\n<p>4)Enter the Spot Symbol, Expiry Date, Strike Interval, Offset, and Trade Delay<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-markdown\">Note : Ensure while entering the Option Expiry Format. Login to Algomojo Terminal and check out the weekly and monthly option format and enter the expiry date accordingly.\n\nFor Aliceblue account holders Monthly Option Symbol Format: NIFTY21JAN14500CE\n\nHence the Expiry Date needs to be entered as 21JAN\n\nFor Aliceblue Account holders weekly Option Symbol Format: NIFTY2111414500CE\n\nHence the Expiry Date needs to be entered as 21114\n\nFor Tradejini and Zebu Account Holders Monthly Option Symbol Format: NIFTY28JAN2114500CE\n\nHence the Expiry Date needs to be entered as 28JAN21\n\nFor Tradejini and Zebu Account Holders Monthly Option Symbol Format: NIFTY14JAN2114500CE\n\nHence the Expiry Date needs to be entered as 14JAN21<\/code><\/pre>\n\n\n\n<p>7)Bingo Now you can Send ATM Option Orders from Amibroker by connecting any of your Buy\/Sell Trading System. To Send ITM\/OTM Option Orders to adjust the offset parameters from the Properties section<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial provides instructions on how to utilize simple buy and sell trading signals in Spot\/Future charts to place option orders (including ATM, ITM, and OTM options) on the Algomojo platform. Implementing this system can help traders mitigate risk, particularly in the event of unexpected market movements that may result in significant losses. Additionally, implementing ATM or ITM option buying strategies, as opposed to futures, may help to reduce the risk of extreme black swan events and significantly mitigate the potential for large gap-up or gap-down risks when carrying forward positions.<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"default","ast-global-header-display":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":""},"categories":[6,15],"tags":[13,71,72,73,74,70],"_links":{"self":[{"href":"https:\/\/algomojo.com\/blog\/wp-json\/wp\/v2\/posts\/128"}],"collection":[{"href":"https:\/\/algomojo.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/algomojo.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/algomojo.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/algomojo.com\/blog\/wp-json\/wp\/v2\/comments?post=128"}],"version-history":[{"count":21,"href":"https:\/\/algomojo.com\/blog\/wp-json\/wp\/v2\/posts\/128\/revisions"}],"predecessor-version":[{"id":637,"href":"https:\/\/algomojo.com\/blog\/wp-json\/wp\/v2\/posts\/128\/revisions\/637"}],"wp:attachment":[{"href":"https:\/\/algomojo.com\/blog\/wp-json\/wp\/v2\/media?parent=128"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/algomojo.com\/blog\/wp-json\/wp\/v2\/categories?post=128"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/algomojo.com\/blog\/wp-json\/wp\/v2\/tags?post=128"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}