Welcome to the Traders Laboratory Forums.
Coding Forum Collaborate, receive help, or discuss coding related issues.

Reply
Old 11-09-2008, 12:08 PM   #1

Join Date: Oct 2008
Location: new york
Posts: 54
Ignore this user

Thanks: 17
Thanked 8 Times in 4 Posts



Tradestation Code Help

this is not working as i like for it too.
psudocode:

if Hulls moves above 13 ema then
if i am short then
cover
print string "cover" where i covered
go long one contract
print string "long" where i went long

if hulls moves below 13 ema then
if i am long then
sell
print "Closed"

sell short one contract
print "short" where i went short

---------- CODE -----------------------

inputs:
Price( Close ),
Hulls( 8 ),
EMA( 13 ),
Displace( 0 ),
upColour(Blue),
downColour(Red);

variables:
HullsAvg( 0 ),
EMAvg( 0 ),
MP( 1 );


HullsAvg = jtHMA( Price, Hulls ) ;
EMAvg = AverageFC( Price, EMA ) ;
MP = MarketPosition ;

if HullsAvg crosses over EMAvg then
begin
if MP = -1 then
begin
Buy To Cover("Cover") this bar;
end;
Buy ( "Long" )this bar;
end;


if HullsAvg crosses under EMAvg then
begin
if MP = 1 then
begin
Sell ("Close") this bar;
end;
sellshort( "Short" ) this bar;
end;
ephi144 is offline  
Reply With Quote
Old 11-09-2008, 01:00 PM   #2

Join Date: May 2007
Location: Toronto
Posts: 247
Ignore this user

Thanks: 8
Thanked 143 Times in 53 Posts



Re: Tradestation Code Help

Try arranging your REVERSALS outside of your ENTRY

eg.

if HullsAvg crosses over EMAvg then
begin
Buy ( "Long" )this bar;
end;

if HullsAvg crosses under EMAvg then
begin
sellshort( "Short" ) this bar;
end;

if MP = -1 and HullsAvg crosses over EMAvg then Buy To Cover("Cover") this bar;
if MP = 1 and HullsAvg crosses under EMAvg then Sell ("Close") this bar
bakrob99 is offline  
Reply With Quote
Old 11-29-2008, 08:11 PM   #3

Join Date: Jul 2008
Location: elyria
Posts: 4
Ignore this user

Thanks: 0
Thanked 1 Time in 1 Post



Re: Tradestation Code Help

Did the solution above work for you?
danbarn3 is offline  
Reply With Quote
Old 11-29-2008, 09:05 PM   #4

Join Date: Oct 2008
Location: new york
Posts: 54
Ignore this user

Thanks: 17
Thanked 8 Times in 4 Posts



Re: Tradestation Code Help

turns out that when you use Buy or Sell
TS first sells any open positions that you and then enters a buy order and vice versa. so you do not need to explicitly define those orders
ephi144 is offline  
Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
TradeStation Strategy Code Help jjthetrader Coding Forum 2 10-26-2010 09:06 AM
Quick TS Code Help Please ephi144 Coding Forum 1 11-10-2008 02:15 PM
Help To Code My EA pepe1 Coding Forum 0 06-24-2008 02:41 PM
Code for Trade Station Shai Beginners Forum 2 04-02-2008 10:05 AM
Does Anyone have the TTM Scalper Code for Esignal??? jphillips9 Beginners Forum 5 01-14-2008 08:26 PM

All times are GMT -4. The time now is 10:11 PM.
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
CS to VB integration by DeskLancer
©2006-2011 Traders Laboratory, All Rights Reserved.