Indicador - Swing Gann Experto

Odine
Mensajes: 83
Registrado: 22 Mar 2023 11:49

Indicador - Swing Gann Experto

Mensaje por Odine »

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.
Imagen
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
Odine
Mensajes: 83
Registrado: 22 Mar 2023 11:49

Re: Indicador - Swing Gann Experto

Mensaje por Odine »

Si alguien conoce algún programador que me pueda ayudar, por favor, que me escriba un privado para poderlo tratar.

Gracias, saludos!!
Avatar de Usuario
Gibranes
Mensajes: 231
Registrado: 22 Jun 2010 07:57

Re: Indicador - Swing Gann Experto

Mensaje por Gibranes »

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.
Avatar de Usuario
Gibranes
Mensajes: 231
Registrado: 22 Jun 2010 07:57

Re: Indicador - Swing Gann Experto

Mensaje por Gibranes »

Perdón, no vi que es para ctrader no conozco esa plataforma. 
Odine
Mensajes: 83
Registrado: 22 Mar 2023 11:49

Re: Indicador - Swing Gann Experto

Mensaje por Odine »

Gibranes escribió: 29 Mar 2023 21:59 Perdón, no vi que es para ctrader no conozco esa plataforma. 
:D :D !!!

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

Avatar de Usuario
Gibranes
Mensajes: 231
Registrado: 22 Jun 2010 07:57

Re: Indicador - Swing Gann Experto

Mensaje por Gibranes »

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#. 
Adjuntos
Captura de pantalla 2023-03-31 084214.jpg
Odine
Mensajes: 83
Registrado: 22 Mar 2023 11:49

Re: Indicador - Swing Gann Experto

Mensaje por Odine »

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#. 
Sí, es algo así como lo que adjuntaste.
Voy a echar un vistazo como dices a ver si encuentro algún foro de desarrollador de C#.

Gracias por el aporte Gibranes!!, saludos
Avatar de Usuario
X-Trader
Administrador
Mensajes: 12781
Registrado: 06 Sep 2004 10:18
Contactar:

Re: Indicador - Swing Gann Experto

Mensaje por X-Trader »

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
"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."
Odine
Mensajes: 83
Registrado: 22 Mar 2023 11:49

Re: Indicador - Swing Gann Experto

Mensaje por Odine »

X-Trader escribió: 01 Abr 2023 10:29 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
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);

}
}

}
}
}
Avatar de Usuario
Gibranes
Mensajes: 231
Registrado: 22 Jun 2010 07:57

Re: Indicador - Swing Gann Experto

Mensaje por Gibranes »

Desarrollo algo en C#. Envía el indicador completo, intento editarlo en visual studio si es posible. 
Odine
Mensajes: 83
Registrado: 22 Mar 2023 11:49

Re: Indicador - Swing Gann Experto

Mensaje por Odine »

Gibranes escribió: 03 Abr 2023 14:43 Desarrollo algo en C#. Envía el indicador completo, intento editarlo en visual studio si es posible. 
Hola Gibranes,

Lo que os pasé es el código completo del indicador. Así lo copié de la plataforma donde lo utilizo, no venía más.

Saludos
Avatar de Usuario
Gibranes
Mensajes: 231
Registrado: 22 Jun 2010 07:57

Re: Indicador - Swing Gann Experto

Mensaje por Gibranes »

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#.
Odine
Mensajes: 83
Registrado: 22 Mar 2023 11:49

Re: Indicador - Swing Gann Experto

Mensaje por Odine »

Gibranes escribió: 08 Abr 2023 12:06 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#.
No me he enterado de nada! :D. Disculpa mi ignorancia en el tema.

Qué necesitas que busque un archivo con terminación sln y te lo pase?

Gracias Gribanes, saludos!!
Avatar de Usuario
Gibranes
Mensajes: 231
Registrado: 22 Jun 2010 07:57

Re: Indicador - Swing Gann Experto

Mensaje por Gibranes »

¿Cómo se llama el indicador?
¿O dónde lo puedo descargar?
Odine
Mensajes: 83
Registrado: 22 Mar 2023 11:49

Re: Indicador - Swing Gann Experto

Mensaje por Odine »

Gibranes escribió: 10 Abr 2023 19:26 ¿Cómo se llama el indicador?
¿O dónde lo puedo descargar?
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!


Responder

Volver a “Indicadores”