protected override void OnBarUpdate()
{
if (Bars.FirstBarOfSession)
{
disable = 0;
dayscapital = initialcapital + Performance.AllTrades.TradesPerformance.Currency.C umProfit;
}
if (initialcapital + Performance.AllTrades.TradesPerformance.Currency.C umProfit > daycapital * 0.97
&& disable == 0)
{
<<<continuetrading>>>
}
else
{
disable = 1;
}
What I'd expect is that as long as the daily loss is less than 3%, the script should <<<continuetrading>>>. But it doesn't seem to work. I have a stop loss of 1% on all trades so the max daily drawdown should be 4%. However, I have some with 6+%.
I tried to troubleshoot this by adding a
Print (dayscapital);
on the last line of the first if clause, after the dayscapital has been calculated for the day.
However, checking the output window, the dayscapital is never printed as 10000, which it should be at least once, on the first day before any trades have been completed (since initialcapital = 10000). Also, for some reason, other Print() commands on the first day have been outputted before the Print (dayscapital) even though they come later on in the script.
Any help would be much appreciated. Thanks!
-------
EDIT:
I tried this in another script where and it does seem to work. Could this by any chance be due to a problem this has with SetTrailStop?
Comment