MarketPosiition BUG

Questions about MultiCharts and user contributed studies.
Posts: 70
Joined: 15 Sep 2006
Been thanked: 15 times

MarketPosiition BUG

Postby damageboy » 22 Nov 2006

While using the MarketPosition keyword I noticed it is wrongly intialized by MC before the first trade has been made by the strategy:

The following code:

Code: Select all

If (Debug) then print(File(LogFile), "");
If (Debug) then print(File(LogFile), "---------------------- ", NumToStr(CurrentBar,0), " [", ELDateToString(Date), ", ", ELTimeToString(Time), "] -----------------------------");
if (Debug) then Print(File(LogFile), "MP=", MarketPosition);
produces the following log:

Code: Select all

---------------------- 1 [11/02/2006, 12:45] -----------------------------

---------------------- 2 [11/02/2006, 12:50] -----------------------------

---------------------- 3 [11/02/2006, 12:55] -----------------------------
Until later when the first trade has been entered and MarketPosition is "corrected"

Code: Select all

---------------------- 12 [11/02/2006, 13:40] -----------------------------
Naturally, MarketPosition should only return -1,0 or 1 as the documentation shows:
MarketPosition (Reserved Word)

Returns a numeric value for a short or long position for the specified position.


Where Num is a numeric expression representing the number of positions ago.

-1 is returned for a short position, and 1 is returned for a long position. 0 is returned if the current position is specified, and you are not currently in the market.

This function can only be used in the evaluation of strategies.

MarketPosition(0) returns a value of 0 if the current position is flat.

User avatar
Alex Kramer
Posts: 834
Joined: 23 Feb 2006

Postby Alex Kramer » 22 Nov 2006

Thanks for your attention. This is a known issue, will be fixed in the next version.

Return to “MultiCharts”