- ago
I started to use the PowerPack.
When UPI is selected in the One-parameter graph, the vertical axis is not properly sized.

0
116
Solved
6 Replies

Reply

Bookmark

Sort
Cone8
 ( 7.88% )
- ago
#1
Seems to be something specific to your results. Can you share the script?
0
- ago
#2
Sure, please see the MVP

CODE:
public class Strategy1 : UserStrategyBase    {       public Strategy1()       {          AddParameter("Days before EOM", ParameterType.Int32, 5, 1, 25, 1);       }       Int32 daysBeforeEom;       Dictionary<DateTime, int> daysToEom;       public override void Initialize(BarHistory bars)       {          daysBeforeEom = Parameters[0].AsInt;          daysToEom = GetDaysToEOM(bars);       }              private Dictionary<DateTime, int> GetDaysToEOM(BarHistory originalBars)       {          var daysToEomInternal = new Dictionary<DateTime, int>();                    BarHistory bars = BarHistoryCompressor.ToScale(originalBars, HistoryScale.Daily);          int daysToEomCount = 0;          for (int i = bars.Count - 1; i > 1; i--)          {             daysToEomInternal.Add(bars.DateTimes[i].Date, daysToEomCount);             if (bars.DateTimes[i].Month != bars.DateTimes[i - 1].Month)                daysToEomCount = 0;             else                daysToEomCount++;          }                    return daysToEomInternal;       }       public override void Execute(BarHistory bars, int bar)       {          if (bar < 2)             return;          if (bars.Scale != HistoryScale.Daily)          {             WriteToDebugLog("Strategy works on daily data only");             return;          }          if (HasOpenPosition(bars, PositionType.Long))          {             ClosePosition(LastPosition, OrderType.MarketClose, 0, "Time exit");          }          if (!HasOpenPosition(bars, PositionType.Long) && daysToEom[bars.DateTimes[bar].Date] == daysBeforeEom)          {             PlaceTrade(bars, TransactionType.Buy, OrderType.MarketClose);          }       }    }
0
Cone8
 ( 7.88% )
- ago
#3
What's the MVP?
If you can duplicate it with that script, what symbol(s) and date range did you use?

Edit: I just realized I'm not using the right Scorecard. Stand by...

0
Cone8
 ( 7.88% )
- ago
#4
Ok, I see it, but in this case there appears to be some very large values for daysBeforeEom = 23, 24, 25.



0
Cone8
 ( 7.88% )
- ago
#5
Okay, that's occurring because of the Ulcer Index being 0 (Post #3).
We'll make that a NaN to avoid this problem.

Update: Fixed for PowerPack build 48.
0
Best Answer
- ago
#6
With MVP I meant minimum viable product - so a most simple strategy that allows you to reproduce the issue.

The ticker is SPY for 20 years.

Thank you for the fix!
0

Reply

Bookmark

Sort