I would like to see the annualized volatility on the chart, that is, a value, for example 15% on an instrument. I want to program it, any ideas?
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Volatilidad Anualizada
Collapse
X
-
Hello Gibranes,
Thank you for your post.
For general information on using NinjaScript to program custom scripts, please see the following post:To figure out how to calculate the annualized volatility, you will need to figure out what formula you would like to use. I found the following publicly available link, for example, that discusses calculating historical and annualized volatility in exel:
You could likely take that information, or information from other resources, to decide how you would like to calculate the value using NinjaScript.
Please let us know if we may be of further assistance.
-
Ask CHATGPT: But the value it gives me is not correct, I'm going to look where the error is
using System;
using NinjaTrader.Cbi;
namespace NinjaTrader.Strategy
{
public class MyStrategy : Strategy
{
protected override void OnBarUpdate()
{
// Calcular el rango promedio verdadero (ATR)
double atrValue = ATR(14)[0]; // 14 es el período utilizado para el cálculo
// Calcular la volatilidad anualizada asumiendo 252 días hábiles por año
double volatilidadAnualizada = atrValue * Math.Sqrt(252);
Print("Volatilidad Anualizada: " + volatilidadAnualizada);
}
}
}
Comment
-
Hello Gibranes,
Thank you for your reply.
From our experience at this time, ChatGpt is not quite adequate to generate valid compilable NinjaScripts that function as the user has intended. We often find that the generated code will call non-existent properties and methods, use improper classes or inheritance, and may have incorrect logic. We highly encourage that you create a new NinjaScript yourself using the NinjaScript Editor, and use the code generated by ChatGpt as more as suggestions and guides when coding the script yourself, than using the actual code generated.
While It would not be within our support model to correct these scripts at user request, we would be happy to provide insight for any direct specific inquiries you may have if you would like to create this script yourself. Our support is able to assist with finding resources in our help guide as well as simple examples, and we are happy to assist with guiding you through the debugging process to assist you with understanding unexpected behavior.
You can also contact a professional NinjaScript Consultant who would be eager to create or modify this script at your request or assist you with your script. The NinjaTrader Ecosystem has affiliate contacts who provide educational as well as consulting services. Please let me know if you would like a list of affiliate consultants who would be happy to create this script or any others at your request or provide one on one educational services.
Please let me know if I may be of further assistance.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
559 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
324 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
101 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
546 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
547 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment