Syntax
public Position BuyAtStopLimit(int bar, double price)
public Position BuyAtStopLimit(int bar, double price, string signalName)
public Position ShortAtStopLimit(int bar, double price)
public Position ShortAtStopLimit(int bar, double price, string signalName)
public bool SellAtStopLimit(int bar, Position p, double price)
public bool SellAtStopLimit(int bar, Position p, double price, string signalName)
public bool CoverAtStopLimit(int bar, Position p, double price)
public bool CoverAtStopLimit(int bar, Position p, double price, string signalName)
Parameter Description
| bar |
Bar |
| price |
Limit price
|
| signalName |
(optional) Entry/exit signal name
|
Description
This is a set of four overloaded functions that implement Stop/Limit order types. Original WL4 code created by Dion Kurczek.
Example
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WealthLab;
using WealthLab.Indicators;
using Community.Components; // Stop/Limit orders here
namespace WealthLab.Strategies
{
public class MyStrategy : WealthScript
{
protected override void Execute()
{
PositionHelper ps = new PositionHelper( this ); // Pass WealthScript
for(int bar = 40; bar < Bars.Count; bar++)
{
if (IsLastPositionActive)
{
if( !ps.SellAtStopLimit( bar, LastPosition, Lowest.Series(Low,40)[bar] ) )
ps.CoverAtStopLimit( bar, LastPosition, Highest.Series(High,40)[bar] );
}
else
{
if( ps.BuyAtStopLimit( bar, Highest.Series(High,40)[bar] ) == null )
ps.ShortAtStopLimit( bar, Lowest.Series(Low,40)[bar] );
}
}
}
}
}