Şuanki Dizin: /home/wwwdreamtechnolo/www/sharemarkettraders.com/software/ |
Şuanki Dosya : /home/wwwdreamtechnolo/www/sharemarkettraders.com/software/nine-twenty-algorithm.php |
<?php require_once('lib/function.php'); $db = new login_function(); /*****************************PLACE ORDER************************** */ function place_stock_order($symboltoken,$strategy_type,$buy_type,$price) { //take strategy data from another table $stock_settings_data = $db->get_stock_setting_data($symboltoken,$strategy_type); if(!empty($stock_settings_data)) { $strategy_name = $stock_settings_data['strategy_name']; $symboltoken = $stock_settings_data['symboltoken']; $variety = $stock_settings_data['variety']; $exchange = $stock_settings_data['exchange']; $transactiontype= $stock_settings_data['transactiontype']; $ordertype = $stock_settings_data['ordertype']; $quantity = $stock_settings_data['quantity']; $producttype = $stock_settings_data['producttype']; $duration = $stock_settings_data['duration']; $target_points = $stock_settings_data['squareoff']; $stoploss_point = $stock_settings_data['stoploss']; $trade_execute_on_off = $stock_settings_data['trade_execute_on_off']; if($trade_execute_on_off=="ON") { $tradingsymbol = $db->get_trading_symbol_name($symboltoken); $squareoff = $price + $target_points; $stoploss = $price - $stoploss_point; $order = $smart_api ->PlaceOrder(array('variety' => $variety, 'tradingsymbol' => $tradingsymbol, 'symboltoken' => $symboltoken, 'exchange' => $exchange, 'transactiontype' => $transactiontype, 'ordertype' => $ordertype, 'quantity' => $quantity, 'producttype' => $producttype, 'price' => $price, 'squareoff' => $squareoff, 'stoploss' => $stoploss, 'duration' => $duration)); /*$order = $smart_api ->PlaceOrder(array('variety' => 'NORMAL', 'tradingsymbol' => 'JINDALSTEL-EQ', 'symboltoken' => '6733', 'exchange' => 'NSE', 'transactiontype' => 'BUY', 'ordertype' => 'LIMIT', 'quantity' => '1', 'producttype' => 'DELIVERY', 'price' => 690, 'squareoff' => 0, 'stoploss' => 0, 'duration' => 'DAY')); */ } } } /*****************************END PLACE ORDER************************** */ /*****************************FETCH CURRENT CANDLE DATA************************** */ //Current candle Data fetched $response_historical = '{"status":"success","http_code":200,"http_error":"","response_data":{"status":true,"message":"SUCCESS","errorcode":"","data":[["2023-09-15T09:25:00+05:30",2462.5,2464,2458.6,2459.4,72495],["2023-09-15T09:30:00+05:30",2459.95,2460.65,2455,2455.7,89342]]}}'; $extracted_data = array(); $extracted_data = json_decode($response_historical,true); $current_candle_response_timestamp = $extracted_data['response_data']['data'][1][0]; $current_candle_open = $extracted_data['response_data']['data'][1][1]; $current_candle_high = $extracted_data['response_data']['data'][1][2]; $current_candle_low = $extracted_data['response_data']['data'][1][3]; $current_candle_close = $extracted_data['response_data']['data'][1][4]; $current_candle_volume = $extracted_data['response_data']['data'][1][5]; /*****************************END FETCH CURRENT CANDLE DATA***************************/ /*****************************NINE TWENTY STRATEGY***************************/ //fetch nine twenty candle data $nine_twenty_candle_data = $db->get_todays_nine_twenty_candle_data($var_symbol_token); if(!empty($nine_twenty_candle_data)) { $res_id = $details[0]; $res_exchange = $details[1]; $res_symbol_token= $details[2]; $res_interval = $details[3]; $res_from_date = $details[4]; $res_to_date = $details[5]; //Nine twnty candle data into variables $nine_twenty_response_timestamp= $details[6]; $nine_twenty_open = $details[7]; $nine_twenty_high = $details[8]; $nine_twenty_low = $details[9]; $nine_twenty_close = $details[10]; $nine_twenty_volume = $details[11]; $res_date = $details[12]; $res_time = $details[13]; $res_api_response = $details[14]; //compare nine twenty candle breakout //1. Breakout from Low Of Nine Twenty if($current_candle_close > $nine_twenty_high AND $current_candle_open <= $nine_twenty_low) { echo "Breakout Done from nine twenty low of candle"; $strategy_type = "NINE_TWENTY"; $buy_type = "CALL"; place_stock_order($symboltoken,$strategy_type,$buy_type,$current_candle_close); } //2. Breakout from inside candle of nine twenty else if($current_candle_close > $nine_twenty_high AND $current_candle_open <= $nine_twenty_high) { echo "Breakout Done from inside"; $strategy_type = "Nine_Twenty"; $buy_type = "CALL"; place_stock_order($symboltoken,$strategy_type,$buy_type,$current_candle_close); } //3. Break down from High of Nine twenty if($current_candle_close < $nine_twenty_low AND $current_candle_open >= $nine_twenty_high) { $strategy_type = "Nine_Twenty"; $buy_type = "PUT"; place_stock_order($symboltoken,$strategy_type,$buy_type,$current_candle_close); } //4. Break down from inside of Nine twenty else if($current_candle_close < $nine_twenty_low AND $current_candle_open >= $nine_twenty_low) { $strategy_type = "Nine_Twenty"; $buy_type = "PUT"; place_stock_order($symboltoken,$strategy_type,$buy_type,$current_candle_close); } } /*****************************END NINE TWENTY STRATEGY***************************/ ?>
Linux 65-254-81-4.cprapid.com 5.14.0-284.11.1.el9_2.x86_64 #1 SMP PREEMPT_DYNAMIC Tue May 9 05:49:00 EDT 2023 x86_64
Apache
65.254.81.4