
Untitled
By: a guest on
Aug 9th, 2012 | syntax:
None | size: 1.09 KB | hits: 12 | expires: Never
using System;
using System.Collections.Generic;
using System.Text;
using WealthLab;
using WealthLab.Indicators;
using System.Drawing;
namespace WealthLabCompile
{
class DipBuyer : WealthScript
{
//Create parameters
StrategyParameter pctDip;
public DipBuyer()
{
pctDip = CreateParameter("Dip Percent", 1.77266852407375, 1, 15, 0.5);
}
protected override void Execute()
{
DataSeries trigger = Bars.Close * (1 - pctDip.Value/100);
// Offset the series by 1 bar to show the crossing
PlotSeries( PricePane, trigger >> 1, Color.Red, LineStyle.Solid, 1 );
for (int bar = 0; bar < Bars.Count; bar++)
{
if (IsLastPositionActive)
SellAtMarket(bar + 1, LastPosition);
BuyAtLimit(bar + 1, trigger[bar]);
}
// Give the largest losers the highest priority for simulations
foreach (Position Pos in Positions)
Pos.Priority = -Pos.NetProfitPercent;
}
}
}