Monday, December 01, 2008     | Register
TradersStudio Forums
Subject: PGO

You are not authorized to post a reply.   
Author Messages
droskill
Posts:21

01-06-2007 3:13 PM Alert 

Hey guys,

I'm trying to duplicate Mark Johnson's PGO for TradersStudio - here's the code I have from a Chartscript:
{#OptVar1 30;1;50;1}
{#OptVar2 0;-5;10;1}
{#OptVar3 89;5;150;5}

var Bar, MP, MAlen: integer;
var Avg, PGO, PGOlast: float;
var EntLevel, ExitLevel: float;

EntLevel := #OptVar1/10;
ExitLevel := EntLevel*#OptVar2/10;
MAlen := #OptVar3;

for Bar := MAlen to BarCount() - 1 do
begin
{ SetCommission(50);}
  PGO := (PriceClose(Bar) - SMA(Bar, #Close, MAlen))/EMA(Bar,TrueRangeSeries, MAlen);
  Avg := SMA(Bar, #Close, MAlen);
  MP := MarketPosition;

{ Exit position if PGO crosses zero. This happens when the Close crosses Avg. }

  if (MP > 0) and (PGO < ExitLevel) then
    SellAtMarket( Bar+1, Lastposition, 'LX');
  if (MP < 0) and (PGO > -ExitLevel) then
    CoverAtMarket( Bar+1, LastPosition, 'SX');

{ Enter long/short when PGO goes above 3.0 or below -3.0. }
{ Tell $imulator our exit will be at or near Avg. }

  if (MP <= 0) and (PGO > EntLevel) then
  begin
    buyAtMarket( Bar+1, 'LE');
    SetPositionRiskStop(LastPosition, Avg);
  end;

  if (MP >= 0) and (PGO < -EntLevel) then
  begin
    shortAtMarket( Bar+1, 'SE');
    SetPositionRiskStop(LastPosition, Avg);
  end;

end;

And....position size:

var A, fEquity, VP: float;

VP := 0.02;
fEquity := Equity(BarCount-1);

if (fEquity<100000) or (fEquity>1300000) then A := 1
else if (fEquity>100000) and (fEquity<180000) then A := 1+(fEquity-100000)/80000
else if (fEquity>180000) and (fEquity<600000) then A := 2-0.6*(fEquity-180000)/420000
else if (fEquity>600000) and (fEquity<1300000) then A := 1.4-0.4*(fEquity-600000)/700000;

SetPositionSizeFixed( VP*A*fEquity );

Anybody have any thoughts on doing this in TS?  My main question is the OptVar1-3 at the top of the script - I just don't understand what these do or what their function is.

Any help greatly appreciated....can't wait for v2.5!

Best,

Damian

murray
Posts:431

01-06-2007 5:41 PM Alert 

In more primative products like Wealth Labs you need to have a special version of the system to optimize the code. In products like TradersStudio and TradeStation , the same version your run of the system can be used for optimization

OptVar1-3 at the top of the script

 Sets the range for each variable in the optimization in Wealth Labs.

 

droskill
Posts:21

01-06-2007 8:55 PM Alert 
so why are there 4 variables? I would expect there to be two...
You are not authorized to post a reply.



ActiveForums 3.6
TradersStudio® Copyright 2004-2008 All Rights Reserved   |  Privacy Statement  |  Terms Of Use