Home     News     Software     Order     Download     Support     Publications     Research     Contacts  
   Home

   News

  •  

  • Latest News
      
  •  

  • World News
      
  •  

  • Our achievements
      
       Software

  •  

  • TradeStation Solutions
      
  •  

  • Portfolio Software
      
  •  

  • Genetic Optimization
      
  •  

  • eSignal Solutions
      
  •  

  • Matlab & TradeStation Solutions
      
  •  

  • Excel & TradeStation Solutions
      
       Order

       Download

  •  

  • Free Download
      
  •  

  • Update
      
       Support

  •  

  • Online Help
      
  •  

  • Upgrade Policy
      
       Publications

  •  

  • Fractal dimension – numerical characteristic of trend
      
  •  

  • Volatility Models
      
  •  

  • Genetic optimization. Application in TradeStation environment.
      
  •  

  • Trading Systems Free
      
  •  

  • TradeStation converted Signals for Genetic Optimizer
      
  •  

  • TradeStation & Matlab Link
      
  •  

  • Wavelet Transform
      
  •  

  • Portfolio Analyzer
      
  •  

  • Genetic Optimizer
      
  •  

  • Money Management
      
       Research

  •  

  • TS Excel Link's using example
      
  •  

  • Strategy Optimization, Curve Fitting and Walk Forward Analysis.
      
  •  

  • Entropy Indicator in TradeStation using Matlab
      
  •  

  • TradeStaion Genetic Optimizer
      
       Contacts

    Genetic Optimizer: Walk-Forward Optimization

    Simple example of WFO.

    Genetic Optimizer is used as optimizator.
    Walk-Forward Optimization is demonstrated in this example on simple strategy that consists of moving averages and stop-loss exits.

    Entry parameters:
    SampleStart - Number of bar when segment Sample begins.
    SampleLen - Length of Sample segment.
    OOSLen - Length of Out of Sample segment (OOS).
    Gen - Number of iterations for Genetic optmizer.
    MYStrategyName - Name of strategy that is used for saving current population.


    In order to perform WFO it's necessary to optimization parameters in certain way.
    To do it you need to set optimization in TradeStation for parameter SampleStart from 1 to number of bars K with step that is equal to length of OOS segment.
    SampleLen should exeed length of OOS several times. Also we set optimization on parameter Gen from 1 to M with step 1.

    K - should be more than SampleLen + OOSLen + Max number of bars strategy will reference
    M - should be more than size of population - in this example size of population = 50.


    Example of setting parameters:

    SampleStart = 1..1400:20
    SampleLen = 200.
    OOSLen = 20
    Gen = 1..100:1
    MyStrategyName = “WFO_Test”


    Work of trading Strategy.
    For every value of SampleStart cycle of optimization is performed Gen = 1..100:1.
    Results of optimization for every value of SampleStart are exported into window using Print.

    Results.

    On picture below results of testing are showen using parameter above. Test of the strategy with WFO.

    Picture 1. Results of WFO using Genetic Optimizer for TradeStation.

    EasyLanguage:
     
    {******************************************************************* 
    Name: TS.GO.Ex.WFO 
    Analysis Type: Strategy 
    Description: Example Strategy for Genetic Optimizer v.1.x or higher 
    Example of simple trading system to show the possibilities  
    of Genetic Optimizer for TradeStation. 
    The system is based on 2 moving average crossover.  
    Buy signal is generated when fast moving average crosses over slow moving average.  
    Additionaly Stop-loss is included in the system. 
    Used: TSGO12.dll 
    Provided By: Trade Smart Research (c) Copyright 2001 - 2004 
             www.tsresearchgroup.com 
    *******************************************************************}
      
     
    Input: SampleStart(1), { Bar number for Sample start }  
           SampleLen(100), { Length of Sample }  
           OOSLen(20),     { Length of Out of Sample }  
           Gen(1),         { Iteration nuber }  
           MyStrategyName("MySystem1" ); 
     
    { Declaration of variables }  
    Vars: Len1(0),Len2(0),Len3(0),Len4(0),SL(0), 
          LastRun(0),R(0),K(0); 
      
    { ---------------------------------------------------------------------- }  
    { The Genetic Optimizer initialization and the definition of genes }  
     
    If CurrentBar = 1 Then Begin 
     
    { This block runs on every run of strategy on the first bar. 
     
      The function TS.GO.Start is called having the Parameter that defines 
      filename for milestones. 
      All the tunings of an optimizer and current population are stored in the 
      file, that allows to continue an optimization after break, or to draw 
      the input/output signals after the opening the TradeStation workspace with 
      the strategy. It is possible to open this file in graphic interface for viewing 
      population.}
      
     
        R = TS.GO.Start(MyStrategyName + "("  + GetSymbolName + ").rgo" ); 
     
    { This block runs when the optimization is starting for the first bar only. }  
     
        If Gen = 1 Then Begin 
     
    { The initializing of optimizer determination of genes and the population 
      regime is executed (see the description of functions). 
      We start optimizer with last population in a given example. }
      
     
            R = TS.GO.Mode(1); 
            R = TS.GO.Popul(50); 
     
    { Output results of WFO }  
     
            If SampleStart > 1 Then  
            print
                TS.GO.Get("Sample.Start" ,1), 
                TS.GO.Get("Sample.End" ,1), 
                TS.GO.Get("OOS.Start" ,1), 
                TS.GO.Get("OOS.End" ,1), 
                TS.GO.Get("Sample.Fitness" ,1), 
                TS.GO.Get("OOS.Fitness" ,1), 
                TS.GO.Get("Sample.Profit" ,1), 
                TS.GO.Get("OOS.Profit" ,1), 
                TS.GO.Get("Len1" ,1), 
                TS.GO.Get("Len2" ,1), 
                TS.GO.Get("Len3" ,1), 
                TS.GO.Get("Len4" ,1), 
                TS.GO.Get("SL" ,1) 
                ) 
            else ClearDebug
     
    { Define user variables }  
                 
            R = TS.GO.Var("Generation" ); 
            R = TS.GO.Var("LastBar" ); 
     
            R = TS.GO.Var("Sample.Start" ); 
            R = TS.GO.Var("Sample.End" ); 
            R = TS.GO.Var("Sample.Fitness" ); 
            R = TS.GO.Var("Sample.Profit" ); 
     
            R = TS.GO.Var("OOS.Start" ); 
            R = TS.GO.Var("OOS.End" ); 
            R = TS.GO.Var("OOS.Fitness" ); 
            R = TS.GO.Var("OOS.Profit" ); 
             
    { The description of 5 genes is as follows. 
      The First parameter - a gene number. If it's zero, generate gene number. 
      The Second parameter - a chromosome number that the gene belongs to. 
      The Third parameter - a minimum parameter value. 
      The Fourth parameter - a maximum parameter value. 
      The Fifth parameter - an increment of the parameter. It is possible to assign 0. 
      Sixth parameter - a name of the gene, one can use it as a commentary in 
      the graphic interface. }
      
     
            K = TS.GO.Chrom("Buy.Signal" ); 
            R = TS.GO.Gen("Len1" ,K,1,50,1); 
            R = TS.GO.Gen("Len2" ,K,1,50,1); 
     
            K = TS.GO.Chrom("Sell.Signal" ); 
            R = TS.GO.Gen("Len3" ,K,1,50,1); 
            R = TS.GO.Gen("Len4" ,K,1,50,1); 
     
            K = TS.GO.Chrom("StopLoss" ); 
            R = TS.GO.Gen("SL" ,K,100,1000,100); 
            R = TS.GO.ShowViewer
     
        End;  
          
    { Start the new Iteration }  
     
        LastRun = TS.GO.Next(Gen); 
     
    { Save generation number and parameters }  
     
        R = TS.GO.Set("Generation" ,Gen); 
     
        R = TS.GO.Set("Sample.Start" ,SampleStart); 
        R = TS.GO.Set("Sample.End"  ,SampleStart + SampleLen - 1); 
        R = TS.GO.Set("OOS.Start" ,SampleStart + SampleLen); 
        R = TS.GO.Set("OOS.End"   ,SampleStart + SampleLen + OOSLen - 1); 
     
    { Get values of genes }  
     
        Len1 = TS.GO.Get("Len1" ,0); 
        Len2 = TS.GO.Get("Len2" ,0); 
        Len3 = TS.GO.Get("Len3" ,0); 
        Len4 = TS.GO.Get("Len4" ,0); 
        SL   = TS.GO.Get("SL"   ,0); 
    End
     
    { ---------------------------------------------------------------------- }  
    { Begin the basic strategy code. }  
     
    { Set up the stop-loss parameter. }  
     
    SetStopPosition
    SetStopLoss(SL); 
     
    { The Moving Averages Calculation. }  
     
    Value1 = AverageFC(C,Len1); 
    Value2 = AverageFC(C,Len2); 
    Value3 = AverageFC(C,Len3); 
    Value4 = AverageFC(C,Len4); 
     
    { Generation of signals by moving averages crossover. 
      According to the signal, short positions are reversed to long positions and 
      vise versa. Besides, positions can be stopped by stop-loss and 
      trailing-stop orders. }
      
     
    if Value1 cross over  Value2 then Buy This Bar ; 
    if Value3 cross below Value4 then Sell This Bar ; 
     
    { End the basic strategy code. }  
    { ---------------------------------------------------------------------- }  
     
    Vars:    Fitness(0),Fitness1(0),Fitness2(0),Fitness3(0), 
            Profit1(0),Profit2(0),Profit3(0); 
     
    { Calculation an optimization criteria. The simplest 
      criteria is used here. }
      
     
    Fitness = NetProfit
     
    { Save fitness for Sample Start }  
    if CurrentBar = SampleStart Then Begin 
        Fitness1 = Fitness; 
        Profit1  = NetProfit
    end
     
    { Save fitness for Sample End }  
    if CurrentBar = SampleStart + SampleLen Then Begin 
        Fitness2 = Fitness; 
        Profit2  = NetProfit
    end
     
    { Save fitness for Out of Sample End }  
    if CurrentBar = SampleStart + SampleLen + OOSLen Then Begin 
        Fitness3 = Fitness; 
        Profit3  = NetProfit
    end
     
    if LastBarOnChart Then Begin 
     
    { A fitness value is passed to the genetic optimizer on the last bar. 
      The sample fitness is difference from start sample fitness  
      and end sample fitness. }
      
     
        R = TS.GO.Set("LastBar" ,CurrentBar); 
        R = TS.GO.Set("Sample.Fitness" , Fitness2 - Fitness1); 
        R = TS.GO.Set("Sample.Profit" , Profit2 - Profit1); 
        R = TS.GO.Set("OOS.Fitness" , Fitness3 - Fitness2); 
        R = TS.GO.Set("OOS.Profit" , Profit3 - Profit2); 
     
        R = TS.GO.Fitness(Fitness2 - Fitness1); 
     
    { One can look at all tested variants, assigning a print of the gene 
      values for each generation.  
      In PowerEditor in debug window to the debugger.}
      
     
    end
     
    {***** Copyright (c) 2001-2004 Trade Smart Research, Ltd.  
       All rights reserved. www.tsresearchgroup.com  
       Trade Smart Research reserves the right to modify or overwrite this analysis technique  
       with each release. *****}
      


    <<< Genetic Optimizer
    Trading System Example TS.GO.12PRO >>>


    Developed by: webdesign.tria.lv  

      About | Privacy Statement | Terms of use | TradeStation Disclaimer

    Copyright © 2004 TS Smart Research

    time: 0.0634 | queries: 3