[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [amibroker] Code help requested - Control length of trade



PureBytes Links

Trading Reference Links


Greg: I was 
thinking that your original statement
<SPAN 
class=900054615-21042002> 
sell = 
Ref(Buy,-20) rather than what you tried sell = Ref(Buy,20);
<SPAN 
class=900054615-21042002> 
Did you ever try 
this?
<SPAN 
class=900054615-21042002> 
<SPAN 
class=900054615-21042002>Ken
<FONT face=Tahoma 
size=2>-----Original Message-----From: greg 
[mailto:greg.bean@xxxx]Sent: Sunday, April 21, 2002 10:02 
AMTo: amibroker@xxxxxxxxxxxxxxxSubject: Re: [amibroker] 
Code help requested - Control length of trade
Hi,
 
I think I've got it now. My use of <FONT 
color=#0000ff size=1>ExRem was 
messing me up. 
 
This seems to work ok.
 

/* MI Screens BackTest*/<FONT 
color=#008000 size=1>
//Buy at open 
on first Monday Of Month //<FONT 
color=#000000 size=1>
Buyday = DayOfWeek<FONT 
color=#000000 size=1>()==<FONT color=#ff00ff face="Courier New" 
size=1>1 AND <FONT color=#0000ff 
size=1>Day()<FONT color=#000000 
face="Courier New" size=1>>=<FONT color=#ff00ff face="Courier New" 
size=1>1 AND 
Day<FONT 
color=#000000 face="Courier New" size=1>()<=<FONT color=#ff00ff 
face="Courier New" size=1>7; <FONT 
color=#008000 size=1>// buy on Monday<FONT color=#000000 
face="Courier New" size=1>
//Sell on Friday, 4 weeks after buy//<FONT color=#000000 
face="Courier New" size=1>
Sellday = <FONT color=#0000ff face="Courier New" 
size=1>DayOfWeek<FONT color=#000000 face="Courier New" 
size=1>()==5<FONT 
color=#000000 face="Courier New" size=1> AND <FONT color=#0000ff 
face="Courier New" size=1>Day<FONT color=#000000 face="Courier New" 
size=1>()>=<FONT color=#ff00ff face="Courier New" 
size=1>21 AND 
Day<FONT 
color=#000000 face="Courier New" size=1>()<=<FONT color=#ff00ff 
face="Courier New" size=1>31<FONT color=#000000 face="Courier New" 
size=1>;//sellon 
friday
Buy=Buyday 
;
Sell= 
Sellday; // 
sell on Friday 20 days after buy
 
//ApplyStop(2,3,Optimize("TrailingStop",15,0,20,5),1);
 
Greg
 
 
 
<BLOCKQUOTE 
>
----- Original Message ----- 
<DIV 
>From: 
<A href="" 
title=greg.bean@xxxx>greg 
To: <A 
href="" 
title=amibroker@xxxxxxxxxxxxxxx>AmiBroker@xxxx 
Sent: Sunday, April 21, 2002 10:12 
AM
Subject: [amibroker] Code help requested 
- Control length of trade

Hi,
 
Been trying a few things for the past 3 hours but 
can't seem to get it right. Please help before I get divorced :) 
.
Trade Rules:
 
1. Buy at open on first monday of 
month.
2. Sell at open on Friday 4 weeks later (sell 
after 28 days). That's sell after 20 bars . I think ?
 
Pretty simple. But I guess I'm even moresimple:( 

 
I've tried   sell=ref(buy,20). 

<FONT face=Arial 
size=2>               
sell = barssince(buy)=20
 
and various other tthings, but I'm getting 
nowhere.
 
Here's what I've got so far.
 

/* MI Screens BackTest*/<FONT 
color=#008000 size=1>
//Buy at open 
on first Monday Of Month //<FONT 
color=#000000 size=1>
Buyday = DayOfWeek<FONT 
color=#000000 size=1>() == 1<FONT 
color=#000000 size=1>; // buy on 
Monday<FONT 
color=#008000 face="Courier New" size=1>
//Sell on Friday, 4 weeks after buy//<FONT color=#000000 
face="Courier New" size=1>
Sellday = <FONT color=#0000ff face="Courier New" 
size=1>DayOfWeek<FONT color=#000000 face="Courier New" 
size=1>()==5<FONT 
color=#000000 face="Courier New" size=1>;<FONT color=#008000 
face="Courier New" size=1>//sell on friday<FONT color=#000000 
size=1>
Buy=Buyday <FONT color=#000000 face="Courier New" 
size=1>;
Sell=<FONT color=#000000 face="Courier New" 
size=1>Sellday+<FONT color=#ff00ff face="Courier New" 
size=1>20; <FONT color=#008000 
size=1>// sell on Friday 20 days after buy
<FONT color=#008000 
size=1>//ApplyStop(2,3,Optimize("TrailingStop",15,0,20,5),1);<FONT 
color=#000000 size=1>
Buy=ExRem<FONT color=#000000 
size=1>(Buy,Sell);
Sell=ExRem<FONT color=#000000 
size=1>(Buy,Sell);
 
 Youruse of 
Yahoo! Groups is subject to the <A 
href="">Yahoo! Terms of Service. 
Your 
use of Yahoo! Groups is subject to the <A 
href="">Yahoo! Terms of Service.