Buenos días,
Necesito ayuda sobre código de programación por que no tengo ni idea y me es imposible avanzar...
Utilizo este indicador para mis análisis, pero tengo que ir cogiendo datos de forma muy rudimentaria de 1 en 1 y me eternizo . Si alguien me puede ayudar se lo agradecería.
Mi idea sería introducir el código necesario para decirle al indicador que me muestre en el gráfico el precio de apertura y su fecha y el precio de cierre y su fecha. Pongo una foto del indicador para que se entienda mejor.
No se si también se podría descargar todos esos datos a una tabla excel...
Muchas gracias por vuestro tiempo y vuestra ayuda!!
saludos
Indicador - Swing Gann Experto
Re: Indicador - Swing Gann Experto
Si alguien conoce algún programador que me pueda ayudar, por favor, que me escriba un privado para poderlo tratar.
Gracias, saludos!!
Gracias, saludos!!
Re: Indicador - Swing Gann Experto
Deberías decir para que plataformas necesitas el código, no todas las plataformas se desarrollan con el mismo lenguaje.
O bien buscar en el ecosistema de la plataforma, por ejemplo en ninjatrader existe uno casi parecido a lo que buscas, después se puede modificar el código si no es una dll.
O bien buscar en el ecosistema de la plataforma, por ejemplo en ninjatrader existe uno casi parecido a lo que buscas, después se puede modificar el código si no es una dll.
Re: Indicador - Swing Gann Experto
Perdón, no vi que es para ctrader no conozco esa plataforma.
Re: Indicador - Swing Gann Experto
!!!
Sí, es para Ctrader.
Y seguro que es una tontería, pero como yo no tengo ni idea de código pues no sé como poder hacerlo, ni sé como poder buscar o dónde tengo que buscar. Intenté utilizar ChatGPT pero tampoco soy capaz de sacarlo porque me da cosas muy genéricas y en cuanto pruebo a ponerlo en el código del indicador y compilar ya me da error.
Bueno, no queda otra que esperar a ver si alguien se le ocurre alguna forma.
Gracias!! Saludos
Re: Indicador - Swing Gann Experto
Veo que ctrader usa C# el mismo que ninjatrader y la suerte es que no es un lenguaje nativo de la plataforma, C# está desarrollado por microsoft y es uno de los más populares. Busca en foros de desarrolladores en C# o en you tube.
Yo utilizo este para ninjatrader, es muy completo, y es más o menos lo que busca, está desarrollado en C#.
Yo utilizo este para ninjatrader, es muy completo, y es más o menos lo que busca, está desarrollado en C#.
Re: Indicador - Swing Gann Experto
Sí, es algo así como lo que adjuntaste.Gibranes escribió: ↑31 Mar 2023 08:45 Veo que ctrader usa C# el mismo que ninjatrader y la suerte es que no es un lenguaje nativo de la plataforma, C# está desarrollado por microsoft y es uno de los más populares. Busca en foros de desarrolladores en C# o en you tube.
Yo utilizo este para ninjatrader, es muy completo, y es más o menos lo que busca, está desarrollado en C#.
Voy a echar un vistazo como dices a ver si encuentro algún foro de desarrollador de C#.
Gracias por el aporte Gibranes!!, saludos
Re: Indicador - Swing Gann Experto
Hola Odine, aunque cTrader no es la plataforma que más uso, le puedo echar un vistazo. ¿Tienes por ahí el código de ese indicador? Si eso compártelo por aquí.
Saludos,
X-Trader
Saludos,
X-Trader
"Los sistemas de trading pueden funcionar en ciertas condiciones de mercado todo el tiempo, en todas las condiciones de mercado en algún momento del tiempo, pero nunca en todas las condiciones de mercado todo el tiempo."
Re: Indicador - Swing Gann Experto
Hola X-Trader,
Este es el código del indicador.
Gracias!!
using System;
using cAlgo.API;
using System.Linq;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;
namespace cAlgo
{
[Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class SwingGannExperto : Indicator
{
public enum SwingData
{
SpeedIndex,
Volume,
Price
}
public enum Multi
{
Pips = 10,
Unit = 100,
Tick = 1
}
public enum devi
{
Price = 1,
ATR = 2
}
[Parameter("Deviation Size in", Group = "Deviation Settings", DefaultValue = Multi.Unit)]
public Multi Multiplier { get; set; }
[Parameter("Deviation Value", Group = "Deviation Settings", DefaultValue = 50, MinValue = 1)]
public int Deviation { get; set; }
[Parameter("Bull Rectangle", Group = "Objects Settings", DefaultValue = Colors.DarkSlateGray)]
public Colors BullRect { get; set; }
[Parameter("Bear Rectangle", Group = "Objects Settings", DefaultValue = Colors.DarkRed)]
public Colors BearRect { get; set; }
[Parameter("Bull Trend Line", Group = "Objects Settings", DefaultValue = Colors.DarkSlateGray)]
public Colors BullLine { get; set; }
[Parameter("Bear Trend Line", Group = "Objects Settings", DefaultValue = Colors.DarkRed)]
public Colors BearLine { get; set; }
[Parameter("Rectangle Opacity", Group = "Objects Settings", DefaultValue = 40)]
public int RectangleOpacity { get; set; }
[Parameter("Swing Data", Group = "Swing Information", DefaultValue = SwingData.Price)]
public SwingData SwingDataInput { get; set; }
[Parameter("Atr Multiplier", Group = "ATR Settings", DefaultValue = 2, MinValue = 0, MaxValue = 10)]
public double atrMultiplier { get; set; }
[Parameter("Atr Period", Group = "ATR Settings", DefaultValue = 13, MinValue = 1)]
public int atrPeriod { get; set; }
[Parameter("Deviation Type", Group = "Deviation Settings", DefaultValue = devi.ATR)]
public devi deviationType { get; set; }
private int lastHighIndex = 0;
private int lastLowIndex = 0;
private double _point;
private DataSeries CurrentClose;
private IndicatorDataSeries Direction;
private IndicatorDataSeries DownBuffer;
private AverageTrueRange _averageTrueRange;
private double DeviationAtr;
private bool deviationPrice = true;
private double deviationValue;
public int UpTrendStartIndex;
public int DownTrendStartIndex;
public double PixelsInPrice;
public double TopDistance;
public double BottomDistance;
public int PipsMutliplier = 1;
public Color BullRectColor;
public Color BearRectColor;
protected override void Initialize()
{
RectangleOpacity = RectangleOpacity > 100 ? 100 : RectangleOpacity < 0 ? 0 : RectangleOpacity;
RectangleOpacity = (int)(2.55 * RectangleOpacity);
BullRectColor = Color.FromArgb(RectangleOpacity, Color.FromName(BullRect.ToString()).R, Color.FromName(BullRect.ToString()).G, Color.FromName(BullRect.ToString()).B);
BearRectColor = Color.FromArgb(RectangleOpacity, Color.FromName(BearRect.ToString()).R, Color.FromName(BearRect.ToString()).G, Color.FromName(BearRect.ToString()).B);
if (Symbol.Digits == 2 && Symbol.PipSize == 0.1)
{
PipsMutliplier = 10;
}
PixelsInPrice = (Chart.TopY - Chart.BottomY) / Chart.Height;
TopDistance = PixelsInPrice * 60;
Direction = CreateDataSeries();
CurrentClose = Bars.ClosePrices;
DownBuffer = CreateDataSeries();
_point = Symbol.TickSize * (double)Multiplier;
_averageTrueRange = Indicators.AverageTrueRange(atrPeriod, MovingAverageType.Weighted);
if (deviationType == devi.ATR)
{
_point = 1;
deviationPrice = false;
}
else
{
deviationPrice = true;
}
//CalculateSwings(1, Chart.FirstVisibleBarIndex, Chart.LastVisibleBarIndex, SwingDataInput, Bars.Count - 1);
}
public override void Calculate(int index)
{
if (deviationPrice)
{
deviationValue = Deviation;
}
else
{
DeviationAtr = _averageTrueRange.Result[index] * atrMultiplier;
deviationValue = DeviationAtr;
}
int r = 0;
if (index == 1)
{
if (CurrentClose[index] >= Bars.ClosePrices[index - 1])
{
lastHighIndex = index;
lastLowIndex = index - 1;
Direction[index] = 1;
Direction[index - 1] = 1;
UpTrendStartIndex = index - 1;
Chart.DrawTrendLine("TrendLine" + UpTrendStartIndex, UpTrendStartIndex, Bars.LowPrices[UpTrendStartIndex], index, Bars.HighPrices[index], BullLine.ToString());
Chart.DrawRectangle("Rectangle" + UpTrendStartIndex, UpTrendStartIndex, Bars.LowPrices[UpTrendStartIndex], index, Bars.HighPrices[index], BullRectColor).IsFilled = true;
CalculateSwings(1, UpTrendStartIndex, index, SwingDataInput, UpTrendStartIndex);
}
else if (CurrentClose[index] < Bars.ClosePrices[index - 1])
{
lastLowIndex = index;
lastHighIndex = index - 1;
Direction[index] = 3;
Direction[index - 1] = 3;
DownTrendStartIndex = index - 1;
Chart.DrawTrendLine("TrendLine" + DownTrendStartIndex, DownTrendStartIndex, Bars.HighPrices[UpTrendStartIndex], index, Bars.LowPrices[index], Color.Red);
Chart.DrawRectangle("Rectangle" + DownTrendStartIndex, DownTrendStartIndex, Bars.HighPrices[UpTrendStartIndex], index, Bars.LowPrices[index], BearRectColor).IsFilled = true;
CalculateSwings(3, DownTrendStartIndex, index, SwingDataInput, DownTrendStartIndex);
}
}
Direction[index] = Direction[index - 1];
if (Direction[index] == 1)
{
if (Bars.HighPrices[lastHighIndex] - CurrentClose[index] > (deviationValue * _point))
{
Direction[index] = 3;
}
}
else if (Direction[index] == 3)
{
if (Bars.ClosePrices[index] - Bars.LowPrices[lastLowIndex] > (deviationValue * _point))
{
Direction[index] = 1;
}
}
//***********************************************************************************************************************************//
if (Direction[index] == 1)
{
if (Direction[index - 1] == 1)
{
if (CurrentClose[lastHighIndex] < CurrentClose[index])
{
lastHighIndex = index;
}
Chart.DrawTrendLine("TrendLine" + UpTrendStartIndex, UpTrendStartIndex, Bars.LowPrices[UpTrendStartIndex], index, Bars.HighPrices[lastHighIndex], Color.LawnGreen);
Chart.DrawRectangle("Rectangle" + UpTrendStartIndex, UpTrendStartIndex, Bars.LowPrices[UpTrendStartIndex], index, Bars.HighPrices[lastHighIndex], BullRectColor).IsFilled = true;
CalculateSwings(1, UpTrendStartIndex, lastHighIndex, SwingDataInput, UpTrendStartIndex);
}
//********************************************************** //
else if (Direction[index - 1] == 3)
{
Chart.DrawTrendLine("TrendLine" + DownTrendStartIndex, DownTrendStartIndex, Bars.HighPrices[DownTrendStartIndex], lastLowIndex, Bars.LowPrices[lastLowIndex], Color.Red);
Chart.DrawRectangle("Rectangle" + DownTrendStartIndex, DownTrendStartIndex, Bars.HighPrices[DownTrendStartIndex], lastLowIndex, Bars.LowPrices[lastLowIndex], BearRectColor).IsFilled = true;
CalculateSwings(3, DownTrendStartIndex, lastLowIndex, SwingDataInput, DownTrendStartIndex);
for (r = (lastLowIndex + 2); r <= index; r++)
{
}
lastHighIndex = index;
UpTrendStartIndex = lastLowIndex + 1;
Chart.DrawTrendLine("TrendLine" + UpTrendStartIndex, UpTrendStartIndex, Bars.LowPrices[UpTrendStartIndex], index, Bars.HighPrices[index], Color.LawnGreen);
Chart.DrawRectangle("Rectangle" + UpTrendStartIndex, UpTrendStartIndex, Bars.LowPrices[UpTrendStartIndex], index, Bars.HighPrices[index], BullRectColor).IsFilled = true;
CalculateSwings(1, UpTrendStartIndex, index, SwingDataInput, UpTrendStartIndex);
}
}
else if (Direction[index] == 3)
{
if (Direction[index - 1] == 3)
{
if (CurrentClose[index] < CurrentClose[lastLowIndex])
{
lastLowIndex = index;
}
Chart.DrawTrendLine("TrendLine" + DownTrendStartIndex, DownTrendStartIndex, Bars.HighPrices[DownTrendStartIndex], index, Bars.LowPrices[lastLowIndex], Color.Red);
Chart.DrawRectangle("Rectangle" + DownTrendStartIndex, DownTrendStartIndex, Bars.HighPrices[DownTrendStartIndex], index, Bars.LowPrices[lastLowIndex], BearRectColor).IsFilled = true;
CalculateSwings(3, DownTrendStartIndex, lastLowIndex, SwingDataInput, DownTrendStartIndex);
}
//********************************************************** //
else if (Direction[index - 1] == 1)
{
Chart.DrawTrendLine("TrendLine" + UpTrendStartIndex, UpTrendStartIndex, Bars.LowPrices[UpTrendStartIndex], lastHighIndex, Bars.HighPrices[lastHighIndex], Color.LawnGreen);
Chart.DrawRectangle("Rectangle" + UpTrendStartIndex, UpTrendStartIndex, Bars.LowPrices[UpTrendStartIndex], lastHighIndex, Bars.HighPrices[lastHighIndex], BullRectColor).IsFilled = true;
CalculateSwings(1, UpTrendStartIndex, lastHighIndex, SwingDataInput, UpTrendStartIndex);
//**********************************************************//
for (r = (lastHighIndex + 2); r <= index; r++)
{
}
lastLowIndex = index;
DownTrendStartIndex = lastHighIndex + 1;
Chart.DrawTrendLine("TrendLine" + DownTrendStartIndex, DownTrendStartIndex, Bars.HighPrices[lastHighIndex + 1], index, Bars.LowPrices[index], Color.Red);
Chart.DrawRectangle("Rectangle" + DownTrendStartIndex, DownTrendStartIndex, Bars.HighPrices[lastHighIndex + 1], index, Bars.LowPrices[index], BearRectColor).IsFilled = true;
CalculateSwings(3, DownTrendStartIndex, index, SwingDataInput, DownTrendStartIndex);
}
}
}
public void CalculateSwings(int direction, int firstCandle, int lastCandle, SwingData SwingOption, int objectIndex)
{
if (SwingOption == SwingData.Price)
{
Print("Calculate Price");
if (direction == 1)
{
var price = Bars.HighPrices[lastCandle] - Bars.LowPrices[firstCandle];
price = Math.Round(price, Symbol.Digits);
price = (price / Symbol.PipSize) / PipsMutliplier;
Chart.DrawText("Text" + objectIndex, "Price \n" + price, objectIndex, Bars.HighPrices[lastCandle] + TopDistance, Color.LightSteelBlue);
}
else if (direction == 3)
{
var price = Bars.HighPrices[firstCandle] - Bars.LowPrices[lastCandle];
price = Math.Round(price, Symbol.Digits);
price = (price / Symbol.PipSize) / PipsMutliplier;
Chart.DrawText("Text" + objectIndex, "Price \n" + price, objectIndex, Bars.LowPrices[lastCandle] - TopDistance, Color.Red);
}
}
else if (SwingOption == SwingData.Volume)
{
Print("Calculate Volume");
if (direction == 1)
{
//var price = Bars.HighPrices[lastCandle] - Bars.LowPrices[firstCandle];
var volume = 0.0;
for (int i = firstCandle; i <= lastCandle; i++)
{
volume += Bars.TickVolumes;
}
Chart.DrawText("Text" + objectIndex, "Volume \n" + volume, objectIndex, Bars.HighPrices[lastCandle] + TopDistance, Color.LightSteelBlue);
}
else if (direction == 3)
{
//var price = Bars.HighPrices[firstCandle] - Bars.LowPrices[lastCandle];
var volume = 0.0;
for (int i = firstCandle; i <= lastCandle; i++)
{
volume += Bars.TickVolumes;
}
Chart.DrawText("Text" + objectIndex, "Volume \n" + volume, objectIndex, Bars.LowPrices[lastCandle] - TopDistance, Color.Red);
}
}
else if (SwingOption == SwingData.SpeedIndex)
{
Print("Calculate Speed Index");
if (direction == 1)
{
var price = Bars.HighPrices[lastCandle] - Bars.LowPrices[firstCandle];
price = (price / Symbol.PipSize) / PipsMutliplier;
var volume = 0.0;
var speedIndex = 0.0;
for (int i = firstCandle; i <= lastCandle; i++)
{
volume += Bars.TickVolumes;
}
speedIndex = volume / price;
speedIndex = Math.Round(speedIndex, 2);
Chart.DrawText("Text" + objectIndex, "Speed \n" + speedIndex, objectIndex, Bars.HighPrices[lastCandle] + TopDistance, Color.LightSteelBlue);
}
else if (direction == 3)
{
var price = Bars.HighPrices[firstCandle] - Bars.LowPrices[lastCandle];
price = (price / Symbol.PipSize) / PipsMutliplier;
var volume = 0.0;
var speedIndex = 0.0;
for (int i = firstCandle; i <= lastCandle; i++)
{
volume += Bars.TickVolumes;
}
speedIndex = volume / price;
speedIndex = Math.Round(speedIndex, 2);
Chart.DrawText("Text" + objectIndex, "Speed \n" + speedIndex, objectIndex, Bars.LowPrices[lastCandle] - TopDistance, Color.Red);
}
}
}
}
}
Re: Indicador - Swing Gann Experto
Desarrollo algo en C#. Envía el indicador completo, intento editarlo en visual studio si es posible.
Re: Indicador - Swing Gann Experto
El indicador viene en una carpeta, en esa carpeta viene otra carpeta. En la primera carpeta se encuentra un archivo con terminación sln (solución), es la que llama a la clase y desde la cual se edita en visual studio, así funciona en C#.
Re: Indicador - Swing Gann Experto
No me he enterado de nada! . Disculpa mi ignorancia en el tema.
Qué necesitas que busque un archivo con terminación sln y te lo pase?
Gracias Gribanes, saludos!!
Re: Indicador - Swing Gann Experto
¿Cómo se llama el indicador?
¿O dónde lo puedo descargar?
¿O dónde lo puedo descargar?
Re: Indicador - Swing Gann Experto
Lo puedes descargar desde este link.
https://ctrader.com/algos/indicators/show/2521
Gracias, saludos!!
Si te ha gustado este hilo del Foro, ¡compártelo en redes!