crash
crash
10 Aug 2023, 21:08
using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;
using System.Threading;
namespace cAlgo
{
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class Revenant : Robot
{
[Parameter("Quantity (Lots)", Group = "Volume", DefaultValue = 0.01, MinValue = 0.01, Step = 0.01)]
public double Quantity { get; set; }
[Parameter("Take Profit (pips)", Group = "Protection", DefaultValue = 15, MinValue = 1)]
public int TakeProfitInPips { get; set; }
private const string label = "Revenant";
private MovingAverage Mv10D;
private MovingAverage Mv10H;
protected override void OnStart()
{
var EURUSDSeriesDay = MarketData.GetBars(TimeFrame.Daily);
var EUEUSDSeries1h = MarketData.GetBars(TimeFrame.Hour);
var hedging1 =Positions.Find("Hedging1");
var posizione1 = Positions.Find("Mylabel1");
var hedging2 =Positions.Find("Hedging2");
var posizione2 = Positions.Find("Mylabel2");
var volumeInUnits = Symbol.QuantityToVolumeInUnits(Quantity);
var NOposizioni1 = hedging1 == null && posizione1 == null;
var NOposizioni2 = hedging2 == null && posizione2 == null;
var SIposizioni1 = hedging1 != null && posizione1 != null;
var SIposizioni2 = hedging2 != null && posizione2 != null;
var MediaDayDiscesa = Mv10D.Result.Last(1) > Mv10D.Result.LastValue;
var MediaDaySalita = Mv10D.Result.Last(1) < Mv10D.Result.LastValue;
var MediaOraDiscesa = Mv10H.Result.Last(1) > Mv10H.Result.LastValue;
var MediaOraSalita = Mv10H.Result.Last(1) < Mv10H.Result.LastValue;
Mv10D = Indicators.MovingAverage(EURUSDSeriesDay.ClosePrices, 10,MovingAverageType.Simple);
Mv10H = Indicators.MovingAverage(EUEUSDSeries1h.ClosePrices, 10,MovingAverageType.Simple);
while (1==1)
{
while ( NOposizioni1 && NOposizioni2)
{
while (MediaDayDiscesa && MediaOraSalita || MediaDaySalita && MediaOraDiscesa)
{
Print("wait");
//funziona bisognava cancellare il wait
}
while (MediaDayDiscesa && MediaOraDiscesa)
{
Print("vai sell");
break;
}
while (MediaDaySalita && MediaOraSalita)
{
Print("vai buy");
break;
}
break;
}
while (SIposizioni1 && SIposizioni2)
{
Print("DAJEE");
}
} } }
}
why it crash?
Replies
luca.tocchi
11 Aug 2023, 06:02
RE: crash
firemyst said:
why it crash?
Why don't you post the error message or a screen capture of the crash?
Creashed in OnStart whit NullReferenceExeption: Object reference not set to an istance of an object
the program keeps going but doesn’t print anything
@luca.tocchi
PanagiotisChar
11 Aug 2023, 06:11
Hi there,
You are using the indicators before initializing them. That's why you get the exception.
Need help? Join us on Telegram
@PanagiotisChar
firemyst
11 Aug 2023, 00:21
Why don't you post the error message or a screen capture of the crash?
@firemyst