Profile Picture

Positions Close - not working

Posted By puianalin 6 Months Ago
Message
Posted Friday February 09 2018
Hello.

can someone help please? I use DnD and c#. I've create the triggers in DnD. It works only without the close instructions. Thanks.
I have the error below -
"An exception of type System.NullReferenceException was thrown. Object reference not set to an instance of an object."

if (SystemData.Triggers["LONG_T"] [Symbol].IsTriggered)
{
PositionSettings ps1 = new PositionSettings();
ps1.PositionType = PositionType.Long;
ps1.OrderType = OrderType.Market;
ps1.Size = (long)Indicators["Units"].Current;
OpenPosition (ps1);
}

if (SystemData.Triggers["SHORT_T"] [Symbol].IsTriggered)
{
PositionSettings ps2 = new PositionSettings();
ps2.PositionType = PositionType.Short;
ps2.OrderType = OrderType.Market;
ps2.Size = (long)Indicators["Units"].Current;
OpenPosition (ps2);
}

if (SystemData.Triggers["ATR_Stop_L"] [Symbol].IsTriggered)
{
foreach (Position ps1 in OpenPositions)
{
ps1.CloseAtMarket();
}
}

if (SystemData.Triggers["ATR_Stop_S"] [Symbol].IsTriggered)
{
foreach (Position ps2 in OpenPositions)
{
ps2.CloseAtMarket();
}
}


Similar Topics


Reading This Topic


2005-2018 © RightEdge Systems