06-20-2007, 08:34 PM
Join Date: Sep 2006
Thanked 317 Times in 82 Posts
Re: Start and End Timing?
jmi88, see if this works for you...
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.