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
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
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.Emily C.NinjaTrader Customer Service
-
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.Emily C.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by synthhokie, Today, 12:00 PM
|
1 response
15 views
0 likes
|
Last Post Today, 12:31 PM | ||
Started by drnoggin, Today, 12:19 PM
|
0 responses
11 views
0 likes
|
Last Post Today, 12:46 PM | ||
Started by moneyexe, Today, 11:22 AM
|
1 response
12 views
0 likes
|
Last Post Today, 11:32 AM | ||
Started by stevec1824, Today, 11:00 AM
|
2 responses
8 views
0 likes
|
Last Post
by stevec1824
Today, 11:32 AM
|
||
Started by sofortune, Today, 10:05 AM
|
2 responses
14 views
0 likes
|
Last Post
by sofortune
Today, 10:58 AM
|
Comment