Register Login
Forums    February 9, 2012
TradersStudio Forums
PGO
Last Post 01-06-2007 08:55 PM by Damian Roskill. 2 Replies.
Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
Damian Roskill
New Member
New Member
Posts:22

--
01-06-2007 03:13 PM

    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

    mur ang
    Advanced Member
    Advanced Member
    Posts:525

    --
    01-06-2007 05:41 PM

    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.

     

    Damian Roskill
    New Member
    New Member
    Posts:22

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


     TradersStudio, Inc. ® Copyright 2004-2012 All Rights Reserved   Terms Of Use  Privacy Statement