DrawTradeLines

Modified on 2013/05/11 10:45 by Eugene — Categorized as: Community Components

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" } } }