- ago
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);                }             }          }       }    } }
0
954
9 Replies

Closed

Bookmark

Sort
- ago
#1
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?
0
- ago
#2
yes - this is my code which works in version 6
0
- ago
#3
Great, so you have the skills to use Visual Studio to develop this.

What particular difficulty with the translation are you having?
0
- ago
#4
How can the Visual Stugio 2019 automatically translate version 6 code into version 7 code?
0
- ago
#5
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
0
- ago
#6
Tell me please, when switching from version 7 to 8, will there also be the same "not big" changes?
0
Glitch8
 ( 12.10% )
- ago
#7
No there won’t.
0
- ago
#8
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.
0
Cone8
 ( 6.32% )
- ago
#9
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.
0

Closed

Bookmark

Sort