کد زیر در پاین اسکریپت نوشته شده مشکل توی شرط زمانم دارم // This Pine Script™ code is…
- User
کد زیر در پاین اسکریپت نوشته شده مشکل توی شرط زمانم دارم // This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Amir_Hossein222
//@version=5 strategy("week test position", overlay=true)
profit_per = input.float(5,"Profit") stop_per = input.float(2,"Stop")
var all_list = array.new_float() time_frame_lowe = input.timeframe("1","time frame")
close_list = request.security(syminfo.tickerid,time_frame_lowe,close) low_list = request.security(syminfo.tickerid,time_frame_lowe,low) high_list = request.security(syminfo.tickerid,time_frame_lowe,high)
array.push(all_list,close_list) array.push(all_list,high_list) array.push(all_list,low_list)
longCondition = false shortCondition = false
for price_last in all_list
codeif ta.crossover(close[1],price_last) longCondition := true else if ta.crossunder(close[1],price_last) shortCondition := true else if ta.crossover(high[1],price_last) and (close[1] < price_last) shortCondition := true else if ta.crossunder(low[1],price_last) and (close[1] > price_last) longCondition := trueif timenow > input.time(timestamp("20 Jul 2021 00:00 +0300"), "Date") if (longCondition) // if strategy.position_size < 0 // strategy.close("CS") strategy.entry("Long", strategy.long) strategy.exit("LE", "Long",profit = (close + (profit_per * (close/100))), loss = (close - (stop_per * (close/100))))
codeif (shortCondition) // if strategy.position_size > 0 // strategy.close("CL") strategy.entry("Short", strategy.short) strategy.exit("SE", "Short",profit = (close - (profit_per * (close/100))), loss = (close + (stop_per * (close/100)))) - Assistant
در کد Pine Script شما، تعدادی مشکل وجود دارد که باید حل شوند. اولاً، شما مورد زمان را با استفاده از
timenowاشتباه گرفتید و باید ازtimeاستفاده کنید. دوماً، شما به طور مستقیم نمیتوانید آرایهای از نوعfloatبسازید و با قیمتها مقایسه کنید. در نهایت، از indexing به درستی استفاده نشده است.در اینجا نسخه بهبود یافتهای از کد شما آورده شده است: