Log in to see Cloud of Tags

Wealth-Lab Wiki

DrawTradeLines

RSS

Syntax

public static void DrawTradeLines(this WealthScript ws) public static void DrawTradeLines(this WealthScript ws, bool showSignal)

public static void DrawTradeLines() public static void DrawTradeLines(WealthScript ws, bool showSignal)


Parameter Description

showSignal(optional) Whether to display trade signal names

Description

Wealth-Lab's trade lines only show once you hover a trade entry or exit icon. This lets your chart always appear clutter-free. There are times when you want to display trade lines, and this code, submitted by our user Olivier (ovelten), does just that.

Example

Look at this example:

Example using C# extension methods:

using System; using System.Collections.Generic; using System.Text; using System.Drawing; using WealthLab; using WealthLab.Indicators;

namespace WealthLab.Strategies { public class TradeLinesDemo : WealthScript { protected override void Execute() { DataSeries maFast = SMA.Series(Close, 20); DataSeries maSlow = SMA.Series(Close, 60);

PlotSeries(PricePane,maFast,Color.Red,LineStyle.Solid,2); PlotSeries(PricePane,maSlow,Color.Green,LineStyle.Solid,2);

for(int bar = GetTradingLoopStartBar(maSlow.FirstValidValue); bar < Bars.Count; bar++) { if (IsLastPositionActive) { Position p = LastPosition; if (CrossUnder(bar, maFast, maSlow)) SellAtMarket(bar + 1, p); } else { if (CrossOver(bar, maFast, maSlow)) BuyAtMarket(bar + 1); } } this.DrawTradeLines(); } } }



Legacy syntax example:

using System; using System.Collections.Generic; using System.Text; using System.Drawing; using WealthLab; using WealthLab.Indicators; using Community.Components; // DrawTradeLines here

namespace WealthLab.Strategies { public class TradeLinesDemo : WealthScript { protected override void Execute() { DataSeries maFast = SMA.Series(Close, 20); DataSeries maSlow = SMA.Series(Close, 60);

PlotSeries(PricePane,maFast,Color.Red,LineStyle.Solid,2); PlotSeries(PricePane,maSlow,Color.Green,LineStyle.Solid,2);

for(int bar = GetTradingLoopStartBar(maSlow.FirstValidValue); bar < Bars.Count; bar++) { if (IsLastPositionActive) { Position p = LastPosition; if (CrossUnder(bar, maFast, maSlow)) SellAtMarket(bar + 1, p); } else { if (CrossOver(bar, maFast, maSlow)) BuyAtMarket(bar + 1); } } PositionHelper.DrawTradeLines( this ); // Pass a WealthScript instance as "this" } } }

Important Disclaimer: The information provided by Wealth-Lab is strictly for informational purposes and is not to be construed as advice or solicitation to buy or sell any security.  The owner of Wealth-Lab.com assumes no liability resulting from the use of the material contained herein for investment purposes. By using this web site, you agree to the terms of this disclaimer and our Terms of Use.


ScrewTurn Wiki. Some of the icons created by FamFamFam.