(I used other platforms)
The errors occurred in connection kinetick
The simulation program open orders, but closed them immediately
(I'd also like to get some additional advice)
namespace NinjaTrader.Strategy
{
/// <summary>
/// Prima versione ea su hammer (con tante abilitazioni)
/// </summary>
[Description("Prima versione ea su hammer (con tante abilitazioni)")]
public class hammered1 : Strategy
{
#region Variables
// Wizard generated variables
public int per_s = 50; // Default setting for Per_s
// public int per_b = 50; // Default setting for Per_b
public int per_2o = 5; // Default setting for Per_2o
public bool trend = true; // Default setting for Trend
public int trend_v1 = 15; // Default setting for Trend_v1
public int trend_v2 = 30; // Default setting for Trend_v2
public bool rottura_maxmin = true; // Default setting for Rottura_maxmin
public int rottura_periodo = 15; // Default setting for Rottura_periodo
public int rottura_perc=-10;
public int lotti=1;
public int per_stop=101;
public int per_take=101;
// User defined variables (add any user defined variables below)
public int ok_proporzioni=0;
public int ok_trend=0;
public int ok_rottura_maxmin=0;
#endregion
/// <summary>
/// This method is used to configure the strategy and is called once before any strategy method is called.
/// </summary>
protected override void Initialize()
{
CalculateOnBarClose = true;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
#region CARICAMENTI
double atr=High[1]-Low[1];
double min=0;
double massimo=0;
ok_proporzioni=0;
ok_trend=0;
ok_rottura_maxmin=0;
if(Close[1]>Open[1]){massimo=Close[1]; min=Open[1];} else { massimo=Open[1]; min=Close[1]; }
#endregion //fatti a inizio caricamento barra
#region CONTROLLI PREORDINE E FILTRI
#region Proporzioni
if (min-Low[1]>=atr*per_s/100 && High[1]-massimo<=atr*per_2o/100){ok_proporzioni=1;}
if (High[1]-massimo>=atr*per_s/100 && min-Low[1]<=atr*per_2o/100){ok_proporzioni=2;}
#endregion //ok_proporzioni(dell ammer)=1 candela long 2 short
#region Trend presente
if (ok_proporzioni>0)
{
if(trend==true)
{
if(SMA(trend_v1)[1]>SMA(trend_v2)[1]){ok_trend=1;}
if(SMA(trend_v1)[1]<SMA(trend_v2)[1]){ok_trend=2;}
if(SMA(trend_v1)[1]==SMA(trend_v2)[1]){ok_trend=0;}
}
else
{
ok_trend=-1;
}
}
#endregion // ok_trend(2 sma indicano la dir) 1=long 2=short -1=filtro disabilitato 0=2medie stesso valore
#region Rottura minmax
if (ok_proporzioni>0)
{
if(rottura_maxmin==true)
{
double point=ATR(5)[1]*rottura_perc/100;
if(Low[1]<=MIN(Low,rottura_periodo+1)[0]-point){ok_rottura_maxmin=1;}
if(High[1]>=MAX(High,rottura_periodo+1)[0]+point){ok_rottura_maxmin=2;}
}
else
{
ok_rottura_maxmin=-1;
}
}
#endregion // ok_rottura_maxmin(solo se l'ombra viola estremi) 1=long 2=short -1=filtro disabilitato 0=hammer non rompe estremi
#endregion
if(Position.MarketPosition == MarketPosition.Flat && ok_proporzioni==1 && (ok_trend==1 || trend==false) && (ok_rottura_maxmin==1 || rottura_maxmin==false) )
{
EnterLong(lotti, "L");
SetProfitTarget( CalculationMode.Ticks, (Close[1]-Low[1])*per_take/100);
SetStopLoss( CalculationMode.Ticks, (Close[1]-Low[1])*per_stop/100);
}
if(Position.MarketPosition == MarketPosition.Flat && ok_proporzioni==2 && (ok_trend==2 || trend==false) && (ok_rottura_maxmin==2 || rottura_maxmin==false) )
{
EnterShort(lotti, "S");
SetProfitTarget( CalculationMode.Ticks, (High[1]-Close[1])*per_take/100);
SetStopLoss( CalculationMode.Ticks, (High[1]-Close[1])*per_stop/100);
}
}
#region Properties
#endregion
}
}

Comment