protected override void OnBarUpdate()
{
var boling = Bollinger(2, 20);
var currentPrice = Bars.GetClose(Bars.CurrentBar);
if (Position.MarketPosition == MarketPosition.Flat)
{
// Short from upper border
if (currentPrice - boling.Upper[0] > TickSize * MinTicks)
{
if (Position.Quantity != 0)
return;
EnterShort();
_exitPrice = currentPrice - TickSize * ProfitTicks;
_stopPrice = currentPrice + TickSize * LossTicks;
_enterPrice = currentPrice;
MessageLog.WarningMessage(this, "EnteredShort", playSound: PlaySound);
return;
}
/* .............. */
public static void WarningMessage(NinjaScriptBase ind, string message, bool playSound = true, int cooldown = 0)
{
var soundPath = (playSound) ? @"\sounds\Alert4.wav" : "";
ind.Alert("WARNING",
Priority.Medium,
message,
Core.Globals.InstallDir + soundPath,
cooldown,
Brushes.Chocolate,
Brushes.BlanchedAlmond);
}

I always enter (and exit) just with 1 contract (One pip. One quantity. Whatever it called). So it must send just one alert message. Why it doesn't?
And the robot sets wrong markers too. For example:

These markers shows the deal was a loss (with commission). But I can see in my account window that it gave me profit. Why does this happen? How to fix the strategy?



Comment