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

How would you double up?



PureBytes Links

Trading Reference Links

Hello all;

Maybe I didn't give my last post enough time for people to respond, but
since no one, as yet, was able to find the flaw with the code I was trying
to troubleshoot, I'd like to try a "clean" approach...

At present, I use a long term trend following system that buys or sells only
one contract that I'd like to add the following concept to:

When long, buy one more contract on a buy stop that equals 102% of the entry
price of the original contract.
When short, sell one more contract on a sell stop that equals 98% of the
entry price of the original contract.

What would you suggest for code?

For those who are interested, I've posted the code that is problematic
below. (For ease of reading I eliminated some of the variables.) The problem
with this code is when I think it should be setting up to buy (sell) another
contract on a stop, it reverses on the next bar. I'm using TS2000i and the
strategy is set to allow for multiple contracts.

I did get a couple of suggestions to remove the if condition "If MP[1] <>  1
Then" which I tried but there was no change in the results.

Input:    Length1(20),
            Length2(44),
            PyramidSw(0);               {0 is no Pyramiding, 1 allows
pyramiding}

Vars:    Buy_Another(0),
            Sell_Another(0),
            MP(0),                    {MarketPosition}
            Cts(0);                    {Contracts}

{{Basic code entered here}}

{Problem code below}

If PyramidSw = 1 then Begin
            If MP =  1 then Begin
                        If MP[1] <>  1 Then Buy_Another = EntryPrice * 1.02;
                        If Buy_Another <> 0 Then Buy("Pyramid_L")
Buy_Another Stop;
                        If Cts = 2 then Buy_Another = 0;
            End;
            If MP = -1 then Begin
                        If MP[1] <> -1 Then Sell_Another = EntryPrice *
0.98;
                        If Sell_Another <> 0 Then Sell("Pyramid_S")
Sell_Another Stop;
                        If Cts = 2 then Sell_Another = 0;
            End;
End;