- ago
What is the WL6: PrintStatusBar() equivalent in WL7?
I tried looking in the api docs and on this forum, but could not find it (may be missed it).

----
Update:
This thread was marked "Closed", so I can't reply with a new comment. So adding it here.

I have checked https://www.wealth-lab.com/Discussion/Quick-WL6-9-to-WL7-Translation-Guide-5548 but couldn't find anything equivalent.

Even in the PDF file, it shows empty.
0
875
Solved
4 Replies

Reply

Bookmark

Sort
- ago
#1
For WL7 equivalents please see Post #2:
https://www.wealth-lab.com/Discussion/Quick-WL6-9-to-WL7-Translation-Guide-5548
0
- ago
#2
QUOTE:
This thread was marked "Closed", so I can't reply with a new comment. So adding it here.

Yes, because this is a duplicate topic. A forum search for "equivalent" would reveal at least two dozen hits with similar pointers to the QuickRef.

QUOTE:
Even in the PDF file, it shows empty.

Which means there is no equivalent or even a workaround. It was a seldom used cosmetic method.
0
Glitch8
 ( 12.53% )
- ago
#3
You can use the AddLogItem method from the IWLHost interface to write to the WL7 status bar. Here's an example:

CODE:
using WealthLab.Backtest; using System.Threading; using WealthLab.Core; using System.Drawing; namespace WealthScript1 { public class MyStrategy : UserStrategyBase { //Initialize public override void Initialize(BarHistory bars) { } //Execute public override void Execute(BarHistory bars, int idx) {          if (idx % 100 == 0)          {             WLHost.Instance.AddLogItem("Strategy", "Bar Number: " + idx, Color.Green);             Thread.Sleep(200);          } } } }
0
Best Answer
- ago
#4
Excellent! This is exactly what I was looking for. Thanks Glitch!

This functionality is very helpful in giving feedback on the progress of the script for a long running script!

Last night when I didn't have a way to get feedback from my script, I added logging. Here is the code to add logging to your script in case somebody finds it useful:
CODE:
// Logger.cs using System; using System.IO; namespace WLHnChart.Common { public class Logger { StreamWriter streamWriter = null; public Logger(string filePath, bool append) { if (filePath == null) { filePath = string.Format("{0}\\wllog.txt", Path.GetTempPath()); } if (append) { streamWriter = File.AppendText(filePath); } else { streamWriter = File.CreateText(filePath); } streamWriter.AutoFlush = true; } public void Info(string text) { streamWriter.Write(string.Format("{0}: {1}", DateTime.Now, text)); } public void Infoln(string text) { streamWriter.WriteLine(string.Format("{0}: {1}", DateTime.Now, text)); } public void Close() { if (streamWriter != null) { streamWriter.Close(); } } } } // Screen50d.cs using System.Drawing; using System.Collections.Generic; using WealthLab.Core; using WealthLab.Indicators; using WealthLab.Backtest; using WLHnChart.Common; namespace WLHnChart { class Screen50d : UserStrategyBase {       Logger logger; //create indicators and other objects here, this is executed prior to the main trading loop public override void Initialize(BarHistory bars) {          logger = new Logger(@"C:\WLD\log.Screen50d.txt", false);          logger.Infoln("Initialize(): Script started");          ScreenAll(bars);       }       public override void Execute(BarHistory bars, int idx) { }       public override void BacktestBegin()       {          base.BacktestBegin();          WriteToDebugLog("BACKTEST BEGIN");       }       public override void BacktestComplete()       {          base.BacktestComplete();          WriteToDebugLog("BACKTEST COMPLETE");          logger.Close();          logger = null;       }       public void ScreenAll(BarHistory primaryBars)       {          var initialListFile = @"C:\WLD\streamer\lists\15-MyLists\Big List.txt";          var list50dFile = @"C:\WLD\streamer\lists\15-MyLists\Wl-50d.txt";          var list50dAthFile = @"C:\WLD\streamer\lists\15-MyLists\Wl-50d-ath.txt";          var list50dUpFile = @"C:\WLD\streamer\lists\15-MyLists\Wl-50d-up.txt";          var initialList = Utils.ReadSymbols(initialListFile);          logger.Infoln(string.Format("Initial Symbols Count = {0}", initialList.Count));          var list50d = new List<string>();          var list50dAth = new List<string>();          var list50dUp = new List<string>();          // Find symbols which are closer to 50d by 5%          logger.Infoln(string.Format("=====> Running Screen50dNear"));          Screen50dNear(primaryBars, initialList, list50d, 5);          Utils.WriteSymobls(list50dFile, list50d);          // Find symbols which are ATH in last 1.5M and close to 50d          logger.Infoln(string.Format("=====> Running ScreenAth"));          ScreenAth(primaryBars, list50d, list50dAth, 33);          Utils.WriteSymobls(list50dAthFile, list50dAth);          logger.Infoln(string.Format("=====> Running ScreenUp"));          ScreenUp(primaryBars, list50d, list50dUp, 50);          Utils.WriteSymobls(list50dUpFile, list50dUp);       }       public void Screen50dNear(BarHistory primaryBars, List<string> inSymbolList, List<string> outSymbolList, double cutoff) {          int minBars = 60;          int count = 0;          foreach (string symbol in inSymbolList)          {             count++;             logger.Infoln("Processing: Screen50dNear: " + count + " / " + inSymbolList.Count + " : " + symbol + " ");             WLHost.Instance.AddLogItem("Strategy", "Processing: Screen50dNear: " + count + " / " + inSymbolList.Count + " : " + symbol + " ", Color.Green);             BarHistory barHistory = GetHistory(primaryBars, symbol);             if (barHistory == null)             {                WriteToDebugLog(symbol + ": No data found. Skipping...");                logger.Infoln(symbol + ": No data found. Skipping...");                continue;             }             if (barHistory.Count < minBars)             {                WriteToDebugLog(symbol + ": Number of bars = " + barHistory.Count + ". Skipping...");                logger.Infoln(symbol + ": Number of bars = " + barHistory.Count + ". Skipping...");                continue;             }             IndicatorBase sma50;             sma50 = SMA.Series(barHistory.Close, 50);             var closePrice = barHistory.Close[barHistory.Count - 1];             var sma50Price = sma50[barHistory.Count - 1];             double priceAbove50dPct = 100.0 * (closePrice - sma50Price) / sma50Price;             if (priceAbove50dPct < 5)             {                outSymbolList.Add(symbol);             }          }       }       public void ScreenAth(BarHistory primaryBars, List<string> inSymbolList, List<string> outSymbolList, int lookback)       {          int minBars = 60;          int count = 0;          foreach (string symbol in inSymbolList)          {             count++;             logger.Infoln("Processing: ScreenAth: " + count + " / " + inSymbolList.Count + " : " + symbol + " ");             WLHost.Instance.AddLogItem("Strategy", "Processing: ScreenAth: " + count + " / " + inSymbolList.Count + " : " + symbol + " ", Color.Green);             BarHistory barHistory = GetHistory(primaryBars, symbol);             if (barHistory == null)             {                WriteToDebugLog(symbol + ": No data found. Skipping...");                logger.Infoln(symbol + ": No data found. Skipping...");                continue;             }             if (barHistory.Count < minBars)             {                WriteToDebugLog(symbol + ": Number of bars = " + barHistory.Count + ". Skipping...");                logger.Infoln(symbol + ": Number of bars = " + barHistory.Count + ". Skipping...");                continue;             }             int athDays = 251; // default - 1 year             if (barHistory.Count < athDays) {                athDays = barHistory.Count;             }             int highestBar = barHistory.Close.GetHighestBar(barHistory.Count - 1, athDays);             // Highest bar should be within lookback bars             if (highestBar >= barHistory.Count-lookback) {                outSymbolList.Add(symbol); }          }       }       public void ScreenUp(BarHistory primaryBars, List<string> inSymbolList, List<string> outSymbolList, int smaParam)       {          int minBars = 60;          int count = 0;          foreach (string symbol in inSymbolList)          {             count++;             logger.Infoln("Processing: ScreenUp: " + count + " / " + inSymbolList.Count + " : " + symbol + " ");             WLHost.Instance.AddLogItem("Strategy", "Processing: ScreenUp: " + count + " / " + inSymbolList.Count + " : " + symbol + " ", Color.Green);             BarHistory barHistory = GetHistory(primaryBars, symbol);             if (barHistory == null)             {                WriteToDebugLog(symbol + ": No data found. Skipping...");                logger.Infoln(symbol + ": No data found. Skipping...");                continue;             }             if (barHistory.Count < minBars)             {                WriteToDebugLog(symbol + ": Number of bars = " + barHistory.Count + ". Skipping...");                logger.Infoln(symbol + ": Number of bars = " + barHistory.Count + ". Skipping...");                continue;             }             IndicatorBase sma = SMA.Series(barHistory.Close, smaParam);             if (sma[sma.Count-1] > sma[sma.Count-2])             {                outSymbolList.Add(symbol);             }          }       }    } }
1

Reply

Bookmark

Sort