TradersStudio Thread

Discussion in 'Trading Software' started by Gyles, Oct 3, 2008.

  1. Regarding your query, shall try to give more details later, however, Gyles has already discussed in the “Journal” thread that “A triple MA does much better than a Dual one”. Please see below:

    http://www.elitetrader.com/vb/showthread.php?s=&postid=2026762#post2026762
     
    #21     Nov 26, 2008
  2. Thanks, SuperCruz for the reply. :)
     
    #22     Dec 1, 2008
  3. abarker

    abarker

    This is my first post. I have purchased TraderStudio software but have no programming experience. I have gone through the manuals and many websites including this one looking for some help (I have emailed TradersStudio via contact details on their website but have not heard from them after a couple of weeks now.

    I am trying to set up a "session" where I enter on a Moving Average crossover (which is no problem) but once in the trade I would only exit on a Stop Loss or a Profit Target exit. I do not want to exit on a reversal signal (like the moving averages crosses back the other way).

    I have included my code below but it does not do what I want it to. I know why it is going wrong but I cannot fix the problem due to my limited knowledge. The code I have below can get me into a trade but it is using all of my Buy, Sell, Stop Loss and Target commands to enter or exit trades. I know I need to include a MArket Position order in there to tell it to ignore another exit order once one of them is acted on.

    Can some one offer some assistance either on the coding or to direct me where to find a bit more info on learning the programming language.


    Code:
    Sub MovAveXoverSystem06 (SLen As Integer, LLen As Integer, 
    ATRLen As Integer, ExSL As Integer, ExPT As Integer)
    
    'SLen is the Short Moving Average number of previous bars.
    'LLen is the Long Moving Average number of previous bars.
    'ATRLen is the ATR number of previous bars.
    'ExSL is the ATR multiple for the Stop Loss.
    'ExPT is the ATR multiple for the Profit Target.
    
    'Calculate ATR on bar prior to Entry Bar
    Dim ATROnEntry As BarArray
    If MarketPosition<>MarketPosition[1] Then 
    ATROnEntry=Average(TrueRange,ATRLen,1)
    End If
    
    'Calculate Moving Averages 
    Dim ShortAve As BarArray
    Dim LongAve As BarArray
    ShortAve=Average(Close,SLen,0)
    LongAve=Average(Close,LLen,0)
    
    'Calculate Long Entry Stop Loss and Profit Targets
    Dim LongTarget As BarArray
    Dim LongStop As BarArray
    LongTarget=EntryPrice+(ExPT*ATROnEntry)
    LongStop=EntryPrice-(ExSL*ATROnEntry)
    
    'Calculate Short Entry Stop Loss and Profit Targets
    Dim ShortTarget As BarArray
    Dim ShortStop As BarArray
    ShortTarget=EntryPrice-(ExPT*ATROnEntry)
    ShortStop=EntryPrice+(ExSL*ATROnEntry)
    
    
         'Search for a Long Entry Signal
         If CrossesOver(ShortAve,LongAve) Then
         Buy("BuyEntry",1,0,Market,Day)
         End If
    
            'Set Long Target
            If Close > LongTarget Then
            Sell("LongTarget",1,0,Limit,Day)
            
            Else
         
            'Set Long Stop
            If Close < LongStop Then
            Sell("LongStop",1,0,Market,Day)
            End If
    
    
         'Search for a Short Entry Signal
         If CrossesUnder(ShortAve,LongAve) Then
         Sell("SellEntry",1,0,Market,Day)
         End If
    
            'Set Short Target
            If Close < ShortTarget Then
            Buy("ShortTarget",1,0,Limit,Day)
            
            Else
            
            'Set Short Stop
            If Close > ShortStop Then
            Buy("ShortStop",1,0,Market,Day)
            End If
              
    End Sub
    
    

    Thanks for any help

    Andrew
     
    #23     Dec 7, 2008
  4. Murray Ruggiero

    Murray Ruggiero Sponsor

    Support is very good at solving problems, when is the last time you e-mailed them ?. They will often give answers , but in a case like yours they need you to answer questions and e-mail back and forth so we can figure out exactly how to help you.

    For example in your post, I am not sure how you want to manage limiting these positions from trading ?. You say you don't want them to take all the trades but you don't explain the restrictions. Unless you explain that I can't help you.

    Come up with some conditions for restricting your trades and I will show you how to do in this thread.
     
    #24     Dec 7, 2008
  5. abarker

    abarker

    I emailed them last on November27th. I sent them an email last night and they have contacted me. They suggest I pursue my enquiry through this website. Hoe thats OK.

    My aim with this "Session" is to be able to enter a trade either long or short when the Short Term MA crosses above or below the Long Term MA.

    Once I am in a trade I want to set a Stop Loss and Profit Target using an ATR multiple. I do not want to exit the trade on a Reversal signal (not for the sake of this exercise anyway).

    One of the reasons I purchased this software was to be able to test these sorts of ideas. I want to test a "session" that only exits using the Stop Loss or Profit Target exits. I will then run the same test but include the Stop and Reverse exit parameters also.

    So for this exercise say I receive a Long entry signal as per the code:

    If CrossesOver(ShortAve,LongAve) Then
    Buy("BuyEntry",1,0,Market,Day)
    End If

    Now I only want to exit this trade if the price closes below my Stop Loss or above my Profit Target (I will use ExitLong method) so it will be:

    'Set Long Target
    If Close>LongTarget Then
    ExitLong("LongTarget","BuyEntry",1,0,Market,Day)
    End If

    'Set Long Stop
    If Close<LongStop Then
    ExitLong("LongStop","BuyEntry",1,0,Market,Day)
    End If

    I want to act on whichever event occurs first (LongStop or LongTarget). Only once either of these instructions are met will the "Session" move on to search for another entry long or short.

    Next code is:

    'Search for a Short Entry Signal
    If CrossesUnder(ShortAve,LongAve) Then
    Sell("SellEntry",1,0,Market,Day)
    End If

    If I run the "Session" as above I get correct Long or Short entries but in the Trade by Trade section of the Results I also note that my exits include not only my Stop Loss or Target exits but also "BuyEntry" and "SellEntry" exits.

    What I think I need to add into the code is a reference to the market position prior to each new entry search instructions. Would this be correct.

    Therefore:

    Then MarketPosition<>MarketPosition[1] then goto ...(next search) or maybe a loop so that whilst marketposition = +1 it loops through the two exit options only and once market position = 0 then quits the loop and goes onto next instruction.

    Thanks for any suggestions.
     
    #25     Dec 7, 2008
  6. Murray Ruggiero

    Murray Ruggiero Sponsor

    Upload your current code in a text file and I will fix it for you and post it.
     
    #26     Dec 7, 2008
  7. abarker

    abarker

    Thanks Murray,

    I have attached a TXT file. I have added in additional text in the session to try and help explain what I am after. Thanks for your prompt replies.

    Without any programming experience I am relying on examples either in the manuals, the online help and also pre written programs within the system. I couldnt find any similar samples where a Target was used and not a Stop and Reverse system.

    I am just trying to check the difference in the two options. One where I just act on a reversal of the entry signal and then to compare another test where I include Stop Loss and Pofit Target exits.
     
    #27     Dec 7, 2008
  8. abarker

    abarker

    I have reformatted the TXT file to stop the text wrapping and make it a little easier to follow. Sorry about that.
     
    #28     Dec 7, 2008
  9. Murray Ruggiero

    Murray Ruggiero Sponsor

    It's still not readable, send it in a word file, maybe the new line cr/l will stay and I will be about to read it easier.
     
    #29     Dec 7, 2008
  10. abarker

    abarker

    Try again
     
    #30     Dec 7, 2008