Good afternoon - please help me remake the code of a simple trading system in version 6 for the new version 7 - thanks
CODE:
using System; using System.Collections.Generic; using System.Text; using System.Drawing; using WealthLab; using WealthLab.Indicators; namespace WealthLab.Strategies { public class PC1_PS_FET : BacktestHelper2.WealthScript { private StrategyParameter _period; private StrategyParameter _timeexit;// - время выхода public PC1_PS_FET() { _period = CreateParameter("Период Канала: ", 230, 30, 500, 5); _timeexit = CreateParameter("Время выхода: ", 20, 10, 24, 2); } protected override void Execute() { HideVolume(); int firstValidValue = 0; int period = _period.ValueInt; int timeexit = _timeexit.ValueInt; #region Построение каналов // Верхний канал DataSeries highLevel = Highest.Series(High, period); highLevel = highLevel >> 1; highLevel.Description = string.Format("Единый канал , период: {0}", period); PlotSeries(PricePane, highLevel, Color.Green, LineStyle.Solid, 2); firstValidValue = Math.Max(firstValidValue, highLevel.FirstValidValue); // Нижний канал DataSeries lowLevel = Lowest.Series(Low, period); lowLevel = lowLevel >> 1; PlotSeries(PricePane, lowLevel, Color.Red, LineStyle.Solid, 2); firstValidValue = Math.Max(firstValidValue, lowLevel.FirstValidValue); // Верхний канал размер позиции DataSeries highLevelPS = Highest.Series(Close, period); highLevelPS = highLevelPS >> 1; firstValidValue = Math.Max(firstValidValue, highLevelPS.FirstValidValue); // Нижний канал размер позиции DataSeries lowLevelPS = Lowest.Series(Close, period); lowLevelPS = lowLevelPS >> 1; firstValidValue = Math.Max(firstValidValue, lowLevelPS.FirstValidValue); #endregion for (int bar = firstValidValue; bar < Bars.Count - 1; bar++) { #region FET if (Date[bar].DayOfWeek == System.DayOfWeek.Friday && Date[bar].TimeOfDay >= new System.TimeSpan(timeexit, 0, 0)) { if (IsLastPositionActive) //если позиция есть: ExitAtMarket(bar + 1, LastActivePosition, "ForceExitAtFriday"); continue; } if (CloseAtExpiration(bar)) continue; if (ClosePositionsLogic(bar)) continue; #endregion if (IsLastPositionActive) //если позиция есть: { if (LastActivePosition.PositionType == PositionType.Long) { if (Low[bar] < lowLevel[bar]) { ExitAtLimit(bar + 1, LastActivePosition, (High[bar] + Low[bar]) / 2); } } else //если позиция короткая { if (High[bar] > highLevel[bar]) { ExitAtLimit(bar + 1, LastActivePosition, (High[bar] + Low[bar]) / 2); } } } else //если позиции нет: { if (High[bar] > highLevel[bar]) { RiskStopLevel = lowLevelPS[bar]; BuyAtLimit(bar + 1, (High[bar] + Low[bar]) / 2); } else if (Low[bar] < lowLevel[bar]) { RiskStopLevel = highLevelPS[bar]; ShortAtLimit(bar + 1, (High[bar] + Low[bar]) / 2); } } } } } }
Rename
Your code inherits from a custom interface which has some unavailable methods defined: CloseAtExpiration and ClosePositionsLogic. As both are closed source, are you the author?
yes - this is my code which works in version 6
Great, so you have the skills to use Visual Studio to develop this.
What particular difficulty with the translation are you having?
What particular difficulty with the translation are you having?
How can the Visual Stugio 2019 automatically translate version 6 code into version 7 code?
There is no automatic translation. Please read both posts in this topic for your own translation:
https://www.wealth-lab.com/Discussion/Quick-WL6-9-to-WL7-Translation-Guide-5548
https://www.wealth-lab.com/Discussion/Quick-WL6-9-to-WL7-Translation-Guide-5548
Tell me please, when switching from version 7 to 8, will there also be the same "not big" changes?
No there won’t.
Sorry - I overwrote your question because I accidentally hit "Edit" instead of Reply.
Your question was about the magnitude of changes between versions 6 and 8, and also between version 7 and 8.
Your question was about the magnitude of changes between versions 6 and 8, and also between version 7 and 8.
There's practically no difference in Strategy code between 7 and 8, only in the storage mechanism, which will be handled by a conversion tool.
Version 6 code isn't compatible with Versions 7 or 8, but following the patterns we've shown (see Eugene's link) most strategies can be converted in a matter of minutes - once you get the hang of it.
Version 6 code isn't compatible with Versions 7 or 8, but following the patterns we've shown (see Eugene's link) most strategies can be converted in a matter of minutes - once you get the hang of it.
Your Response
Post
Edit Post
Login is required