Excel Link Dll: TradeStation Indicator Example
Sample indicator TS.LINK.EXAMPLE:
| EasyLanguage: | {TSGO_TEST1 (Signal) Optimization and OOS testing Input Parameters: Gen - input parameter, that assigns the number of generations. Dstart – Bar number from the end of data, start In Sample data. Dstop - Bar number from the end of data, end In Sample data for example - Dstop = 365 - OOS is 365 bars.} Inputs: Gen(1),Dstart(60000),Dstop(0); DefineDLLFunc: "ts_GO.dll", int, "GO_Start",LPSTR; DefineDLLFunc: "ts_GO.dll", int, "GO_Set_Mode",int; DefineDLLFunc: "ts_GO.dll", int, "GO_Set_Npar",int; DefineDLLFunc: "ts_GO.dll", int, "GO_Def_Gen",int,int,float,float,float,LPSTR; DefineDLLFunc: "ts_GO.dll", int, "GO_Set_Population",int; DefineDLLFunc: "ts_GO.dll", int, "GO_Next",int; DefineDLLFunc: "ts_GO.dll", float, "GO_Get",int; DefineDLLFunc: "ts_GO.dll", int, "GO_Fitness",float; Vars: Len1(0),Len2(0),Len3(0),Len4(0),SL(0),DT(0),FA(0),PC(0),Fitness(0); { ---------------------------------------------------------------------- }
|
| MetaStock: | PK:=Zig(C,10,%)<Ref(Zig(C,10,%),-1)AND Ref(Zig(C,10,%),-1)>Ref(Zig(C,10,%),-2); TR:=Zig(C,10,%)>Ref(Zig(C,10,%),-1) AND Ref(Zig(C,10,%),-1)<Ref(Zig(C,10,%),-2); pk1:=PeakBars(1,C,10); pk2:=PeakBars(2,C,10); (ValueWhen(1,pk,Ref(C,-1))/ValueWhen(2,pk,Ref(C,-1))>.96 AND ValueWhen(1,pk,Ref(C,-1))/ValueWhen(2,pk,Ref(C,-1))<1.04) AND pk2-pk1>=10 AND Cross(ValueWhen(1,tr,Ref(C,-1)),C) pk:=Zig(C,10,%)<Ref(Zig(C,10,%),-1) AND Ref(Zig(C,10,%),-1)>Ref(Zig(C,10,%),-2); tr:=Zig(C,10,%)>Ref(Zig(C,10,%),-1) AND Ref(Zig(C,10,%),-1)<Ref(Zig(C,10,%),-2); tr1:=TroughBars(1,C,10); tr2:=TroughBars(2,C,10); (ValueWhen(1,tr,Ref(C,-1))/ValueWhen(2,tr,Ref(C,-1))>.96 AND ValueWhen(1,tr,Ref(C,-1))/ValueWhen(2,tr,Ref(C,-1))<1.04) AND tr2-tr1>=10 AND Cross(C,ValueWhen(1,pk,Ref(C,-1))) |
| WealthScript: | var O, H, L, C, O1, C1: float; var HO, HH, HL, HC, BAR, HPANE, HADIFFCO, HAINDPANE: integer; { Create Heikin-Ashi OHLC Price Series } HO := CreateSeries; HH := CreateSeries; HL := CreateSeries; HC := CreateSeries; { Initialize first bar to values of price } @HO[0] := PriceOpen( 0 ); @HH[0] := PriceHigh( 0 ); @HL[0] := PriceLow( 0 ); @HC[0] := PriceClose( 0 ); { Populate Heikin-Ashi Chart } for Bar := 1 to BarCount - 1 do begin o := PriceOpen( Bar ); h := PriceHigh( Bar ); l := PriceLow( Bar ); c := PriceClose( Bar ); o1 := @HO[ Bar - 1 ]; c1 := @HC[ Bar - 1 ]; @HC[Bar] := ( o + h + l + c ) / 4; @HO[Bar] := ( o1 + c1 ) / 2; @HH[Bar] := Max( Max( o1, c1 ), h ); @HL[Bar] := Min( Min( o1, c1 ), l ); end; { Plot it } hPane := CreatePane( 250, true, true ); PlotSyntheticSymbol( 'heikin-ashi', HO, HH, HL, HC, hPane, #Navy, #Candle ); DrawLabel( 'heikin-ashi', hPane ); { Calculate and plot the haDiffCO indicator } HideVolume; haDiffCO := SubtractSeries( HC, HO ); haIndPane := CreatePane( 100, false, true ); PlotSeriesLabel( haDiffCO, haIndPane, #Lime, #ThickHist, 'haDiffCO' ); PlotSeriesLabel( SMASeries( haDiffCO, 5 ), haIndPane, #Green, #Thick, 'SMA(5)' ); |
|