NexusFi: Find Your Edge


Home Menu

 





arima model


Discussion in MultiCharts

Updated
    1. trending_up 1,076 views
    2. thumb_up 0 thanks given
    3. group 2 followers
    1. forum 1 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
tsxela
modena italy
 
Posts: 2 since Jul 2014
Thanks Given: 1
Thanks Received: 0

i generated with chatgpt a code of arima model, can someone help me to correct the code?
thank you in advance

{*******************************************************************
ARIMA Function for MultiCharts

*******************************************************************}

inputs:
TimeSeries(close),
p(2),
dd(1),
q(2);

vars:
ii(0),
j(0),
k(0),
n(0),
m(0),
s(0),
phi(0),
theta(0),
diff(0),
resid(0),
std_dev(0),
sum_phi(0),
sum_theta(0),
sum_diff(0),
sum_resid(0),
sum_std_dev(0),
forecast(0),
error(0),
sum_forecast(0);

{Calculate phi and theta}
for ii = 1 to p begin
phi[ii] = 0;
end;

for ii = 1 to q begin
theta[ii] = 0;
end;

for ii = 1 to p begin
sum_phi = 0;
for j = ii to n begin
sum_phi = sum_phi + TimeSeries[j-dd] * TimeSeries[j-ii-dd];
end;
phi[ii] = sum_phi;
end;

for ii = 1 to q begin
sum_theta = 0;
for j = ii to n begin
sum_theta = sum_theta + resid[j-1] * TimeSeries[j-ii-dd];
end;
theta[ii] = sum_theta;
end;

{Calculate differences}
for ii = 1 to dd begin
diff[ii] = 0;
end;

for ii = dd+1 to n begin
diff[ii] = TimeSeries[ii] - TimeSeries[ii-dd];
end;

{Calculate residuals}
for ii = 1 to n begin
resid[ii] = 0;
end;

for ii = p+1 to n begin
sum_diff = 0;
sum_phi = 0;
sum_theta = 0;
for j = 1 to p begin
sum_phi = sum_phi + phi[j] * diff[ii-j];
end;
for j = 1 to q begin
sum_theta = sum_theta + theta[j] * resid[ii-j];
end;
resid[ii] = diff[ii] - sum_phi - sum_theta;
end;

{Calculate standard deviation}
for ii = 1 to n begin
std_dev[ii] = 0;
end;

for ii = p+1 to n begin
sum_resid = 0;
for j = 1 to p begin
sum_resid = sum_resid + phi[j] * diff[ii-j];
end;
for j = 1 to q begin
sum_resid = sum_resid + theta[j] * resid[ii-j];
end;
std_dev[ii] = sqrt(sum_resid * sum_resid / (n-p-q));
end;

{Calculate forecast}
for ii = n+1 to n+m begin
forecast[ii] = 0;
end;

for ii = n+1 to n+m begin
sum_forecast = 0;
for j = 1 to p begin
sum_forecast = sum_forecast + phi[j] * (TimeSeries[n-j+1] - TimeSeries[n-j+1-d]);
end;
for j = 1 to q begin
sum_forecast = sum_forecast + theta[j] * resid[n-j+1];
end;
forecast[ii] = TimeSeries[n] + sum_forecast;
end;

{Calculate error}
for ii = n+1 to n+m begin
error[ii] = 0;
end;

for ii = n+1 to n+m begin
error[i] = forecast[ii] - TimeSeries[n+ii-n-dd];
end;


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
requesting .nrd replay files from 2026 spy and qqq
The Elite Circle
Datafeed for Atas
Platforms and Indicators
Trump Media to sell instant access to market-moving soci …
Traders Hideout
EA
Platforms and Indicators
No book, only a stair: journaling fills where price move …
Cryptocurrency
 
  #2 (permalink)
artisanpro
montreal, qc, canada
 
Posts: 28 since May 2021
Thanks Given: 28
Thanks Received: 18


tsxela View Post
i generated with chatgpt a code of arima model, can someone help me to correct the code?
thank you in advance end;

May I suggest that instead of asking to make this work that you ask instead: Has anyone used an arima model successfully and, if so, could you share the code.

Getting back to the chatgpt code that you provided: what sort of compilation errors did you receive?


Reply With Quote




Last Updated on April 29, 2023


© 2026 NexusFi®, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Downloads - Top
no new posts