{"id":3469,"date":"2018-02-23T13:55:35","date_gmt":"2018-02-23T13:55:35","guid":{"rendered":"http:\/\/joapen.com\/blog\/?p=3469"},"modified":"2018-02-23T13:55:36","modified_gmt":"2018-02-23T13:55:36","slug":"trading-view-pine-editor-hello-world","status":"publish","type":"post","link":"https:\/\/joapen.com\/blog\/2018\/02\/23\/trading-view-pine-editor-hello-world\/","title":{"rendered":"Trading view Pine Editor, hello world"},"content":{"rendered":"<p>Reading the book Machine Trading from Ernie P. Chang, on the first chapter it offers different oppinions about environments to gather historical data, do backtesting&#8230;<\/p>\n<p>I started to analyze which one of the solutions was better to cover the whole picture proposed in the book. My analysis was basically to compare Tradingview and Ninja Trader.<\/p>\n<p>I started to evaluate Quantopian, as it covers backtesting and the environment to develop is Perl on Notebook (which I am familar with), but I discarded it.<\/p>\n<p><a href=\"http:\/\/joapen.com\/blog\/2018\/02\/23\/trading-view-pine-editor-hello-world\/tradingmachine-diagram-ernst-chang\/\" rel=\"attachment wp-att-3470\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3470\" src=\"http:\/\/joapen.com\/blog\/wp-content\/uploads\/2018\/02\/TradingMachine-diagram-Ernst-Chang.jpg\" alt=\"\" width=\"815\" height=\"413\" srcset=\"https:\/\/joapen.com\/blog\/wp-content\/uploads\/2018\/02\/TradingMachine-diagram-Ernst-Chang.jpg 815w, https:\/\/joapen.com\/blog\/wp-content\/uploads\/2018\/02\/TradingMachine-diagram-Ernst-Chang-300x152.jpg 300w, https:\/\/joapen.com\/blog\/wp-content\/uploads\/2018\/02\/TradingMachine-diagram-Ernst-Chang-768x389.jpg 768w, https:\/\/joapen.com\/blog\/wp-content\/uploads\/2018\/02\/TradingMachine-diagram-Ernst-Chang-500x253.jpg 500w\" sizes=\"auto, (max-width: 815px) 100vw, 815px\" \/><\/a><\/p>\n<p>As conclusion, for my initial steps on backtesting I have selected Tradingview as tool to start building backtests scripts.<\/p>\n<p>This one is the first one. It combines a simple strategy between RSI and MACD.<\/p>\n<p>\/\/@version=3<br \/>\n<span style=\"color: #0000ff;\">strategy(&#8220;Test-1 RSI&#8221;, overlay=true, initial_capital=1000, currency=&#8217;USD&#8217;)<\/span><br \/>\n\/\/\/\/\/\/\/\/\/\/\/ inputs \/\/\/\/\/\/\/\/\/\/<br \/>\n\/\/ RSI<br \/>\n<span style=\"color: #0000ff;\">Length = input(14, minval=1)<\/span><br \/>\n<span style=\"color: #0000ff;\">Oversold = input(25, minval=1)<\/span><br \/>\n<span style=\"color: #0000ff;\">Overbought = input(70, minval=1)<\/span><br \/>\n\/\/ MACD<br \/>\n<span style=\"color: #0000ff;\">fastLength = input(12)<\/span><br \/>\n<span style=\"color: #0000ff;\">slowlength = input(26)<\/span><br \/>\n<span style=\"color: #0000ff;\">MACDLength = input(9)<\/span><br \/>\n\/\/\/\/\/\/\/\/\/\/\/ individual long conditions \/\/\/\/\/\/\/\/\/\/<br \/>\n\/\/ RSI<br \/>\n<span style=\"color: #0000ff;\">rsiLongCondition = rsi(close, Length) &lt; Oversold<\/span><br \/>\n\/\/ MACD<br \/>\n<span style=\"color: #0000ff;\">MACD = ema(close, fastLength) &#8211; ema(close, slowlength)<\/span><br \/>\n<span style=\"color: #0000ff;\">aMACD = ema(MACD, MACDLength)<\/span><br \/>\n<span style=\"color: #0000ff;\">macdDelta = MACD &#8211; aMACD<\/span><br \/>\n<span style=\"color: #0000ff;\">macdLongCondition = crossover(macdDelta, 0)<\/span><br \/>\n\/\/\/\/\/\/\/\/\/\/\/ long condition \/\/\/\/\/\/\/\/\/\/<br \/>\n\/\/ RSI and MACD<br \/>\n<span style=\"color: #0000ff;\">if (rsiLongCondition and macdLongCondition)<\/span><br \/>\n<span style=\"color: #0000ff;\"> strategy.entry(&#8220;Long 1&#8221;, strategy.long)<\/span><br \/>\n\/\/\/\/\/\/\/\/\/\/\/ individual short conditions \/\/\/\/\/\/\/\/\/\/<br \/>\n\/\/ RSI<br \/>\n<span style=\"color: #0000ff;\">rsiShortCondition = rsi(close, Length) &gt; Overbought<\/span><br \/>\n\/\/ MACD<br \/>\nmacdShortCondition = crossunder(macdDelta, 0)<br \/>\n<span style=\"color: #000000;\">\/\/\/\/\/\/\/\/\/\/\/ short condition \/\/\/\/\/\/\/\/\/\/<\/span><br \/>\n<span style=\"color: #0000ff;\">if (macdShortCondition)<\/span><br \/>\n<span style=\"color: #0000ff;\"> strategy.close(&#8220;Short 1&#8221;)<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Reading the book Machine Trading from Ernie P. Chang, on the first chapter it offers different oppinions about environments to gather historical data, do backtesting&#8230; I started to analyze which one of the solutions was better to cover the whole picture proposed in the book. My analysis was basically to compare Tradingview and Ninja Trader. &#8230; <a title=\"Trading view Pine Editor, hello world\" class=\"read-more\" href=\"https:\/\/joapen.com\/blog\/2018\/02\/23\/trading-view-pine-editor-hello-world\/\" aria-label=\"Read more about Trading view Pine Editor, hello world\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[105],"tags":[],"class_list":["post-3469","post","type-post","status-publish","format-standard","hentry","category-trading"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Trading view Pine Editor, hello world -<\/title>\n<meta name=\"description\" content=\"Reading the book Machine Trading from Ernie P. Chang, on the first chapter it offers different oppinions about environments to gather historical data, do - joapen projects\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/joapen.com\/blog\/2018\/02\/23\/trading-view-pine-editor-hello-world\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Trading view Pine Editor, hello world -\" \/>\n<meta property=\"og:description\" content=\"Reading the book Machine Trading from Ernie P. Chang, on the first chapter it offers different oppinions about environments to gather historical data, do - joapen projects\" \/>\n<meta property=\"og:url\" content=\"https:\/\/joapen.com\/blog\/2018\/02\/23\/trading-view-pine-editor-hello-world\/\" \/>\n<meta property=\"og:site_name\" content=\"joapen projects\" \/>\n<meta property=\"article:published_time\" content=\"2018-02-23T13:55:35+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-02-23T13:55:36+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/joapen.com\/blog\/wp-content\/uploads\/2018\/02\/TradingMachine-diagram-Ernst-Chang.jpg\" \/>\n<meta name=\"author\" content=\"joapen\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"joapen\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/joapen.com\\\/blog\\\/2018\\\/02\\\/23\\\/trading-view-pine-editor-hello-world\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/joapen.com\\\/blog\\\/2018\\\/02\\\/23\\\/trading-view-pine-editor-hello-world\\\/\"},\"author\":{\"name\":\"joapen\",\"@id\":\"https:\\\/\\\/joapen.com\\\/blog\\\/#\\\/schema\\\/person\\\/23919df2312175fe9c4609203595b217\"},\"headline\":\"Trading view Pine Editor, hello world\",\"datePublished\":\"2018-02-23T13:55:35+00:00\",\"dateModified\":\"2018-02-23T13:55:36+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/joapen.com\\\/blog\\\/2018\\\/02\\\/23\\\/trading-view-pine-editor-hello-world\\\/\"},\"wordCount\":215,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/joapen.com\\\/blog\\\/#\\\/schema\\\/person\\\/23919df2312175fe9c4609203595b217\"},\"image\":{\"@id\":\"https:\\\/\\\/joapen.com\\\/blog\\\/2018\\\/02\\\/23\\\/trading-view-pine-editor-hello-world\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/joapen.com\\\/blog\\\/wp-content\\\/uploads\\\/2018\\\/02\\\/TradingMachine-diagram-Ernst-Chang.jpg\",\"articleSection\":[\"Trading\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/joapen.com\\\/blog\\\/2018\\\/02\\\/23\\\/trading-view-pine-editor-hello-world\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/joapen.com\\\/blog\\\/2018\\\/02\\\/23\\\/trading-view-pine-editor-hello-world\\\/\",\"url\":\"https:\\\/\\\/joapen.com\\\/blog\\\/2018\\\/02\\\/23\\\/trading-view-pine-editor-hello-world\\\/\",\"name\":\"Trading view Pine Editor, hello world -\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/joapen.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/joapen.com\\\/blog\\\/2018\\\/02\\\/23\\\/trading-view-pine-editor-hello-world\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/joapen.com\\\/blog\\\/2018\\\/02\\\/23\\\/trading-view-pine-editor-hello-world\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/joapen.com\\\/blog\\\/wp-content\\\/uploads\\\/2018\\\/02\\\/TradingMachine-diagram-Ernst-Chang.jpg\",\"datePublished\":\"2018-02-23T13:55:35+00:00\",\"dateModified\":\"2018-02-23T13:55:36+00:00\",\"description\":\"Reading the book Machine Trading from Ernie P. Chang, on the first chapter it offers different oppinions about environments to gather historical data, do - joapen projects\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/joapen.com\\\/blog\\\/2018\\\/02\\\/23\\\/trading-view-pine-editor-hello-world\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/joapen.com\\\/blog\\\/2018\\\/02\\\/23\\\/trading-view-pine-editor-hello-world\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/joapen.com\\\/blog\\\/2018\\\/02\\\/23\\\/trading-view-pine-editor-hello-world\\\/#primaryimage\",\"url\":\"https:\\\/\\\/joapen.com\\\/blog\\\/wp-content\\\/uploads\\\/2018\\\/02\\\/TradingMachine-diagram-Ernst-Chang.jpg\",\"contentUrl\":\"https:\\\/\\\/joapen.com\\\/blog\\\/wp-content\\\/uploads\\\/2018\\\/02\\\/TradingMachine-diagram-Ernst-Chang.jpg\",\"width\":815,\"height\":413},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/joapen.com\\\/blog\\\/2018\\\/02\\\/23\\\/trading-view-pine-editor-hello-world\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/joapen.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Trading view Pine Editor, hello world\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/joapen.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/joapen.com\\\/blog\\\/\",\"name\":\"joapen projects\",\"description\":\"Just a place to write\",\"publisher\":{\"@id\":\"https:\\\/\\\/joapen.com\\\/blog\\\/#\\\/schema\\\/person\\\/23919df2312175fe9c4609203595b217\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/joapen.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/joapen.com\\\/blog\\\/#\\\/schema\\\/person\\\/23919df2312175fe9c4609203595b217\",\"name\":\"joapen\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/joapen.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/04\\\/joapen-mini.jpeg\",\"url\":\"https:\\\/\\\/joapen.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/04\\\/joapen-mini.jpeg\",\"contentUrl\":\"https:\\\/\\\/joapen.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/04\\\/joapen-mini.jpeg\",\"width\":400,\"height\":400,\"caption\":\"joapen\"},\"logo\":{\"@id\":\"https:\\\/\\\/joapen.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/04\\\/joapen-mini.jpeg\"},\"sameAs\":[\"http:\\\/\\\/www.joapen.com\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Trading view Pine Editor, hello world -","description":"Reading the book Machine Trading from Ernie P. Chang, on the first chapter it offers different oppinions about environments to gather historical data, do - joapen projects","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/joapen.com\/blog\/2018\/02\/23\/trading-view-pine-editor-hello-world\/","og_locale":"en_US","og_type":"article","og_title":"Trading view Pine Editor, hello world -","og_description":"Reading the book Machine Trading from Ernie P. Chang, on the first chapter it offers different oppinions about environments to gather historical data, do - joapen projects","og_url":"https:\/\/joapen.com\/blog\/2018\/02\/23\/trading-view-pine-editor-hello-world\/","og_site_name":"joapen projects","article_published_time":"2018-02-23T13:55:35+00:00","article_modified_time":"2018-02-23T13:55:36+00:00","og_image":[{"url":"http:\/\/joapen.com\/blog\/wp-content\/uploads\/2018\/02\/TradingMachine-diagram-Ernst-Chang.jpg","type":"","width":"","height":""}],"author":"joapen","twitter_misc":{"Written by":"joapen","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/joapen.com\/blog\/2018\/02\/23\/trading-view-pine-editor-hello-world\/#article","isPartOf":{"@id":"https:\/\/joapen.com\/blog\/2018\/02\/23\/trading-view-pine-editor-hello-world\/"},"author":{"name":"joapen","@id":"https:\/\/joapen.com\/blog\/#\/schema\/person\/23919df2312175fe9c4609203595b217"},"headline":"Trading view Pine Editor, hello world","datePublished":"2018-02-23T13:55:35+00:00","dateModified":"2018-02-23T13:55:36+00:00","mainEntityOfPage":{"@id":"https:\/\/joapen.com\/blog\/2018\/02\/23\/trading-view-pine-editor-hello-world\/"},"wordCount":215,"commentCount":0,"publisher":{"@id":"https:\/\/joapen.com\/blog\/#\/schema\/person\/23919df2312175fe9c4609203595b217"},"image":{"@id":"https:\/\/joapen.com\/blog\/2018\/02\/23\/trading-view-pine-editor-hello-world\/#primaryimage"},"thumbnailUrl":"http:\/\/joapen.com\/blog\/wp-content\/uploads\/2018\/02\/TradingMachine-diagram-Ernst-Chang.jpg","articleSection":["Trading"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/joapen.com\/blog\/2018\/02\/23\/trading-view-pine-editor-hello-world\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/joapen.com\/blog\/2018\/02\/23\/trading-view-pine-editor-hello-world\/","url":"https:\/\/joapen.com\/blog\/2018\/02\/23\/trading-view-pine-editor-hello-world\/","name":"Trading view Pine Editor, hello world -","isPartOf":{"@id":"https:\/\/joapen.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/joapen.com\/blog\/2018\/02\/23\/trading-view-pine-editor-hello-world\/#primaryimage"},"image":{"@id":"https:\/\/joapen.com\/blog\/2018\/02\/23\/trading-view-pine-editor-hello-world\/#primaryimage"},"thumbnailUrl":"http:\/\/joapen.com\/blog\/wp-content\/uploads\/2018\/02\/TradingMachine-diagram-Ernst-Chang.jpg","datePublished":"2018-02-23T13:55:35+00:00","dateModified":"2018-02-23T13:55:36+00:00","description":"Reading the book Machine Trading from Ernie P. Chang, on the first chapter it offers different oppinions about environments to gather historical data, do - joapen projects","breadcrumb":{"@id":"https:\/\/joapen.com\/blog\/2018\/02\/23\/trading-view-pine-editor-hello-world\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/joapen.com\/blog\/2018\/02\/23\/trading-view-pine-editor-hello-world\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/joapen.com\/blog\/2018\/02\/23\/trading-view-pine-editor-hello-world\/#primaryimage","url":"https:\/\/joapen.com\/blog\/wp-content\/uploads\/2018\/02\/TradingMachine-diagram-Ernst-Chang.jpg","contentUrl":"https:\/\/joapen.com\/blog\/wp-content\/uploads\/2018\/02\/TradingMachine-diagram-Ernst-Chang.jpg","width":815,"height":413},{"@type":"BreadcrumbList","@id":"https:\/\/joapen.com\/blog\/2018\/02\/23\/trading-view-pine-editor-hello-world\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/joapen.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Trading view Pine Editor, hello world"}]},{"@type":"WebSite","@id":"https:\/\/joapen.com\/blog\/#website","url":"https:\/\/joapen.com\/blog\/","name":"joapen projects","description":"Just a place to write","publisher":{"@id":"https:\/\/joapen.com\/blog\/#\/schema\/person\/23919df2312175fe9c4609203595b217"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/joapen.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/joapen.com\/blog\/#\/schema\/person\/23919df2312175fe9c4609203595b217","name":"joapen","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/joapen.com\/blog\/wp-content\/uploads\/2021\/04\/joapen-mini.jpeg","url":"https:\/\/joapen.com\/blog\/wp-content\/uploads\/2021\/04\/joapen-mini.jpeg","contentUrl":"https:\/\/joapen.com\/blog\/wp-content\/uploads\/2021\/04\/joapen-mini.jpeg","width":400,"height":400,"caption":"joapen"},"logo":{"@id":"https:\/\/joapen.com\/blog\/wp-content\/uploads\/2021\/04\/joapen-mini.jpeg"},"sameAs":["http:\/\/www.joapen.com"]}]}},"_links":{"self":[{"href":"https:\/\/joapen.com\/blog\/wp-json\/wp\/v2\/posts\/3469","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/joapen.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/joapen.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/joapen.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/joapen.com\/blog\/wp-json\/wp\/v2\/comments?post=3469"}],"version-history":[{"count":2,"href":"https:\/\/joapen.com\/blog\/wp-json\/wp\/v2\/posts\/3469\/revisions"}],"predecessor-version":[{"id":3472,"href":"https:\/\/joapen.com\/blog\/wp-json\/wp\/v2\/posts\/3469\/revisions\/3472"}],"wp:attachment":[{"href":"https:\/\/joapen.com\/blog\/wp-json\/wp\/v2\/media?parent=3469"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/joapen.com\/blog\/wp-json\/wp\/v2\/categories?post=3469"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/joapen.com\/blog\/wp-json\/wp\/v2\/tags?post=3469"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}