PureBytes Links
Trading Reference Links
|
I am trying to play around with an martingale type position sizing formula
that adds another contract with each winning trade. Below is the code I have
used and have tried many variations, but I cannot seem to get it to work.
The idea is once I have a loss, the num variable returns to 1 and starts
again. So, if I have a win, then num goes to 2 for the next trade. If I have
2 winners, num goes to 3 etc,etc. I want the system to increase with a new
contract with each consecutive win.
I have read many times that Anti-Martingale strategies work best, but I just
want to see the differences for myself. I have tried this on an S&P system
and after the first winner of 1 contract the system then buys amounts like
11, 76, 27 etc on the next trade. Can somebody help me out? Here's the code:
Variables: Num(1);
If PositionProfit(1) < 0 Then Num = 1;
If PositionProfit(1) > 0 Then Num = Num + 1;
Buy Num Contracts Blah Blah;
I have also tried this code but it still won’t count correctly:
Variables: Num(1);
If PositionProfit < 0 Then Num = 1;
If PositionProfit >= 0 Then Num = Num + 1;
Buy Num Contracts Blah Blah;
I have also tried setting the PositionProfit up as a variable and referring
to it, but still no joy. Here’s that attempt:
Variables: Num(1), PP(0);
PP = PositionProfit;
If PP < 0 Then Num = 1;
If PP >= 0 Then Num = Num + 1;
Buy Num Contracts Blah Blah;
Any ideas? Thanks.
|