millionchart
English

فراخوانی‌هایی که حالت نگه می‌دارند

بعضی فراخوانی‌ها آنچه را روی کندل‌های قبلی دیده‌اند به یاد می‌سپارند. این صفحه نشان می‌دهد این برای سشن‌ها و برای جای چنین فراخوانی‌ای چه معنایی دارد.

فراخوانی‌ای که حالت نگه می‌دارد (یک میانگین متحرک، یک درخواست، مقدار یک سشن) برای هر جایی که نوشته شده یک حالت جدا دارد، و این حالت وقتی جلو می‌رود که اجرا به همان جا برسد. تشخیص‌های E3302 و W3302 توضیح می‌دهند وقتی چنین فراخوانی‌ای جایی بنشیند که شاید اجرا نشود چه پیش می‌آید.

سقف‌های سشن#

سشن‌هایی با منطقهٔ زمانی و مقداری که با هر سشن از نو شروع می‌شود.

Cuprel
// A trading session is two times and a zone. `state session` keeps a value that restarts at the start of each session,
// so this draws the high of the London session so far, and the high of the New York session so far.
indicator "Session highs"
    edition = 1
    display = price

session london = 08:00 .. 16:30 @ "Europe/London"
session newyork = 09:30 .. 16:00 @ "America/New_York"
state session london london_high = high
state session newyork newyork_high = high
if london.active
    london_high = math.max(london_high, high)
if newyork.active
    newyork_high = math.max(newyork_high, high)
plot(london_high, name = "London high so far", color = color.green)
plot(newyork_high, name = "New York high so far", color = color.orange)

یک حالت برای هر فراخوانی#

یک تابع که دو بار صدا زده می‌شود: هر جای فراخوانی حالت خودش را نگه می‌دارد، و این با تفاضلی که دقیقاً صفر است نشان داده می‌شود.

Cuprel
// Every place where a call that keeps a state is written has a state of its own. smooth() is one function called twice, with two different series,
// and each call keeps its own running average: the difference to the same average written out directly is zero on every bar.
indicator "One state for each call"
    edition = 1
    display = pane

fn smooth(source: float, length: int): float = tech.ema(source, length)

let from_close = smooth(close, 10)
let from_open = smooth(open, 10)
plot(from_close - tech.ema(close, 10), name = "Close, function minus direct", color = color.green)
plot(from_open - tech.ema(open, 10), name = "Open, function minus direct", color = color.red)
plot(from_close - from_open, name = "Close average minus open average", color = color.gray)