Register Login
Forums    February 6, 2012
TradersStudio Forums
Sessions with variables and Trading Plans
Last Post 05-28-2007 06:34 PM by Jay Bailey. 6 Replies.
Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
Damian Roskill
New Member
New Member
Posts:22

--
10-02-2006 05:54 PM

    I'm a bit confused by how the Trading Plan and Session interact.  Say that you have a session that calls a script that takes a variable as an input (say a simple moving cross entry).  Now when you run the session, you are prompted to enter the parameters associated with the Session.  If I then attach that Session to a Trading Plan, it does not prompt me for the inputs.  How would enter these?  Would they become constants in the Trading Plan?

    Thanks,

    Damian

    mur ang
    Advanced Member
    Advanced Member
    Posts:525

    --
    10-02-2006 08:00 PM

    TradePlan use the last set of inputs which were saved in the session.  You can pass information between session and trade plans.

    This is an example system

    Sub ChanBreakOut_ADX(SLen)
        Dim MinMove
        Dim Hi, Lo

        MinMove = GetActiveMinMove()
        Hi = Highest(High,SLen,0)+MinMove
        Lo = Lowest(Low,SLen,0)-MinMove

        Buy("ChanBuy", 1, Hi ,Stop, Day)
        Sell("ChanSell", 1, Lo , Stop, Day)
        ' This sets a variable which can be retrieved by a trade plan
        MarketVar("ADXval") = ADX(10, 0) - ADX(10, 10)
    End Sub

    This shows how you can pass info from the system to the trade plan.

     

    Sub TP_ADX()
        Dim M As Integer
        Dim S As Integer
        Dim objM As TSProcessor.IMarket
        Dim ADXval As Double

        For S = 0 To TradePlan.SessionCount - 1
            For M = 0 To TradePlan.Session(S).MarketCount - 1
                objM = TradePlan.Session(S).Market(M)
                ADXval = objM.MarketVar("ADXval")

                If ADXval > 0 Then
                    objM.EntryNumUnits = -1
                Else
                    objM.EntryNumUnits = 0
                End If
            Next
        Next
    End Sub

     

    Jay Bailey
    New Member
    New Member
    Posts:6

    --
    05-26-2007 10:48 PM

    I am also confused as to how the session and the trading plans interact.  This is not explained wel in the manual(s).  For example if I write a trading plan which implements money management (how much risk or how many dollars to put into each trade).  How does this affect the session in terms of Buy() or Sell() orders?  Since the system already has Buy() orders which contain a value for LotSize (the size of the trade), I don't understand how the Trading plan tells the session how many contracts or shares the system should use each time there is a Buy() or Sell() order?

    Am I the only one who is confused about this?

     

    mur ang
    Advanced Member
    Advanced Member
    Posts:525

    --
    05-26-2007 11:36 PM

    The Trade Plan can override the default number of units of buy and sell order.

         Here is how Trade Plans work. The Sessions are run for one bar per market for each session and the control is passed to the tradeplan. The tradeplan can override the number of units in the active orders for that day. Setting them to 0 , filters out that trade. In addition you can pass variables between the Session, on a market by market basis and the tradeplans.

      If you follow though the tutorial in the manual where we go though a percent margin trade plan and look though that code , I think it will be a little clearer how this works.

     

    Jay Bailey
    New Member
    New Member
    Posts:6

    --
    05-28-2007 07:52 AM

    So, let me see if I have this correct?

    Let's say I have a trade plan subroutine called

       PerMarginPlanWithTaxes(Percent, Ceiling) ' this is one of the built in ones

    And I have a trading "system" called

       RsiSystem(various parameters) ' this is my system where I determine the entry and exit points and execute Buy() and Sells().

    Now, TradersStudio executes both of these subroutines one bar at a time (presumably the RsiSystem() first, followed by the PerMarginPlanWithTaxes() routine?).  

    RsiSystem() is executing Buy() this, Sell() that, ExitLong(), ExitShort(), etc. for whenever it is appropriate.  Now, let's say that RsiSystem() executes a Buy("LONG", LotSize, 0, CloseEntry, Day), and say LotSize = 5 and ContractLotSize = 100 which would then result in a buy of 5 x 100 = 500 shares.

    Now, the system calls PerMarginPlanWithTaxes() for the same bar, and PerMarginSystemWithTaxes() can override the buy of 500 shares by setting the units to 0, effectively cancelling the trade?  Is that correct?

    Now further, let's say that a trade plan calls for no more than 5% of equity to be used for any one trade in a $100,000 account.  That should limit the trade size to $5,000 correct?  Now, suppose everytime the RsiSystem() called buy for a trade, it was coded to buy 1,000 shares * a price of $8, resulting in a request to buy $8000 worth of stock.   Would the trade plan then simply reject every trade since it exceeded the $5000 equity limit and no trades would execute?

    What I am getting at is that allowing a trade or not (setting the units to 0 or not) seems like a very limiting way to be able to control the size of a trade.  Am I missing something and there is a way to set finer granular control over the size of each trade?

    Sorry, for the long question, but it is important that I understand how this works.

    By the way, except for a few fairly minor bugs, TS 2.5 is working fine on Vista.    I have been writing code and testing it for a couple of weeks.  If you will let me know where to send the bug reports, I will send them to you.

    Thanks,

    Jay Bailey

     

    mur ang
    Advanced Member
    Advanced Member
    Posts:525

    --
    05-28-2007 09:41 AM

    Yes, you are correct on how it works but TradePlans are even more powerful. If you have 5000.00 worth of a stock to buy. It is the tradeplan which can size the number of shares , instead of 0 , you would pass floor(5000/TSClose) for example.

     

      In addition please send all bug reports for vista to Murray@TradersStudio.com as well as Support@TradersStudio.com

    PS, you can send a list of question on what you have found hard to understand to Murray. He is beginning to work on a video series for version 2.5 and this input will be helpful.

     

    Jay Bailey
    New Member
    New Member
    Posts:6

    --
    05-28-2007 06:34 PM

    Thanks very much for the reply.  After I posted the question, I did find in the middle of Page 64 of the TraderStudio Basic 2.5 Manual a good explanation of how the Trading Plan can override the Buy() and Sell() calls.

    I think I mentioned this before, but this is another good example where having a PDF version of all of the manuals would be very helpful.  Instead of paging through the whole paper manual(s), we could simply search the PDF for the keywords we are looking for. 

    Will you be supplying a PDF version?  This would also cut down on printing costs for you.

    Thanks!

    Jay

     

    You are not authorized to post a reply.


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