Issue with OpenPositionProfit

Questions about MultiCharts and user contributed studies.
Thomas Mann
Posts: 173
Joined: 25 Aug 2007

Issue with OpenPositionProfit

Postby Thomas Mann » 10 Dec 2008

Hi,
I tried to use the OpenPositionProtect strategy word to stop out of a Long position if the amount went > -80. It went right through -80 and kept falling. Does the language word understand a negative number ?
thanks



If MarketPosition= 1 and OpenPositionProfit < -80 then
begin
Buy ("SStopProtect") next bar at Market;
end;

Thomas Mann
Posts: 173
Joined: 25 Aug 2007

Postby Thomas Mann » 10 Dec 2008

Hi,
Code should read like this.



// OpenPosition Stop Protect
If MarketPosition= 1 and OpenPositionProfit < -80 then
begin
Sell ("SStopProtect") next bar at Market;
end;

Thomas Mann
Posts: 173
Joined: 25 Aug 2007

Postby Thomas Mann » 10 Dec 2008

Hi,
The code below works if the trade goes + > 80, but does not work if the trade goes > -80
Any ideas ?
Thanks


If MarketPosition= 1 and OpenPositionProfit > 80 then
begin
Sell("LProtect") next bar at market ;
end;

User avatar
Marina Pashkova
Posts: 2758
Joined: 27 Jul 2007

Postby Marina Pashkova » 18 Dec 2008

Hi Thomas,

We have tested both codes below and both are working just just fine.

Code: Select all

// script1
buy next bar market;
If MarketPosition= 1 and OpenPositionProfit < -50 then
begin
Sell("LProtect") next bar at market ;
end;

// script2
buy next bar market;
If MarketPosition= 1 and OpenPositionProfit > 50 then
begin
Sell("LProtect") next bar at market ;
end;
We have run tests on both scripts and they work as expected. As soon as we lose over 50, we exit at the next bar / tick (script 1).

As soon as we have made more than 50, we exit at the next bar / tick (script2).

Let me know how they work for you.


Return to “MultiCharts”