Register Login
Forums    February 9, 2012
TradersStudio Forums
randomized entries
Last Post 12-07-2006 10:23 PM by David Hubbard. 2 Replies.
Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
David Rooke
New Member
New Member
Posts:22

--
11-01-2006 09:59 AM

    Hi,

    Does tradersstudio support the concept of random trade entries? This is the best way I can think of to test exits against a consistent background of entries.

    If it does how does it maximize entropy?

    If there are better ways of doing this please let me know...

     

    D

    mur ang
    Advanced Member
    Advanced Member
    Posts:525

    --
    11-01-2006 10:07 AM

    You would have to create them using the random function in the language.

    Rnd( maxVal)

     

    David Hubbard
    New Member
    New Member
    Posts:6

    --
    12-07-2006 10:23 PM

    Here is a copy of code where I implemented a random entry to test some basic exits.  Normally I set the bias parameter at 0.5.  If the random number is above 0.5 the system goes long.  If it is under 0.5 it goes short.  Here it is:

    Sub DHRandomEntry(Bias, mmstp, pflim, maxhold)
       
    'Random entry parameter
    'Stop loss parameter
    'Profit target limit


    'maximum holding period

        Dim Trigger
        Dim Signal
        Dim ATR
       

        If BarNumber=FirstBar Then
            Trigger = 0
            Signal = 0
            ATR = 0
           
        End If

        trigger =Rnd()
        If trigger < bias Then
            signal = -1
        End If
        If trigger >1 - bias Then
            signal =1
        End If
        ATR =Xaverage(TrueRange, 50, 0)
    'Random Entry
        If signal =1 Then
            Buy("Rnd_Mkt.LE", 1, 0, Market, Day)
        End If
        If signal =-1 Then
            Sell("Rnd_Mkt.SE", 1, 0, Market, Day)
        End If
    'Standardized Exits
        If MarketPosition[0] >0 Then
            ExitLong("MM.LX", "", 1, EntryPrice - mmstp*ATR, Stop, Day)
            ExitLong("Pt.LX", "", 1, EntryPrice +pflim*ATR, limit, Day)
            If barssinceentry -1>=maxhold Then
                ExitLong("Hold.LX", "", 1, 0, market, Day)
            End If
        End If
        If MarketPosition[0] <0 Then
            ExitShort("MM.SX", "", 1, EntryPrice +mmstp*ATR, Stop, Day)
            ExitShort("Pt.SX", "", 1, EntryPrice - pflim*ATR, limit, Day)
            If barssinceentry -1>=maxhold Then
                ExitShort("Hold.SX", "", 1, 0, market, Day)
            End If
        End If
    End Sub

    You are not authorized to post a reply.


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