--Параметры: p_classcode=«SPBFUT» --Код класса p_seccode=«RIM6» --Код инструмента p_account="...." --Код счета p_clientcode="...." --Клиенткий код p_count=1 --Размер позиции p_spread=100 --Проскальзывание p_sell_level_zigzag=30 --уровень при котором продаем p_buy_level_zigzag=30 --уровень при котором покупаем p_svech=30 p_n=1
is_run = true count = 0
function main() while is_run do sleep(100) robot() end end
function robot() local N1=getNumCandles(«RIM6-Fractals») local N=getNumCandles(«MyPrice-RIM6»)
--надо перебрать верхние и нижние фракталы.и больше меньше
for i=1,p_svech-1 do
t1,n1,i1=getCandlesByIndex(«RIM6-Fractals», 0, N1-i, 1)--(«RSI-1», 0, N1-p_svech, 2) t,n,i=getCandlesByIndex(«MyPrice-RIM6», 0, N-1, 1)
message(«MyPrice-RIM6: »..t[0].close,1)
if t1[0].high>t[0].close then --p_svech=p_svech-1
if t[0].close<t1[0].high-p_sell_level_zigzag then Trade(«S»,count+p_count,t[0].close-p_spread) end if t[0].close>t1[0].high+p_buy_level_zigzag then Trade(«B»,count+p_count,t[0].close+p_spread) end
p_n=p_n+1 message(«свеча верх фрактал: »..p_n,1) message(«RIM6-Fractals-high: »..t1[0].high,1)
break end
if t1[0].low>t[0].close then
if t[0].close<t1[0].low-p_sell_level_zigzag then Trade(«S»,count+p_count,t[0].close-p_spread) end if t[0].close>t1[0].low+p_buy_level_zigzag then Trade(«B»,p_count-count,t[0].close+p_spread) end p_n=p_n+1 message(«свеча нижн фрактал: »..p_n,1) message(«RIM6-Fractals-low: »..t1[0].low,1) break end end
end
function Trade(a_oper,a_count,a_price) if a_count>0 then t = { [«CLASSCODE»]=p_classcode, [«SECCODE»]=p_seccode, [«ACTION»]=«NEW_ORDER», [«ACCOUNT»]=p_account, [«CLIENT_CODE»]=p_clientcode, [«TYPE»]=«L», [«OPERATION»]=a_oper, [«QUANTITY»]=tostring(a_count), [«PRICE»]=tostring(a_price), [«EXPIRY_DATE»]=«TODAY», [«TRANS_ID»]=«1» } res=sendTransaction(t) message(«Количество до »..tostring(count).." количество сделки "..tostring(a_count).." тип операции"..a_oper,1) if a_oper==«B» then count=count+a_count else count=count-a_count end message(«Количество после »..tostring(count),1) end end
function OnStop(stop_flag) is_run=false stop_flag=1--УБРАТЬ ЗА ТИРЕ end
можно сделать любой индикатор. фрактал не получается.
индикаторы мацд.рси.параболик.средние.идеально срабатывают.
в принципе роботы сливают".
средние.