Tradestation: a Basic Crossover Strategy

Discussion in 'Automated Trading' started by Nashequilibrium, Oct 3, 2006.

  1. i see what you are saying.........the my question is, ho do i get the code to buy as soon as the crossover occurs and not at the close of the bar or the next bar?....thanks
     
    #11     Oct 4, 2006
  2. twalker

    twalker

    The MA is calculated not on a tick by tick basis but on close of bar basis. When MA's are close together they may cross several times intrabar so if you set code to buy/sell at every cross you may well end up buying/selling several times in a bar. Best bet for you is to shorten your timeframe.
     
    #12     Oct 5, 2006
  3. Actually, the MA is calculated tick by tick (well, on QT it is). When traders look at MAs what they are seeing is actually snapshots that are taken every X period. For example, a 5 period MA uses the last 4 closes from the previous 4 bars in addition to the current tick to generate an MA of 5 datapoints (ie. the close of the previous 4 bars + the current last value which is continually changing). What you see historically on your chart is just the wiggles removed between closes of the previous bars but you do get to see the influence of every tick. Another way to think of it is generating the EXACT 5 period MA that you would see on a 5M chart but on a 1M chart. The 5 period MA on a 5M spans 25M of market movement snapshot every but using datapoints that are 5M apart. TO get the same EXACT plot on a 1M, I would have to use every 5th 1M bar close in order to generate the same 5M plot. However, to gain the resolution of 1M while retaining a 5M perspective, I simply use the appropriate 1M closes (ie. previous 4 1M bar closes that correspond to the 5M chart) in addition to the 1M close of every subsequent bar. Thus you get the EXACT MA of the 5M chart but with all the resolution of the 1M chart...
     
    #13     Oct 5, 2006
  4. twalker

    twalker

    Sorry , but sounds like a load of waffle to me. An average is calculated over a set of fixed historical points. You need to decide which points these are. If you want whipsaw city then make it every tick but one thing you need to ensure is that you use the same calc method you see as historically successful in your realtime assessment.
     
    #14     Oct 5, 2006
  5. Come on guys....lets not loose perspective, this is a simple question, how do i get the tradestation code to allow me to buy as soon as the cross over occurs....even if it occurs 100 times on that same bar, i don't really care, i just want it to buy/sell as soon as the crossover occurs....thanks!!
     
    #15     Oct 5, 2006
  6. twalker

    twalker

    You need to use tick chart and calc MA on different timeframe using ADE.
    Check out TS forum, it is too involved for me to explain here.
     
    #16     Oct 5, 2006
  7. Definitely tick charts. You strip out the previous N-1 closes that are N minutes apart and then use every current tick as your Nth datapoint of your of your N period MA. This will show all crossovers...

    There aren't any indicators that do this currently (ie. sample tick data synched to an N period timeframe while using the current tick as the Nth datapoint). I did build a generic one but I am not on my TS machine right now...
     
    #17     Oct 5, 2006
  8. Okay lets assume......that the crossover can only occur at the start of a new candle stick and not anytime during the candlestick. How would i program this to buy at that start of that candlestick??
     
    #18     Oct 5, 2006
  9. intrabarorderpersist = true. Could you explain how this works and can i fit it into my code or is there a dialogue box whereby i select this function....thanks
     
    #19     Oct 5, 2006
  10. try:

    "buy this bar;"

    If the bar is refreshed intrabar, then it should generate a market order straight away, without waiting for the close of the bar.
     
    #20     Oct 6, 2006