Здравствуйте! Помогите разобраться с кодом. Проблема в следующем, тф5, в 9:00:10 (иногда значение секунд другое) на 2 минуты значение индикатора = 0... и так каждые 10 минут, т.е. в 9:10:10, 9:20:10, 9:30:10 и тд до 10 часов! потом всё нормально работает! Где причина, не могу понять... Подскажите, если кто знает.
Цитата |
---|
func createString(v1,v2,v3) string=set_value(string, "ins",v1) string=set_value(string, "last",v2) string=set_value(string, "cci",v3) line=line+1 add_item(line, string) end func func get_market(class_code) market="" if ((class_code&""=="EQNE") or (class_code&""=="EQBR") or (class_code&""=="EQNL") or (class_code&""=="EQLV") or (class_code&""=="EQLV") or (class_code&""=="EQBS") or (class_code&""=="RTSST")) market="micex" end if if ((class_code&""=="TQNE") or (class_code&""=="TQBR") or (class_code&""=="TQNL") or (class_code&""=="TQLV") or (class_code&""=="TQLV") or (class_code&""=="TQBS") or (class_code&""=="RTSST")) market="micex" end if if ((class_code&""=="SPBFUT")) market="forts" end if result=market end func func get_class(security_code) EQNE = GET_CLASS_SECURITIES ("EQNE") EQBR = GET_CLASS_SECURITIES ("EQBR") EQNL = GET_CLASS_SECURITIES ("EQNL") EQLI = GET_CLASS_SECURITIES ("EQLI") EQLV = GET_CLASS_SECURITIES ("EQLV") EQBS = GET_CLASS_SECURITIES ("EQBS") TQNE = GET_CLASS_SECURITIES ("TQNE") TQBR = GET_CLASS_SECURITIES ("TQBR") TQNL = GET_CLASS_SECURITIES ("TQNL") TQLI = GET_CLASS_SECURITIES ("TQLI") TQLV = GET_CLASS_SECURITIES ("TQLV") TQBS = GET_CLASS_SECURITIES ("TQBS") GTS = GET_CLASS_SECURITIES ("GTS") SPBFUT = GET_CLASS_SECURITIES ("SPBFUT") RTSST = GET_CLASS_SECURITIES ("RTSST") class="" for sec_code in TQNE if sec_code==security_code class="TQNE" break end if end for for sec_code in TQBR if sec_code==security_code class="TQBR" break end if end for for sec_code in TQNL if sec_code==security_code class="TQNL" break end if end for for sec_code in TQLI if sec_code==security_code class="TQLI" break end if end for for sec_code in TQLV if sec_code==security_code class="TQLV" break end if end for for sec_code in TQBS if sec_code==security_code class="TQBS" break end if end for for sec_code in EQNE if sec_code==security_code class="EQNE" break end if end for for sec_code in EQBR if sec_code==security_code class="EQBR" break end if end for for sec_code in EQNL if sec_code==security_code class="EQNL" break end if end for for sec_code in EQLI if sec_code==security_code class="EQLI" break end if end for for sec_code in EQLV if sec_code==security_code class="EQLV" break end if end for for sec_code in EQBS if sec_code==security_code class="EQBS" break end if end for for sec_code in GTS if sec_code==security_code class="GTS" break end if end for for sec_code in SPBFUT if sec_code==security_code class="SPBFUT" break end if end for 'for sec_code in RTSST 'if sec_code==security_code 'class="RTSST" 'break 'end if 'end for result=class end func func get_total_net(market,client,code) if market="micex" or class&""=="RTSST" n=GET_NUMBER_OF("DEPO_LIMITS") cur_bal_lim=0 TOTAL_NET=0 FOR i FR OM 1 to n limit = GET_ITEM ("DEPO_LIMITS", i) LIMIT_KIND= GET_VALUE (limit, "LIMIT_KIND")&"" sch= GET_VALUE (limit, "CLIENT_CODE") sec_t=GET_VALUE (limit, "SECCODE") if sch==client and LIMIT_KIND&""=="2" and sec_t==code TOTAL_NET=GET_VALUE (limit, "CURRENT_BALANCE") usl=1 break end if END FOR result=TOTAL_NET end if if market="forts" and class&""!="RTSST" n=GET_NUMBER_OF("FUTURES_CLIENT_HOLDINGS") TOTAL_NET=0 FOR i FR OM 1 to n limit = GET_ITEM ("FUTURES_CLIENT_HOLDINGS", i) sch= GET_VALUE (limit, "TRDACCID") sec_t=GET_VALUE (limit, "SECCODE") if sch=client if sec_t=code TOTAL_NET=GET_VALUE (limit, "TOTAL_NET")+0 end if end if END FOR result=TOTAL_NET end if end func func get_CBPLPLANNED(market,client) if market="micex" n=GET_NUMBER_OF("MONEY_LIMITS") usl=0 CBPLPLANNED=0 FOR i FR OM 1 to n limit = GET_ITEM ("MONEY_LIMITS", i) sch = GET_VALUE (limit, "CLIENT_CODE") LIMIT_KIND= GET_VALUE (limit, "LIMIT_KIND")&"" if usl=0 and LIMIT_KIND&""=="2" if sch=client usl=1 CBPLPLANNED=GET_VALUE (limit, "CURRENT_BALANCE")+0 break end if end if END FOR result=CBPLPLANNED end if if market="forts" n=GET_NUMBER_OF("FUTURES_CLIENT_LIMITS") CBPLPLANNED=0 usl=0 FOR i FROM 1 to n lim it = GET_ITEM ("FUTURES_CLIENT_LIMITS", i) sch = GET_VALUE (lim it, "TRDACCID") if usl=0 if sch=client CBPLPLANNED=GET_VALUE (lim it, "CBPLPLANNED")+0 usl=1 end if end if END FOR result=CBPLPLANNED end if end func func time() time=get_datetime() year=get_value(time,"YEAR") month=get_value(time,"MONTH") day=get_value(time,"DAY") minute=get_value(time,"MIN") hour=get_value(time,"HOUR") sec=get_value(time,"SEC") curdate=year*10000+month*100+day curtime=hour*10000+minute*100+sec res=0 if market="forts" if (curtime>90005 and curtime<135940) or (curtime>140505 and curtime<184900) or (curtime>190505 and curtime<234500) res=1 end if end if if market="micex" if (curtime>100010 and curtime<184450) res=1 end if end if work=0 IF (0 + IS_CONNECTED() = 1) seconline=SUBSTR(Get_Info_Param("CONNECTIONTIME"),6,2) minonline=SUBSTR(Get_Info_Param("CONNECTIONTIME"),3,2) houronline=SUBSTR(Get_Info_Param("CONNECTIONTIME"),0,2) if (((houronline+0)>1) or ((minonline+0)>1) or ((seconline+0)>20)) work=1 end if end if if (work+0)=1 result=res else result=0 end if end func func get_profit(code_profit) n=get_number_of("TRADES") summ=0 start_net_trades=get_open_net(market,client,code) if market="micex" price_close=get_value(get_candle(id_base,true_date,184900,0),"close") end if if market="forts" price_close=get_value(get_candle(id_base,true_date,235000,0),"close") end if message(price_close,1) if (start_net_trades+0)>620 summ=summ-(start_net_trades-620)*price_trades end if if (start_net_trades+0)<620 summ=summ+(620-start_net_trades)*price_trades end if for i from 1 to n str_trades=get_item("TRADES",i) seccode_trades=get_value(str_trades,"SECCODE") operation_trades=get_value(str_trades,"OPERATION") quantity_trades=get_value(str_trades,"QUANTITY") price_trades=get_value(str_trades,"PRICE") if seccode_trades&""==code_profit if operation_trades&""="BUY" summ=summ-quantity_trades*price_trades end if if operation_trades&""="SELL" summ=summ+quantity_trades*price_trades end if end if end for if (total_net+0)>620 summ=summ+(total_net-620)*last end if if (total_net+0)<620 summ=summ-(620-total_net)*last end if 'result=summ end func FUNC operation(client,depo,operation,price,quantity,seccode,classcode,market) new_global("trans_params", "") new_global("trans_result", "") trans_params = "" trans_params = set_value (trans_params, "TRANS_ID", "1") trans_params = set_value (trans_params, "ACTION", "NEW_ORDER") trans_params = set_value (trans_params, "CLASSCODE", classcode) trans_params = set_value (trans_params, "SECCODE",seccode) if (market&"")=="micex" trans_params = set_value (trans_params, "ACCOUNT",depo) trans_params = set_value (trans_params, "CLIENT_CODE", client) end if if (market&"")=="forts" trans_params = set_value (trans_params, "ACCOUNT",client) trans_params = set_value (trans_params, "CLIENT_CODE","") end if trans_params = set_value (trans_params, "OPERATION", operation) trans_params = set_value (trans_params, "QUANTITY", quantity) trans_params = set_value (trans_params, "TYPE", "L") trans_params = set_value (trans_params, "PRICE", price) trans_result=SEND_TRANSACTION (30, trans_params) curr_datetime=Get_DateTime() WRITELN ("qpile_trans.log", get_value (curr_datetime, "DATETIME") & ": " & "Result: " & get_value (trans_result, "RESULT") & ", Result_ex: " & get_value (trans_result, "RESULT_EX") & ", OrderNum: " & get_value (trans_result, "ORDER_NUMBER") & ", Description: " & get_value (trans_result, "DESCRIPTION")) if (get_value (trans_result, "RESULT_EX")+0)!=3 message(get_value (trans_result, "DESCRIPTION"),1) end if END FUNC FUNC stop_order(client,depo,operation,price,stopprice,quantity,seccode,classcode,market) trans_params = "" trans_params = set_value (trans_params, "TRANS_ID", 1) trans_params = set_value (trans_params, "ACTION", "NEW_STOP_ORDER") trans_params = set_value (trans_params, "CLASSCODE", classcode) trans_params = set_value (trans_params, "SECCODE",seccode) if (market&"")=="micex" trans_params = set_value (trans_params, "ACCOUNT",depo) trans_params = set_value (trans_params, "CLIENT_CODE", client) end if if (market&"")=="forts" trans_params = set_value (trans_params, "ACCOUNT",client) trans_params = set_value (trans_params, "CLIENT_CODE","") end if trans_params = set_value (trans_params, "OPERATION", operation) trans_params = set_value (trans_params, "QUANTITY", quantity) trans_params = set_value (trans_params, "TYPE", "L") trans_params = set_value (trans_params, "PRICE", price) trans_params = set_value (trans_params, "STOPPRICE", stopprice) trans_params = set_value (trans_params, "EXPIRY_DATE","GTC") trans_result=SEND_TRANSACTION (30, trans_params) curr_datetime=Get_DateTime() WRITELN ("qpile_trans.log", get_value (curr_datetime, "DATETIME") & ": " & "Result: " & get_value (trans_result, "RESULT") & ", Result_ex: " & get_value (trans_result, "RESULT_EX") & ", OrderNum: " & get_value (trans_result, "ORDER_NUMBER") & ", Description: " & get_value (trans_result, "DESCRIPTION")) stop_number=get_value (trans_result, "ORDER_NUMBER")+0 END FUNC FUNC trailing_stop(client,depo,operation,stop_price,offset,SPREAD,quantity,seccode,classcode,market) new_global("trans_params", "") new_global("trans_result", "") trans_params = "" trans_params = set_value (trans_params, "TRANS_ID", "1") trans_params = set_value (trans_params, "ACTION", "NEW_STOP_ORDER") trans_params = set_value (trans_params, "STOP_ORDER_KIND", "TAKE_PROFIT_STOP_ORDER") trans_params = set_value (trans_params, "CLASSCODE", classcode) trans_params = set_value (trans_params, "SECCODE",seccode) if (market&"")=="micex" trans_params = set_value (trans_params, "ACCOUNT",depo) trans_params = set_value (trans_params, "CLIENT_CODE", client) end if if (market&"")=="forts" trans_params = set_value (trans_params, "ACCOUNT",client) trans_params = set_value (trans_params, "CLIENT_CODE","") end if trans_params = set_value (trans_params, "OPERATION", operation) trans_params = set_value (trans_params, "QUANTITY", quantity) trans_params = set_value (trans_params, "TYPE", "L") trans_params = set_value (trans_params, "STOPPRICE", stop_price) trans_params = set_value (trans_params, "OFFSET", OFFSET) trans_params = set_value (trans_params, "OFFSET_UNITS", "PRICE_UNITS") trans_params = set_value (trans_params, "SPREAD", spread) trans_params = set_value (trans_params, "SPREAD_UNITS", "PRICE_UNITS") trans_params = set_value (trans_params, "EXPIRY_DATE","GTC") trans_result=SEND_TRANSACTION (30, trans_params) take_order=get_value (trans_result,"ORDER_NUMBER") curr_datetime=Get_DateTime() WRITELN ("qpile_trans.log", get_value (curr_datetime, "DATETIME") & ": " & "Result: " & get_value (trans_result, "RESULT") & ", Result_ex: " & get_value (trans_result, "RESULT_EX") & ", OrderNum: " & get_value (trans_result, "ORDER_NUMBER") & ", Description: " & get_value (trans_result, "DESCRIPTION")) END FUNC FUNC binded_stop(client,depo,operation,stop_price,price,linked_price,quantity,seccode,classcode,market) new_global("trans_params", "") new_global("trans_result", "") trans_params = "" trans_params = set_value (trans_params, "TRANS_ID", "1") trans_params = set_value (trans_params, "ACTION", "NEW_STOP_ORDER") trans_params = set_value (trans_params, "STOP_ORDER_KIND", "WITH_LINKED_LIMIT_ORDER") trans_params = set_value (trans_params, "CLASSCODE", classcode) trans_params = set_value (trans_params, "SECCODE",seccode) if (market&"")=="micex" trans_params = set_value (trans_params, "ACCOUNT",depo) trans_params = set_value (trans_params, "CLIENT_CODE", client) end if if (market&"")=="forts" trans_params = set_value (trans_params, "ACCOUNT",client) trans_params = set_value (trans_params, "CLIENT_CODE","") end if trans_params = set_value (trans_params, "OPERATION", operation) trans_params = set_value (trans_params, "QUANTITY", quantity) trans_params = set_value (trans_params, "TYPE", "L") trans_params = set_value (trans_params, "STOPPRICE", stop_price) trans_params = set_value (trans_params, "PRICE", price) trans_params = set_value (trans_params, "LINKED_ORDER_PRICE", linked_price) trans_params = set_value (trans_params, "KILL_IF_LINKED_ORDER_PARTLY_FILLED", "NO") trans_result=SEND_TRANSACTION (30, trans_params) binded_stop_number=get_value (trans_result,"ORDER_NUMBER") curr_datetime=Get_DateTime() WRITELN ("qpile_trans.log", get_value (curr_datetime, "DATETIME") & ": " & "Result: " & get_value (trans_result, "RESULT") & ", Result_ex: " & get_value (trans_result, "RESULT_EX") & ", OrderNum: " & get_value (trans_result, "ORDER_NUMBER") & ", Description: " & get_value (trans_result, "DESCRIPTION")) END FUNC FUNC kill_stop_order(orderkey,classcode,seccode) trans_params = "" trans_params = SET_VALUE(trans_params,"CLASSCODE",classcode) trans_params = set_value (trans_params, "SECCODE",seccode) trans_params = SET_VALUE(trans_params,"TRANS_ID","1") trans_params = SET_VALUE(trans_params,"ACTION","KILL_STOP_ORDER") trans_params = set_value (trans_params, "OPERATION", "s") trans_params = SET_VALUE(trans_params,"STOP_ORDER_KEY",orderkey) trans_result = SEND_TRANSACTION (30,trans_params) curr_datetime=Get_DateTime() WRITELN ("qpile_trans.log", get_value (curr_datetime, "DATETIME") & ": " & "Result: " & get_value (trans_result, "RESULT") & ", Result_ex: " & get_value (trans_result, "RESULT_EX") & ", OrderNum: " & get_value (trans_result, "ORDER_NUMBER") & ", Description: " & get_value (trans_result, "DESCRIPTION")) END FUNC FUNC get_candle(id,date,time,line_id) candle=create_map() slice = Get_Candle_Ex(id, date,time) time =Get_Value(slice,"TIME") lines=Get_Value(slice,"LINES") line=Get_Collection_Item(lines, line_id) close=Get_Value(line,"CLOSE")+0 high=Get_Value(line,"HIGH")+0 low=Get_Value(line,"LOW")+0 open=Get_Value(line,"OPEN")+0 candle=set_value(candle,"open",open) candle=set_value(candle,"high",high) candle=set_value(candle,"low",low) candle=set_value(candle,"close",close) candle=set_value(candle,"time",time) result=candle end func FUNC get_prices(id,market) if id&""!="" new_global("cur_time_bar_pred",0) new_global("close_pred",0) new_global("open_pred",0) new_global("high_pred",0) new_global("low_pred",0) time=get_datetime() hour=get_value(time,"HOUR") min=get_value(time,"MIN") day=get_value(time,"DAY") month=get_value(time,"MONTH") year=get_value(time,"YEAR") cur_date=year*10000+month*100+day cur_time=hour*10000+min*100 true_date=0 for i from 0 to 100000 candle=get_candle(id,cur_date,183000,0) if (get_value(candle,"open")+0)=0 if (day+0)<2 month=month-1 day=32 if month=0 month=12 year=year-1 end if end if day=day-1 cur_date=year*10000+month*100+day else true_date=cur_date break end if end for timeframe_collection=create_collection() hour=18 min=30 time=hour*10000+min*100 pred_time="0" j=0 timeframe="" for i from 0 to 1000 candle=get_candle(id,true_date,time,0) if (get_value(candle,"time")+0)=0 timeframe="day" break end if if get_value(candle,"time")&""=pred_time&"" else timeframe_collection=insert_collection_item(timeframe_collection,j,get_value(candle,"time")) pred_time=get_value(candle,"time") j=j+1 end if if (min+0)=0 hour=hour-1 min=59 else min=min-1 end if time=hour*10000+min*100 if (get_collection_count(timeframe_collection)+0)>1 break end if end for dateframe_collection=create_collection() counter=0 time=get_datetime() day=get_value(time,"DAY") month=get_value(time,"MONTH") year=get_value(time,"YEAR") cur_date=year*10000+month*100+day pred_open=0 pred_high=0 pred_close=0 pred_low=0 if (timeframe&"")=="day" for i from 0 to 1000 candle=get_candle(id,cur_date,150000,0) if ((get_value(candle,"open")+0)!=(pred_open+0) or (get_value(candle,"high")+0)!=(pred_high+0) or (get_value(candle,"close")+0)!=(pred_close+0)) if ((get_value(candle,"close")+0)!=0) dateframe_collection=INSERT_COLLECTION_ITEM(dateframe_collection,counter,cur_date) pred_open=get_value(candle,"open") pred_high=get_value(candle,"high") pred_close=get_value(candle,"close") counter=counter+1 end if end if if (day+0)=1 month=month-1 day=32 if (month+0)=0 month=12 year=year-1 end if end if day=day-1 if get_collection_count(dateframe_collection)>20 break end if cur_date=year*10000+month*100+day end for end if hour1=SUBSTR (get_collection_item(timeframe_collection,0), 0, 2) min1=SUBSTR (get_collection_item(timeframe_collection,0), 2, 2) hour2=SUBSTR (get_collection_item(timeframe_collection,1), 0, 2) min2=SUBSTR (get_collection_item(timeframe_collection,1), 2, 2) chislo=0 if (((timeframe&"")<>"") or ((timeframe&"")<>"day")) if ((hour1+0)=(hour2+0)) if (min1-min2)=1 timeframe=1 chislo=1 end if if (min1-min2)=2 timeframe=2 chislo=1 end if if (min1-min2)=3 timeframe=3 chislo=1 end if if (min1-min2)=4 timeframe=4 chislo=1 end if if (min1-min2)=5 timeframe=5 chislo=1 end if if (min1-min2)=6 timeframe=6 chislo=1 end if if (min1-min2)=10 timeframe=10 chislo=1 end if if (min1-min2)=15 timeframe=15 chislo=1 end if if (min1-min2)=20 timeframe=20 chislo=1 end if if (min1-min2)=30 timeframe=30 chislo=1 end if end if if ((hour1+0)<>(hour2+0)) if (hour1-hour2)=1 timeframe=60 chislo=1 end if if (hour1-hour2)=2 timeframe=120 chislo=1 end if if (hour1-hour2)=4 timeframe=240 chislo=1 end if end if end if hour1=SUBSTR (get_collection_item(timeframe_collection,0), 0, 2) min1=SUBSTR (get_collection_item(timeframe_collection,0), 2, 2) hour2=SUBSTR (get_collection_item(timeframe_collection,1), 0, 2) min2=SUBSTR (get_collection_item(timeframe_collection,1), 2, 2) day_temp=0 'if (timeframe&""=="day") 'timeframe="week" ' for i from 0 to get_collection_count(dateframe_collection)-1 ' z=get_collection_item(dateframe_collection,i) ' t=SUBSTR(get_collection_item(dateframe_collection,i), 6, 2) ' if (i+0)>0 ' if abs(t-day_temp)==1 ' timeframe="day" ' break ' end if ' end if ' day_temp=SUBSTR (get_collection_item(dateframe_collection,i), 6, 2) ' end for 'end if time=get_datetime() hour=get_value(time,"HOUR") min=get_value(time,"MIN") day=get_value(time,"DAY") correct_day=day month=get_value(time,"MONTH") year=get_value(time,"YEAR") cur_date=year*10000+month*100+day cur_time=hour*10000+min*100 LOW_col=CREATE_COLLECTION() HIGH_col=CREATE_COLLECTION() open_col=CREATE_COLLECTION() CLOSE_col=CREATE_COLLECTION() time_col=CREATE_COLLECTION() date_col=CREATE_COLLECTION() cur_time_bar=get_value(get_candle(id,cur_date,cur_time,0),"time") if ((cur_time_bar&"")!="") cur_time_bar_pred=cur_time_bar else cur_time_bar=cur_time_bar_pred end if f=0 if (cur_time_bar+0)!=0 low_col=INSERT_COLLECTION_ITEM(low_col,0,get_value(get_candle(id,cur_date,cur_time_bar,0),"low")) high_col=INSERT_COLLECTION_ITEM(high_col,0,get_value(get_candle(id,cur_date,cur_time_bar,0),"high")) open_col=INSERT_COLLECTION_ITEM(open_col,0,get_value(get_candle(id,cur_date,cur_time_bar,0),"open")) close_col=INSERT_COLLECTION_ITEM(close_col,0,get_value(get_candle(id,cur_date,cur_time_bar,0),"close")) time_col=INSERT_COLLECTION_ITEM(time_col,0,cur_time_bar) date_col=INSERT_COLLECTION_ITEM(date_col,0,cur_date) f=1 end if find_date=cur_date point=0 if (chislo+0)==1 for i from 1 to 2000 temp3=ceil(cur_time_bar/10000) temp4=cur_time_bar/10000 if temp3=temp4 if floor(cur_time_bar/10000)=cur_time_bar/10000 if timeframe=1 cur_time_bar=ceil(cur_time_bar/10000-1)*10000+5900 end if if timeframe=2 cur_time_bar=ceil(cur_time_bar/10000-1)*10000+5800 end if if timeframe=3 cur_time_bar=ceil(cur_time_bar/10000-1)*10000+5700 end if if timeframe=4 cur_time_bar=ceil(cur_time_bar/10000-1)*10000+5600 end if if timeframe=5 cur_time_bar=ceil(cur_time_bar/10000-1)*10000+5500 end if if timeframe=6 cur_time_bar=ceil(cur_time_bar/10000-1)*10000+4800 end if if timeframe=10 cur_time_bar=ceil(cur_time_bar/10000-1)*10000+5000 end if if timeframe=15 cur_time_bar=ceil(cur_time_bar/10000-1)*10000+4500 end if if timeframe=20 cur_time_bar=ceil(cur_time_bar/10000-1)*10000+4000 end if if timeframe=30 cur_time_bar=ceil(cur_time_bar/10000-1)*10000+3000 end if if timeframe=60 cur_time_bar=ceil(cur_time_bar/10000-1)*10000 end if if timeframe=120 cur_time_bar=ceil(cur_time_bar/10000-2)*10000 end if if timeframe=240 cur_time_bar=ceil(cur_time_bar/10000-4)*10000 end if end if else cur_time_bar=cur_time_bar-timeframe*100 end if if timeframe<60 if cur_time_bar<90000 if (market&"")="micex" if timeframe=1 cur_time_bar=184400 end if if timeframe=2 cur_time_bar=184400 end if if timeframe=3 cur_time_bar=184200 end if if timeframe=4 cur_time_bar=184400 end if if timeframe=5 cur_time_bar=184000 end if if timeframe=6 cur_time_bar=184200 end if if timeframe=10 cur_time_bar=184000 end if if timeframe=15 cur_time_bar=183000 end if if timeframe=20 cur_time_bar=184000 end if if timeframe=30 cur_time_bar=183000 end if end if if (market&"")="forts" if timeframe=1 cur_time_bar=234900 end if if timeframe=2 cur_time_bar=234800 end if if timeframe=3 cur_time_bar=234800 end if if timeframe=4 cur_time_bar=234800 end if if timeframe=5 cur_time_bar=234500 end if if timeframe=6 cur_time_bar=234800 end if if timeframe=10 cur_time_bar=234000 end if if timeframe=15 cur_time_bar=234500 end if if timeframe=20 cur_time_bar=234000 end if if timeframe=30 cur_time_bar=233000 end if end if if timeframe>50 if cur_time_bar=100000 break end if if cur_time_bar<90000 if timeframe=60 cur_time_bar=230000 end if if timeframe=120 cur_time_bar=220000 end if if timeframe=240 cur_time_bar=200000 end if end if end if usl=0 for j from 1 to 15 if (day+0)<2 month=month-1 day=32 if month=0 month=12 year=year-1 end if end if day=day-1 cur_date=year*10000+month*100+day slice_day = Get_Candle_Ex(id, cur_date, 103000) LineCount_day=Get_Value(slice_day,"COUNT") +0 if (usl+0)=0 if LineCount_day>0 find_date=cur_date usl=1 break end if end if end for end if end if if timeframe>59 if cur_time_bar<80000 if (market&"")="forts" if timeframe=60 cur_time_bar=230000 end if if timeframe=120 cur_time_bar=220000 end if if timeframe=240 cur_time_bar=200000 end if end if if (market&"")="micex" if timeframe=60 cur_time_bar=180000 end if if timeframe=120 cur_time_bar=180000 end if if timeframe=240 cur_time_bar=160000 end if end if usl=0 for j from 1 to 15 if (day+0)<2 month=month-1 day=32 if month=0 month=12 year=year-1 end if end if day=day-1 curdate=year*10000+month*100+day slice_day = Get_Candle_Ex(id, curdate, 103000) LineCount_day=Get_Value(slice_day,"COUNT") +0 if (usl+0)=0 if LineCOUNT_day>0 find_date=curdate usl=1 break end if end if end for end if end if slice = Get_Candle_Ex(id, find_date,cur_time_bar) LineCount=Get_Value(slice,"COUNT") +0 time=Get_Value(slice,"TIME") lines=Get_Value(slice,"LINES") if f<5 if LineCount>0 if ((cur_time_bar+0)<>0) LineCount=Get_Value(slice,"COUNT") time=Get_Value(slice,"TIME") lines=Get_Value(slice,"LINES") line=Get_Collection_Item(lines, 0) low=Get_Value(line,"LOW") high=Get_Value(line,"HIGH") open=Get_Value(line,"OPEN") close=Get_Value(line,"CLOSE") line_name =Get_Value(line,"NAME") volume=Get_Value(line,"VOLUME") low_col=INSERT_COLLECTION_ITEM(low_col,f,low) high_col=INSERT_COLLECTION_ITEM(high_col,f,high) open_col=INSERT_COLLECTION_ITEM(open_col,f,open) close_col=INSERT_COLLECTION_ITEM(close_col,f,close) time_col=INSERT_COLLECTION_ITEM(time_col,f,cur_time_bar) date_col=INSERT_COLLECTION_ITEM(date_col,f,find_date) f=f+1 end if end if else break end if end for end if prices=create_map() prices=SET_VALUE(prices,"days",dateframe_collection) prices=SET_VALUE(prices,"timeframe",timeframe) prices=SET_VALUE(prices,"high",high_col) prices=SET_VALUE(prices,"low",low_col) prices=SET_VALUE(prices,"close",close_col) prices=SET_VALUE(prices,"open",open_col) prices=SET_VALUE(prices,"time",time_col) prices=SET_VALUE(prices,"date",date_col) result=prices else result=0 end if end func |