Reversing of a positing  [SOLVED]

Questions about MultiCharts and user contributed studies.
Wally_AD
Posts: 47
Joined: 28 Jan 2014
Has thanked: 8 times
Been thanked: 7 times

Reversing of a positing

Postby Wally_AD » 14 May 2014

Hi all,

I want to reverse a short position.
If MarketPosition = -1 Then begin
Buy("Rev_S") 2 Contracts Next Bar At (limitvalue) Limit;
end;

SetProfitTarget(TargPts * BigPointValue );
SetStopLoss(SLPTs * BigPointValue);
The result is that 2 positions are created instead of 1 reverse position.

Is there anything wrong with the code ?

User avatar
Andrew MultiCharts
Posts: 1587
Joined: 11 Oct 2011
Has thanked: 931 times
Been thanked: 559 times

Re: Reversing of a positing

Postby Andrew MultiCharts » 14 May 2014

Hello Wally_AD,

Yes, here is the corrected code to reverse from -1 to +1:

Code: Select all

If MarketPosition = -1 Then begin
Buy("Rev_S") 1 Contracts Next Bar At (limitvalue) Limit;
end;

SetProfitTarget(TargPts * BigPointValue );
SetStopLoss(SLPTs * BigPointValue);

Wally_AD
Posts: 47
Joined: 28 Jan 2014
Has thanked: 8 times
Been thanked: 7 times

Re: Reversing of a positing

Postby Wally_AD » 22 May 2014

But the trace output shows something different.

With MarketPosition = -1

Code: Select all

Buy("Rev_S") 2 Contracts Next Bar At (limitvalue) Limit;
and then printing the MarketPosition results into

MarketPosition = 1

So for backtesting MarketPosition shows -1 or 1 and the Broker Position shows -2 or 2.

This is confusing.


Wally_AD
Posts: 47
Joined: 28 Jan 2014
Has thanked: 8 times
Been thanked: 7 times

Re: Reversing of a positing  [SOLVED]

Postby Wally_AD » 22 May 2014

Ok. Got it.

Thank you Andrew.


Return to “MultiCharts”