Page 1 of 1

about code of adding to winning positions...

Posted: Oct 25 2011
by johnmok
hi all, another part of the program is about adding to winning position.

my plan is to add two more contracts to the original position, which made a maximum of three in total. the conditions is to add one more contract every US$50 profit from the previous contract, the code are as follows, but after adding the following code, nothing happen, the strategy can't add to position.

any ideas? thanks!

Code: Select all

input: add_position_profit(50);

if marketposition = 1 and currentcontracts = 1 then
begin
if PosTradeProfit(0,0) >= add_position_profit then
buy next bar market;
end;

if marketposition = -1 and currentcontracts = 1 then
begin
if PosTradeProfit(0,0) >= add_position_profit then
sellshort next bar market;
end;

if marketposition = 1 and currentcontracts = 2 then
begin
if PosTradeProfit(0,1) >= add_position_profit then
buy next bar market;
end;

if marketposition = -1 and currentcontracts = 2 then
begin
if PosTradeProfit(0,1) >= add_position_profit then
sellshort next bar market;
end;

Re: about code of adding to winning positions...

Posted: Oct 25 2011
by furytrader
This may sound like a silly question, but when you check Format Strategies --> Strategy Properties ... do you have the checkbox marked "Allow Up To N Entries Orders In The Same Direction as The Currently Held Position" checked?

Re: about code of adding to winning positions...

Posted: Oct 25 2011
by johnmok
oh...i am sorry, you are correct, i haven't check that box. after checking the box, the script works...

thanks! :-)