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

Code help requested - Control length of trade



PureBytes Links

Trading Reference Links


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 more simple:( 

 
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 
face="Courier New" color=#008000 size=1>
//Sell on Friday, 4 weeks after buy//<FONT face="Courier New" 
color=#000000 size=1>
Sellday = <FONT face="Courier New" color=#0000ff 
size=1>DayOfWeek<FONT face="Courier New" color=#000000 
size=1>()==5<FONT 
face="Courier New" color=#000000 size=1>;<FONT face="CourierNew" 
color=#008000 size=1>//sell on friday
Buy=Buyday <FONT face="Courier New" color=#000000 
size=1>;
Sell=<FONT face="Courier New" color=#000000 
size=1>Sellday+<FONT face="Courier New" color=#ff00ff 
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);