{"id":2778,"date":"2022-07-01T07:48:00","date_gmt":"2022-07-01T07:48:00","guid":{"rendered":"https:\/\/www.overcharts.com\/it\/helpcenter\/?post_type=docs&#038;p=2778"},"modified":"2022-08-05T13:30:38","modified_gmt":"2022-08-05T13:30:38","password":"","slug":"overbasic-function","status":"publish","type":"docs","link":"https:\/\/www.overcharts.com\/it\/helpcenter\/docs\/overbasic-function\/","title":{"rendered":"Overbasic &#8211; Function"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Una funzione \u00e8 una sequenza di istruzioni OverBasic racchiuse tra le parole chiave <strong><em>Function<\/em><\/strong> e <em><strong>EndFunction.<\/strong><\/em> Il compito di una funzione \u00e8 <strong>eseguire delle operazioni<\/strong> e <strong>restituire un risultato<\/strong>. Il risultato \u00e8 restituito alla funzione chiamante mediante la parola chiave <strong><a href=\"https:\/\/www.overcharts.com\/it\/helpcenter\/docs\/overbasic-return\/\" target=\"_blank\" rel=\"noreferrer noopener\">RETURN<\/a><\/strong>.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>L&#8217;esecuzione della funzione terminer\u00e0 al primo RETURN incontrato, oppure al primo errore NON correttamente gestito (vedi gestione degli errori <strong><em>Try..Catch<\/em><\/strong>).<\/p><\/blockquote>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Sintassi<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code><strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Function<\/mark><\/strong> &lt;nome funzione> (&#91;<strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">ref<\/mark><\/strong>] &lt;nome argomento1> <strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-primary-color\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-primary-color\"><strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\"><strong>As<\/strong><\/mark><\/strong><\/mark><\/mark><\/strong> &lt;tipo argomento1>, &#91;<strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">ref<\/mark><\/strong>] &lt;nome argomento2> <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-primary-color\"><strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\"><strong>As<\/strong><\/mark><\/strong><\/mark> &lt;tipo argomento2>, ...) <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-primary-color\"><strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\"><strong>As<\/strong><\/mark><\/strong><\/mark> &lt;tipo di risultato>&#91;()]\n    ...\n    &lt;istruzioni>\n    ...\n    <strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Return<\/mark><\/strong> &lt;espressione>\n<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-primary-color\"><strong><strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">EndFunction<\/mark><\/strong><\/strong><\/mark><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Una funzione inizia con la parola chiave <strong><em>Function<\/em><\/strong> e termina con la parola chiave <strong><em>EndFunction<\/em><\/strong>.<br>Nella prima riga della funzione, <strong>subito dopo<\/strong> la parola chiave <strong>Function<\/strong>, \u00e8 definito il <strong>nome della funzione<\/strong>.<br>Successivamente, nella stessa riga, vengono definiti gli <strong>eventuali argomenti<\/strong> e il <strong>tipo di risultato<\/strong> della funzione.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Esempio<\/strong>:<br>Nell&#8217;esempio qui sotto, la funzione <strong>CalculateABS<\/strong> calcola il valore assoluto dell&#8217;argomento <strong>n1<\/strong> e ne restituisce il risultato:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-primary-color\"><strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Function<\/mark><\/strong><\/mark><\/strong> CalculateABS(n1 <mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\"><strong>As<\/strong> <strong>Numeric<\/strong><\/mark>) <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-primary-color\"><strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\"><strong>As<\/strong> <strong>Numeric<\/strong><\/mark><\/strong><\/mark>\n    <strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">If<\/mark><\/strong> (n1 &lt; 0) <strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Then<\/mark><\/strong>\n        <strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-primary-color\"><strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Return<\/mark><\/strong><\/mark><\/strong> -1 * n1\n    <strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">EndIf<\/mark><\/strong>\n    <strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-primary-color\"><strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Return<\/mark><\/strong><\/mark><\/strong> n1\n<strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-primary-color\"><strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">EndFunction<\/mark><\/strong><\/mark><\/strong><\/code><\/pre>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Argomenti<\/strong><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Gli argomenti sono dei parametri (<strong><em>facoltativi<\/em><\/strong>) passati alla funzione per influenzarne il comportamento.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Un argomento \u00e8 definito mediante la sintassi:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-primary-color\"><strong><strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">ref<\/mark><\/strong><\/strong><\/mark>] &lt;nome argomento> <strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">As<\/mark><\/strong> &lt;tipo argomento>&#91;()]<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Ogni <em>argomento<\/em> \u00e8 <em>definito da un nome e da un tipo<\/em>. Nell&#8217;esempio qui sotto, <em>value<\/em> \u00e8 il nome dell&#8217;argomento e <em>Numeric<\/em> \u00e8 il tipo:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-primary-color\"><strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Function<\/mark><\/strong><\/mark><\/strong> DoSomething(value <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-primary-color\"><strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\"><strong>As<\/strong> <strong>Numeric<\/strong><\/mark><\/strong><\/mark>) <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-primary-color\"><strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\"><strong>As<\/strong> <strong>Numeric<\/strong><\/mark><\/strong><\/mark><\/code><\/pre>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Array<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Per definire un argomento come <strong><em>array<\/em><\/strong> \u00e8 sufficiente aggiungere le parentesi tonde subito dopo il tipo argomento:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Argument1 <strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-primary-color\"><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\"><strong>As<\/strong> <strong>Numeric<\/strong><\/mark><\/mark>()<\/strong><\/code><\/pre>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Passare un argomento per Riferimento (ref)<\/strong><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Per default, tutti gli argomenti di una funzione sono passati <strong><em>per Valore<\/em><\/strong>, cio\u00e8 nel caso in cui il valore dell&#8217;argomento sia modificato all&#8217;interno della funzione, la modifica NON si rifletter\u00e0 nella funzione chiamante.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Inserendo la parola chiave <strong><em>ref<\/em><\/strong> prima del nome dell&#8217;argomento, l&#8217;argomento verr\u00e0 passato alla funzione <strong><em>per Riferimento<\/em><\/strong>. In questo caso, modificando il valore dell&#8217;argomento all&#8217;interno della funzione, la modifica di rifletter\u00e0 anche nella funzione chiamante:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-primary-color\"><strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Function<\/mark><\/strong><\/mark><\/strong> DoSomething(<strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-primary-color\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-primary-color\"><strong><strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">ref<\/mark><\/strong><\/strong><\/mark><\/mark><\/strong> value <strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-primary-color\"><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\"><strong>As<\/strong> <strong>Numeric<\/strong><\/mark><\/mark><\/strong>) <strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-primary-color\"><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\"><strong>As<\/strong> <strong>Numeric<\/strong><\/mark><\/mark><\/strong>\n    value = 12\n    <strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-primary-color\"><strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Return<\/mark><\/strong><\/mark><\/strong> 10 * 5\n<strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">EndFunction<\/mark><\/strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-primary-color\"><strong>\n<\/strong><\/mark>\n<mark style=\"background-color:rgba(0, 0, 0, 0);color:#3fad1d\" class=\"has-inline-color\">e nella funzione chiamante:<\/mark><mark style=\"background-color:rgba(0, 0, 0, 0);color:#258508\" class=\"has-inline-color\">\n<\/mark>\n...\n...\n<strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Dim<\/mark><\/strong> a1 <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-primary-color\"><strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\"><strong>As<\/strong> <strong>Numeric<\/strong><\/mark><\/strong><\/mark> = 10\n<strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-primary-color\"><strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Dim<\/mark><\/strong><\/mark><\/strong> result <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-primary-color\"><strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\"><strong>As<\/strong> <strong>Numeric<\/strong><\/mark><\/strong><\/mark> = DoSomething(a1)\n...\n...\n\n<mark style=\"background-color:rgba(0, 0, 0, 0);color:#3fad1d\" class=\"has-inline-color\">Il valore di <strong><em>a1<\/em><\/strong> dopo l'esecuzione della funzione DoSomething sar\u00e0 <strong><em>12<\/em><\/strong>.<\/mark><\/code><\/pre>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Avvertenze su argomenti Array:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Una modifica al valore degli <em><strong>elementi<\/strong><\/em> di un argomento <strong>array<\/strong> si rifletter\u00e0 <strong>SEMPRE<\/strong> nella funzione chiamante anche se l&#8217;array NON \u00e8 passato per riferimento (<em>a patto per\u00f2 che l&#8217;array sia stato usato almeno una volta prima di essere passato alla funzione<\/em>):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-primary-color\"><strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Function<\/mark><\/strong><\/mark><\/strong> DoSomething(<strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-primary-color\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-primary-color\"><strong><strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">ref<\/mark><\/strong><\/strong><\/mark><\/mark><\/strong> a1 <strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-primary-color\"><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\"><strong>As<\/strong> <strong>Numeric<\/strong><\/mark><\/mark><\/strong>()) <strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-primary-color\"><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\"><strong>As<\/strong> <strong>Numeric<\/strong><\/mark><\/mark><\/strong>\n    a1(5) = 10\n    <strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-primary-color\"><strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Return<\/mark><\/strong><\/mark><\/strong> 1\n<strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">EndFunction<\/mark><\/strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-primary-color\"><strong>\n<\/strong><\/mark>\n<mark style=\"background-color:rgba(0, 0, 0, 0);color:#3fad1d\" class=\"has-inline-color\">e nella funzione chiamante:<\/mark><mark style=\"background-color:rgba(0, 0, 0, 0);color:#258508\" class=\"has-inline-color\">\n<\/mark>\n...\n...\n<strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-primary-color\"><strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Dim<\/mark><\/strong><\/mark><\/strong> a1 <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-primary-color\"><strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\"><strong>As<\/strong> <strong>Numeric<\/strong><\/mark><\/strong><\/mark>()\n\n<mark style=\"background-color:rgba(0, 0, 0, 0);color:#3fad1d\" class=\"has-inline-color\">Usiamo l'array almeno una volta prima di passarlo alla funzione<\/mark>\na1(2) = 3\n\n<strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-primary-color\"><strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Dim<\/mark><\/strong><\/mark><\/strong> result <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-primary-color\"><strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\"><strong>As<\/strong> <strong>Numeric<\/strong><\/mark><\/strong><\/mark> = DoSomething(a1)\n...\n...\n\n<mark style=\"background-color:rgba(0, 0, 0, 0);color:#3fad1d\" class=\"has-inline-color\">Il valore dell'elemento <em>5<\/em> dell'array <strong><em>a1<\/em><\/strong> dopo l'esecuzione della funzione DoSomething sar\u00e0 <strong><em>10<\/em><\/strong>.<\/mark><\/code><\/pre>\n\n\n\n<div style=\"height:40px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Risultato<\/strong><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Una funzione deve <strong>sempre<\/strong> restituire un risultato. Il tipo di risultato \u00e8 definito nella prima riga della funzione. Nell&#8217;esempio qui sotto il tipo risultato \u00e8 <strong><em>Numeric<\/em><\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-primary-color\"><strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Function<\/mark><\/strong><\/mark><\/strong> DoSomething() <strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-primary-color\"><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\"><strong>As<\/strong> <strong>Numeric<\/strong><\/mark><\/mark><\/strong><\/code><\/pre>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Per definire il risultato di una funzione come <strong><em>array<\/em><\/strong> \u00e8 sufficiente aggiungere le parentesi tonde subito dopo il tipo risultato:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-primary-color\"><strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Function<\/mark><\/strong><\/mark><\/strong> DoSomething() <strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-primary-color\"><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\"><strong>As<\/strong> <strong>Numeric<\/strong><\/mark><\/mark><\/strong>()<\/code><\/pre>\n\n\n\n<div style=\"height:60px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Funzione Main<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">In Overbasic esiste una funzione speciale denominata <strong><em>Main<\/em><\/strong>. La funzione Main \u00e8 la <strong>funzione principale dello script<\/strong> Overbasic. In altre parole, \u00e8 la funzione da dove inizia l&#8217;esecuzione dello script.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-primary-color\"><strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Function<\/mark><\/strong><\/mark><\/strong> <strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Main<\/mark><\/strong>()<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">La funzione Main non ha argomenti e nemmeno un tipo risultato definito. Il risultato infatti dipende dal tipo di script. Se lo script \u00e8 un indicatore, il risultato sar\u00e0 di tipo <strong><em>Numeric<\/em><\/strong>, se Trading System sar\u00e0 di tipo <strong><em>Boolean<\/em><\/strong>. Per maggiori informazioni vedi la documentazione relativa agli indicatori utente e trading system.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>La funzione Main viene chiamata automaticamente da Overcharts ogni volta che viene eseguito lo script. Per esempio, nel calcolo di un indicatore, lo script viene eseguito per ogni barra presente nel grafico di riferimento. Se il grafico di riferimento dell&#8217;indicatore contiene 100 barre, lo script verr\u00e0 eseguito 100 volte. L&#8217;esecuzione avverr\u00e0 anche ad ogni aggiornamento dati real time.<\/p><\/blockquote>\n\n\n\n<div style=\"height:60px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Una funzione \u00e8 una sequenza di istruzioni OverBasic racchiuse tra le parole chiave Function e EndFunction. Il compito di una funzione \u00e8 eseguire delle operazioni e restituire un risultato. Il risultato \u00e8 restituito alla funzione chiamante mediante la parola chiave RETURN. L&#8217;esecuzione della funzione terminer\u00e0 al primo RETURN incontrato, oppure al primo errore NON correttamente [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"doc_category":[14],"doc_tag":[],"class_list":["post-2778","docs","type-docs","status-publish","hentry","doc_category-sintassi-parole-chiave"],"year_month":"2026-10","word_count":640,"total_views":"1","reactions":{"happy":"0","normal":"0","sad":"0"},"author_info":{"name":"Overcharts Team","author_nicename":"overadmin","author_url":"https:\/\/www.overcharts.com\/it\/helpcenter\/author\/overadmin\/"},"doc_category_info":[{"term_name":"Sintassi &amp; Parole Chiave","term_url":"https:\/\/www.overcharts.com\/it\/helpcenter\/docs-category\/sintassi-parole-chiave\/"}],"doc_tag_info":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\r\n<title>Overbasic - Function - Overcharts Help Center<\/title>\r\n<meta name=\"description\" content=\"Una funzione \u00e8 una sequenza di istruzioni OverBasic racchiuse tra le parole chiave Function e EndFunction.\" \/>\r\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\r\n<link rel=\"canonical\" href=\"https:\/\/www.overcharts.com\/it\/helpcenter\/docs\/overbasic-function\/\" \/>\r\n<meta property=\"og:locale\" content=\"it_IT\" \/>\r\n<meta property=\"og:type\" content=\"article\" \/>\r\n<meta property=\"og:title\" content=\"Overbasic - Function - Overcharts Help Center\" \/>\r\n<meta property=\"og:description\" content=\"Una funzione \u00e8 una sequenza di istruzioni OverBasic racchiuse tra le parole chiave Function e EndFunction.\" \/>\r\n<meta property=\"og:url\" content=\"https:\/\/www.overcharts.com\/it\/helpcenter\/docs\/overbasic-function\/\" \/>\r\n<meta property=\"og:site_name\" content=\"Overcharts Help Center\" \/>\r\n<meta property=\"article:modified_time\" content=\"2022-08-05T13:30:38+00:00\" \/>\r\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\r\n<meta name=\"twitter:label1\" content=\"Tempo di lettura stimato\" \/>\n\t<meta name=\"twitter:data1\" content=\"4 minuti\" \/>\r\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.overcharts.com\\\/it\\\/helpcenter\\\/docs\\\/overbasic-function\\\/\",\"url\":\"https:\\\/\\\/www.overcharts.com\\\/it\\\/helpcenter\\\/docs\\\/overbasic-function\\\/\",\"name\":\"Overbasic - Function - Overcharts Help Center\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.overcharts.com\\\/it\\\/helpcenter\\\/#website\"},\"datePublished\":\"2022-07-01T07:48:00+00:00\",\"dateModified\":\"2022-08-05T13:30:38+00:00\",\"description\":\"Una funzione \u00e8 una sequenza di istruzioni OverBasic racchiuse tra le parole chiave Function e EndFunction.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.overcharts.com\\\/it\\\/helpcenter\\\/docs\\\/overbasic-function\\\/#breadcrumb\"},\"inLanguage\":\"it-IT\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.overcharts.com\\\/it\\\/helpcenter\\\/docs\\\/overbasic-function\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.overcharts.com\\\/it\\\/helpcenter\\\/docs\\\/overbasic-function\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.overcharts.com\\\/it\\\/helpcenter\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Overbasic &#8211; Function\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.overcharts.com\\\/it\\\/helpcenter\\\/#website\",\"url\":\"https:\\\/\\\/www.overcharts.com\\\/it\\\/helpcenter\\\/\",\"name\":\"Overcharts Help Center\",\"description\":\"Piattaforma di Trading e Analisi Tecnica\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.overcharts.com\\\/it\\\/helpcenter\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"it-IT\"}]}<\/script>\r\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Overbasic - Function - Overcharts Help Center","description":"Una funzione \u00e8 una sequenza di istruzioni OverBasic racchiuse tra le parole chiave Function e EndFunction.","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:\/\/www.overcharts.com\/it\/helpcenter\/docs\/overbasic-function\/","og_locale":"it_IT","og_type":"article","og_title":"Overbasic - Function - Overcharts Help Center","og_description":"Una funzione \u00e8 una sequenza di istruzioni OverBasic racchiuse tra le parole chiave Function e EndFunction.","og_url":"https:\/\/www.overcharts.com\/it\/helpcenter\/docs\/overbasic-function\/","og_site_name":"Overcharts Help Center","article_modified_time":"2022-08-05T13:30:38+00:00","twitter_card":"summary_large_image","twitter_misc":{"Tempo di lettura stimato":"4 minuti"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.overcharts.com\/it\/helpcenter\/docs\/overbasic-function\/","url":"https:\/\/www.overcharts.com\/it\/helpcenter\/docs\/overbasic-function\/","name":"Overbasic - Function - Overcharts Help Center","isPartOf":{"@id":"https:\/\/www.overcharts.com\/it\/helpcenter\/#website"},"datePublished":"2022-07-01T07:48:00+00:00","dateModified":"2022-08-05T13:30:38+00:00","description":"Una funzione \u00e8 una sequenza di istruzioni OverBasic racchiuse tra le parole chiave Function e EndFunction.","breadcrumb":{"@id":"https:\/\/www.overcharts.com\/it\/helpcenter\/docs\/overbasic-function\/#breadcrumb"},"inLanguage":"it-IT","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.overcharts.com\/it\/helpcenter\/docs\/overbasic-function\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.overcharts.com\/it\/helpcenter\/docs\/overbasic-function\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.overcharts.com\/it\/helpcenter\/"},{"@type":"ListItem","position":2,"name":"Overbasic &#8211; Function"}]},{"@type":"WebSite","@id":"https:\/\/www.overcharts.com\/it\/helpcenter\/#website","url":"https:\/\/www.overcharts.com\/it\/helpcenter\/","name":"Overcharts Help Center","description":"Piattaforma di Trading e Analisi Tecnica","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.overcharts.com\/it\/helpcenter\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"it-IT"}]}},"_links":{"self":[{"href":"https:\/\/www.overcharts.com\/it\/helpcenter\/wp-json\/wp\/v2\/docs\/2778","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.overcharts.com\/it\/helpcenter\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/www.overcharts.com\/it\/helpcenter\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/www.overcharts.com\/it\/helpcenter\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.overcharts.com\/it\/helpcenter\/wp-json\/wp\/v2\/comments?post=2778"}],"version-history":[{"count":19,"href":"https:\/\/www.overcharts.com\/it\/helpcenter\/wp-json\/wp\/v2\/docs\/2778\/revisions"}],"predecessor-version":[{"id":2947,"href":"https:\/\/www.overcharts.com\/it\/helpcenter\/wp-json\/wp\/v2\/docs\/2778\/revisions\/2947"}],"wp:attachment":[{"href":"https:\/\/www.overcharts.com\/it\/helpcenter\/wp-json\/wp\/v2\/media?parent=2778"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/www.overcharts.com\/it\/helpcenter\/wp-json\/wp\/v2\/doc_category?post=2778"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/www.overcharts.com\/it\/helpcenter\/wp-json\/wp\/v2\/doc_tag?post=2778"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}