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

Reply
Old 06-20-2007, 11:05 AM   #1

Join Date: Oct 2006
Posts: 4
Ignore this user

Thanks: 0
Thanked 1 Time in 1 Post



Start and End Timing?

Im trying to test a system and have it start trading at 8:00am and close any postion at end of day...For example this simple MA cross, how would I put in 'dont take a signal till after 8am' and then 'exit any postion at the close'?

Thanks for any help

Code:
inputs: Price( Close ), FastLength( 9 ), SlowLength( 18 ) ; 
variables: FastAvg( 0 ), SlowAvg( 0 ) ; 

FastAvg = AverageFC( Price, FastLength ) ; 
SlowAvg = AverageFC( Price, SlowLength ) ; 

if CurrentBar > 1 and FastAvg crosses over SlowAvg then 

   Buy ( "MA2CrossLE" ) next bar at market ; 
    

if CurrentBar > 1 and FastAvg crosses under SlowAvg then 

   Sell Short ( "MA2CrossSE" ) next bar at market ;
jmi88 is offline  
Reply With Quote
Old 06-20-2007, 08:34 PM   #2
ant

ant's Avatar

Join Date: Sep 2006
Location: USA
Posts: 421
Ignore this user

Thanks: 22
Thanked 314 Times in 81 Posts



Re: Start and End Timing?

jmi88, see if this works for you...

Code:
inputs: Price( Close ), FastLength( 9 ), SlowLength( 18 ) ; 
variables: FastAvg( 0 ), SlowAvg( 0 ) ; 

FastAvg = AverageFC( Price, FastLength ) ; 
SlowAvg = AverageFC( Price, SlowLength ) ; 

if MarketPosition = 0 and Time > 800 and CurrentBar > 1 and FastAvg crosses over SlowAvg then 

   Buy ( "MA2CrossLE" ) next bar at market ; 
    
if MarketPosition = 0 and Time > 800 and CurrentBar > 1 and FastAvg crosses under SlowAvg then 

   Sell Short ( "MA2CrossSE" ) next bar at market ; 

if MarketPosition > 0 and Time = Sess1EndTime then
	
	Sell ( "MA2CrossLX" ) this bar at close ; 

if MarketPosition < 0 and Time = Sess1EndTime then
	
	BuyToCover ( "MA2CrossSX" ) this bar at close ;
I added the check for MarketPosition so that you only have one position open at a time. You can also hardcode the time instead of using Sess1EndTime.
ant is offline  
Reply With Quote

Reply

Tags
buytocover, sess1endtime

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is it possible to start trading FOREX with $1000? 1time Forex Trading Laboratory 96 02-22-2010 11:27 AM
How did I start my future trade? Weryfalloffdown Beginners Forum 25 01-19-2009 11:40 AM
if you had to start over... darthtrader Beginners Forum 38 12-20-2008 02:22 PM
Newbie looking to start trading creso Beginners Forum 18 09-07-2006 12:56 PM

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