deimosaffair

BarUpDn time limited

3676 görüntülenme
70
trying to understand strategies, it appears that there is a lot of black magic in how a strat works behind the scenes.
anyway, it's hard to analyse what's all the data with one gazillion entries, and i wanted to know how we can manipulate/do stuff with a chart.

so, i needed to know how to "give" the script my values to work on. bundled two wants/needs into one, and created a script that only applies a strategy from the date given onwards.

how to use:
at the chart, go to the "format" little button, then the input tab, and there is all the date fields i created. fun to set it to the current date, then start going backwards and see all the little arrows filing up the chart :)
Açık kaynak kodlu komut dosyası

Gerçek TradingView ruhuyla, bu komut dosyasının yazarı açık kaynak olarak yayınladı, böylece yatırımcılar bunu anlayabilir ve doğrulayabilir. Yazara tebrikler! Ücretsiz olarak kullanabilirsiniz, ancak bu kodun bir yayında yeniden kullanımı Kullanım Koşulları tarafından belirlenmektedir. Bir grafikte kullanmak için favorilerinize ekleyebilirsiniz.

Bu komut dosyasını bir grafikte kullanmak ister misiniz?
//@version=2
strategy("BarUpDn time limited", overlay=true, default_qty_type = strategy.percent_of_equity, default_qty_value = 10)

//input boxes for the limit date
yearLimit = input(2016,title="year") 
monthLimit = input(1, title="month")
dayLimit = input(1, title="day")

//function that checks if the current date is more recent than the limit
dateOk(yl,ml,dl) =>
    ok = (year < yl) ? false : (yl == year and month < ml ) ? false : (yl == year and ml == month and dayofmonth < dl) ? false : true
    ok
    
    
//applies dumb prebuilt strat limited to the date
if (dateOk(yearLimit,monthLimit,dayLimit) and (close > open and open > close[1]) )
    strategy.entry("BarDn", strategy.short)
if (dateOk(yearLimit,monthLimit,dayLimit) and (close < open and open < close[1]) )
    strategy.entry("BarUp", strategy.long)

Yorumlar

How exactly does this strategy make an entry decision? Is it based on gapping? Because surely the open should be equal to the previous candles close price?
Cevap Gönder
@DomHall, not important, i was just fooling with strategy syntax, got one of the builtin examples, and the conditions prety much make no sense. you could try close > close, just to make the strat fire. as it says in the comments //applies dumb prebuilt strat limited to the date

the point was to make a strategy start from the date i choose, not from the first bar. but then again, this thing has 60% correct hits, and it's turning a profit, so it lloks like i done a "killer strat" just by pure chance :D
Cevap Gönder
DomHall deimosaffair
Okay, cool. The other way to do it is to write:

is_date_valid = time > timestamp(2016, 09 , 11, 0, 1)
if is_date_valid and (close > open and open > close) )
strategy.entry("BarUp", strategy.long)

Just another way that someone taught me. It's annoying that the strategy tester maxes out at 2000!
Cevap Gönder
hey, thanks for the timestamp tip, makes it more clear :)

and btw, what's that 2000 you refer? it's bars, trades, somethign else?
Cevap Gönder
DomHall deimosaffair
No worries. Yeah, at the moment if you have a strategy that gives more than 2000 trade signals in any given period it won't allow you to test it. But using the timestamp feature resolves this anyway! You only need around 100 trades to know if a strategy is in any way good.
Cevap Gönder
ntradeden deimosaffair
@deimosaffair, applying the same strategy in python is not yielding the same result.
Cevap Gönder
Ana Sayfa Hisse Senedi Takipçisi Forex Takipçisi Kripto Takipçisi Ekonomik Takvim Hakkında Grafik Özellikleri Ücretlendirme Tanıdık yönlendirme Kurallarımız Destek Merkezi Web Sitesi & Aracı Kurum Çözümleri Görsel Bileşenler(Widget) Grafik Çözümleri Hafif Grafik Kitaplığı Blog ve Haberler Twitter