Есть стратегия для Wealth-Lab 4. Хочу протестировать ее под WLD .NET, подскажите как ее модифицировать
---текст
[CODE]
(*Description...
This script uses Williams %R for intraday and short-term trading, and gets lots of trades. To change fr om intraday to short-term change 'IntradayTrades' to false. The days to expiry and the profit target can be set separately for long and short positions.
Credit for this script goes to a piece of code fr om the Wealthlab Developer help file, and jrbyrd who wrote "A MultiPosition Buy-At-Limit System using Adaptive BBands".
*)
var INTRADAYTRADES: boolean;
var SHORTDAYS, LONGDAYS, LONGPROFITTARGET, SHORTPROFITTARGET, WILLIAMSHIGH, WILLIAMSLOW, EMAPERIOD, ATRPERIOD, START, NLASTVARBAR, MT2, DE, PERIOD, MT, UT, X1, DT, XSERIES, UT2, DT2, BBUPPER, BBLOWER, LOWFACTOR, HIGHFACTOR, P: integer;
{#OptVar5 Default: 3}
{#OptVar4 Default: 27}
{#OptVar3 Default: 115}
{#OptVar2 Default: 85}
{#OptVar1 Default: 15}
{This is wh ere you can adjust most of the
variables to optimize the script }
ShortDays := 2;
LongDays := 2;
LongProfitTarget := 10;
ShortProfitTarget := 5;
WilliamsHigh := 75;
WilliamsLow := 25;
IntradayTrades := false;
HideVolume; {Can delete this line if you need volume}
{------------------}
EMAPeriod := 9;
ATRPeriod := 30;
Start := EMAPeriod + ATRPeriod;
nLastVarBar := BarCount() - 1;
{Williams %R}
var X: float;
var PCTRPANE, SMOOTHR, BAR: integer;
PctRPane := CreatePane( 75, true, true );
PlotSeries( WilliamsRSeries( 14 ), PctRPane, 511, #Thick );
SmoothR := WilderMASeries( WilliamsRSeries( 14 ), 4 );
DrawLabel( 'WilliamsR( 14 )', PctRPane );
PlotSeries( SmoothR, PctRPane, #Black, #Thin );
for Bar := 20 to BarCount - 1 do
begin
x := GetSeriesValue( Bar, SmoothR );
if x < 20 then
SetBackgroundColor( Bar, #RedBkg )
else if x > 80 then
SetBackgroundColor( Bar, #BlueBkg );
end;
mt2 := CreateSeries();
de := #OptVar1 / 10; {Nr Std Dev's}
period := #OptVar5;
mt := EMASeries(#Close, period);
ut := EMASeries(mt, period);
x1 := ((2 * period) / (period + 1));
dt := MultiplySeriesValue(ut, x1);
dt := SubtractSeries(dt, ut);
dt := DivideSeriesValue(dt, ((period - 1) / (period + 1)) );
xseries := SubtractSeries(#Close, dt);
for Bar := period + 1 to BarCount - 1 do
begin
x := abs(GetSeriesValue(Bar, xseries));
SetSeriesValue(Bar, mt2, x);
end;
mt2 := EMASeries(mt2, period);
ut2 := EMASeries(mt2, period);
dt2 := MultiplySeriesValue(ut2, x1);
dt2 := SubtractSeries(dt2, ut2);
dt2 := DivideSeriesValue(dt2, ((period - 1) / (period + 1)) );
xseries := MultiplySeriesValue(dt2, de);
BBUpper := AddSeries(dt, xseries);
BBLower := SubtractSeries(dt, xseries);
PlotSeries(BBUpper, 0, #Blue, 0);
PlotSeries(BBLower, 0, #Green, 0);
PlotSeries(dt, 0, #Red, 0);
LowFactor := #OptVar2 / 100;
HighFactor := #OptVar3/ 100;
{ Implement Trading Rules }
{BuyLimitPrice := 0.0; }
InstallStopLoss( 5 );
{InstallProfitTarget ( ProfitTarget );}
for Bar := Start + 1 to nLastVarBar do
begin
ApplyAutoStops( Bar );
if GetSeriesValue( Bar, WilliamsRSeries( 14 )) < WilliamsLow then
if not LastActivePosition >= 0 then
ShortAtLimit(Bar + 1, (GetSeriesValue(Bar, BBUpper) * 1.05), '' );
if GetSeriesValue( Bar, WilliamsRSeries( 14 )) > WilliamsHigh then
if not LastActivePosition >= 0 then
BuyAtLim it(Bar + 1, (GetSeriesValue(Bar, BBLower) * 0.95), '' );
for P := 0 to PositionCount - 1 do
begin
if PositionActive( P ) then
begin
if PositionLong( P ) then
if bar + 1 - positionEntryBar( p ) > 0 then
if bar + 1 - positionEntryBar( p ) >= LongDays then
begin
SellAtMarket( Bar + 1, P, 'LongDaysExpired' );
end;
if PositionLong( P ) then
if bar + 1 - positionEntryBar( p ) > 0 then
if PositionProfit( P )/PriceClose(Bar) >= LongProfitTarget then
begin
SellAtMarket( Bar + 1, P, 'LongProfitTarget' );
end;
if not PositionLong( P )then
if bar + 1 - positionEntryBar( p ) > 0 then
if bar + 1 - positionEntryBar( p ) >= ShortDays then
begin;
CoverAtMarket( Bar + 1, P, 'ShortDaysExpired' );
end;
if not PositionLong( P )then
if bar + 1 - positionEntryBar( p ) > 0 then
if PositionProfit( P )/PriceClose(Bar) >= ShortProfitTarget then
begin;
CoverAtMarket( Bar + 1, P, 'ShortProfitTarget' );
end;
if PositionLong( P ) then
if (IntradayTrades) then
if PositionProfit( P )/PriceClose(Bar) >= LongProfitTarget then
begin
SellAtMarket( Bar + 1, P, 'LongProfitTarget' );
end;
if not PositionLong( P )then
if (IntradayTrades) then
if PositionProfit( P )/PriceClose(Bar) >= ShortProfitTarget then
begin;
CoverAtMarket( Bar + 1, P, 'ShortProfitTarget' );
end;
end;
end;
end;
[/CODE]
---конец