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

Reply
Old 09-30-2009, 06:56 PM   #1

Join Date: Feb 2008
Location: Miami Beach
Posts: 4
Ignore this user

Thanks: 1
Thanked 1 Time in 1 Post

EL Strategy Help Needed

I'm tying to code a strategy for trading the YM as follows:

Enter market short when price closes +40 pts above yesterdays close and time is 2am or later. Exit when either price retraces to yesterday's close, or the time is 9:45am. Reverse for long entry with price -40 pts.

I believe it should be quite simple to code, but can't seem to get it. Below is what I came up with. Any assistance would be greatly appreciated.

Thanks.


inputs: Offset(40), Stop_Loss(500), Exit_Time(945), Start_Time(200);

Value1 = CloseD(1);

if time >= Start_Time and time <= Exit_Time then
begin

if marketposition = 0 and close > Value1 + Offset points then sell short next bar at market;

if marketposition = 0 and close < Value1 - Offset points then buy next bar at market;

end;

If time >= Exit_Time and MarketPosition <> 0 then
begin
Sell all contracts next bar at market;
BuyToCover all contracts next bar at market;
end;


if marketposition = 1 and close <= Value1 then sell all contracts next bar at market;

if marketposition = -1 and close >= Value1 then buy to cover all contracts next bar at

market;

setstoploss(Stop_Loss);
Marc33139 is offline  
Reply With Quote
Old 09-30-2009, 07:40 PM   #2

Tams's Avatar

Join Date: Sep 2008
Location: Geelong
Posts: 3,779
Ignore this user

Thanks: 2,084
Thanked 1,474 Times in 912 Posts

Re: EL Strategy Help Needed

draw a flow chart... it can help you visualize your logic

__________________



Only an idiot would reply to a stupid post
Tams is offline  
Reply With Quote
Old 09-30-2009, 10:11 PM   #3

Join Date: May 2008
Location: amsterdam
Posts: 114
Ignore this user

Thanks: 25
Thanked 39 Times in 30 Posts

Re: EL Strategy Help Needed

Code:
inputs: Offset(40){amount of ticks not full points}, Stop_Loss(500), Exit_Time(945), Start_Time(200);

if time >= Start_Time and time <= Exit_Time and EntriesToday(Date) = 0 then 
Begin
SellShort next bar CloseD(1) +( Offset * ( MinMove / PriceScale )) Limit;
Buy next bar CloseD(1) - ( Offset * ( MinMove / PriceScale )) Limit;
End;

If time >= Exit_Time then 
begin
   	Sell this Bar on Close;
	BuyToCover this Bar on Close;
end;

BuyToCover next bar CloseD(1) Limit;
Sell next bar CloseD(1) Limit; 

SetStopLoss(Stop_Loss);
i have not tried this but it should work, your problem could have been the offset points,
for a e-mini the reserve word "points" refers to the pricescale / 100, while using MinMove/PriceScale
gives you the minimum price fluctation (ticks), for the YM this shouldnt matter as a tick is equal to a full point.
i allways try to use limit and stop orders where possible,
you will not get good and realistic fills using marketorders, not in real trading due to slippage
nor in your backtest; especially not in a less liqued market like the ym.
be aware a script like this will give zero sensetivity to changes in
volatility as your entry and exit are all a fixed amount of points.

Last edited by flyingdutchmen; 09-30-2009 at 11:03 PM.
flyingdutchmen is offline  
Reply With Quote
The Following User Says Thank You to flyingdutchmen For This Useful Post:
Marc33139 (10-01-2009)
Old 10-01-2009, 11:21 AM   #4

Join Date: Feb 2008
Location: Miami Beach
Posts: 4
Ignore this user

Thanks: 1
Thanked 1 Time in 1 Post

Re: EL Strategy Help Needed

Thanks so much for the code.
Marc33139 is offline  
Reply With Quote

Reply

Thread Tools
Display Modes Help Others By Rating This Thread
Help Others By Rating This Thread:


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help Needed for Indicator DutchAngel Coding Forum 4 04-16-2009 05:22 AM
Indicators needed ( help) stocktrader.in Coding Forum 4 11-18-2008 01:44 PM
Excel Help Needed brownsfan019 Trading Indicators 5 06-02-2008 07:24 PM
just what i needed xztheericzx Beginners Forum 0 11-04-2007 05:21 AM
Help Needed DAT Files Don4 General Discussion 1 03-26-2007 08:59 PM

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