Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers, Unverified Users Joined: 10/28/2004(UTC) Posts: 3,111 Location: Perth, Western Australia
Was thanked: 16 time(s) in 16 post(s)
|
bb,
I started working on this one for you but SWMBO had to use the computer for her assignments due to tomorrow.
Where I was up to...
I started with writing the pseudo code:
On the first bar in the chart, no trades open:
...check to see if any long or short entry conditions are met
...if an entry condition is met, open the long or short trade as applicable
On the second bar:
...if no trades are open, check to see if any long or short entry conditions are met and open a trade as applicable
...if a trade is already open, check to see if an exit condition has been met. An exit in one direction is automatically an entry in the opposite direction
On each subsequent bar:
...if no trades are open, check to see if any long or short entry conditions are met and open a trade as applicable
...if a trade is already open, check to see if an exit condition has been met. An exit in one direction is automatically an entry in the opposite direction
Using the PREV function, this should be quite do-able, and using Patrick's latch should also make things easier too. The initial entry criteria is your long/short entry criteria. Once one of these trades is open (the value of the latch is 1 or -1), then check to see if the exit condion is met, and recompute on the next bar.
Without testing:
stop:=2;{percent}
FastMA:=Mov(C,7,S);
SlowMA:=Mov(C,21,S);
LE:=Cross(FastMA,SlowMA);
LX:=C<((100-stop)/100)*HighestSince(1,LE,H);
SE:=LX;
SX:=C>((100+stop)/100)*LowestSince(1,SE,L);
LE:=SX;
ExtFml("ForumDll.Latch",LE,LX,SE,SX)
See if that helps the problem?
If not, you will have to wait until I get back from working away and out of touch for a little for a little while...
wabbit :D
P.S. I think that you are going to want to be trading extreeeeemly large priniciples to overcome the brokerage of such a trading system - I suggest you rethink the logic if you want to avoid the poor house!
|