Think.Generators.ThinkScript 1.0.3

dotnet add package Think.Generators.ThinkScript --version 1.0.3
NuGet\Install-Package Think.Generators.ThinkScript -Version 1.0.3
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Think.Generators.ThinkScript" Version="1.0.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Think.Generators.ThinkScript --version 1.0.3
#r "nuget: Think.Generators.ThinkScript, 1.0.3"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Think.Generators.ThinkScript as a Cake Addin
#addin nuget:?package=Think.Generators.ThinkScript&version=1.0.3

// Install Think.Generators.ThinkScript as a Cake Tool
#tool nuget:?package=Think.Generators.ThinkScript&version=1.0.3

Introduction

See these videos for a detailed look at how to use these libraries https://youtu.be/54q4yWAIHZM https://youtu.be/zc9nL5FIXH4

Use think generator to generate thinkScript files from c#. Once nuget package is added open project and add the following to the package reference

OutputItemType="Analyzer" ReferenceOutputAssembly="true"

To compile a class to thinkscript it must be decorated with the ThinkScriptAttribute as follows:

[ThinkScript("path_to_deployment_folder")]

The type being used must also inherit from RenderBase and override the OnDrawPoint() method. All code within OnDrawPoint will be converted into thinkScript. The following is a sample script that draws a line for each of the stock clean energy industry symbols NIO, MP, LI, LAZR, XPEV, and QS

[ThinkScript(@"C:\Users\moeme\Documents")]
public class EVAnalysis : RenderBase
{
    protected override void OnDrawPoint()
    {
        input ways_back = 6;
        plot avg = (Open["xpev"] + Open["qs"] + Close["mp"] + Open["li", 2 - ways_back] + Close["lazr"] +  Close["nio"]) / 6;
        avg.AssignValueColor(Color.Gray);
        avg.SetLineWeight(3);

        def qs = this.MovingAverage(AverageType.EXPONENTIAL, Close["qs"], 20);
        def mp = this.MovingAverage(AverageType.EXPONENTIAL, Close["mp"], 20);
        def li = this.MovingAverage(AverageType.EXPONENTIAL, Close["li"], 20);
        def xpev = this.MovingAverage(AverageType.EXPONENTIAL, Close["xpev"], 20);
        def lazr = this.MovingAverage(AverageType.EXPONENTIAL, Close["lazr"], 20);
        def nio = this.MovingAverage(AverageType.EXPONENTIAL, Close["nio"], 20);
        def trend_line = (qs + mp + li + xpev + lazr + nio) / 6;

        def g = 4 + qs;

        plot plot_qs = qs;
        plot plot_mp = mp;
        plot plot_li = li;
        plot plot_xpev = xpev;
        plot plot_lazr = lazr;
        plot plot_nio = nio;

        plot plot_trend_line = trend_line;
        plot_trend_line.SetLineWeight(5);
        plot_trend_line.AssignValueColor(Color.Green);

    }
}

The code provided above will produce the a thinkScript file titled EVAnalysisSTUDY.ts at the location c:\temp

input ways_back  = 6;
plot avg  = (Open("xpev") + Open("qs") + Close("mp") + Open("li")[2 - ways_back] + Close("lazr") + Close("nio")) / 6;
avg.AssignValueColor(Color.Gray);
avg.SetLineWeight(3);
def qs  = MovingAverage(AverageType.EXPONENTIAL,Close("qs"),20);
def mp  = MovingAverage(AverageType.EXPONENTIAL,Close("mp"),20);
def li  = MovingAverage(AverageType.EXPONENTIAL,Close("li"),20);
def xpev  = MovingAverage(AverageType.EXPONENTIAL,Close("xpev"),20);
def lazr  = MovingAverage(AverageType.EXPONENTIAL,Close("lazr"),20);
def nio  = MovingAverage(AverageType.EXPONENTIAL,Close("nio"),20);
def trend_line  = (qs + mp + li + xpev + lazr + nio) / 6;
def g  = 4 + qs;
plot plot_qs  = qs;
plot plot_mp  = mp;
plot plot_li  = li;
plot plot_xpev  = xpev;
plot plot_lazr  = lazr;
plot plot_nio  = nio;
plot plot_trend_line  = trend_line;
plot_trend_line.SetLineWeight(5);
plot_trend_line.AssignValueColor(Color.Green);

The file can be imported into ThinkOrSwim through the IDE. For details on how to do that please refer to the ThinkOrSwim documentation.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.3 401 1/25/2021
1.0.2 301 1/25/2021
1.0.1 309 1/24/2021
1.0.0 303 1/24/2021