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);
Code: Select all
---------------------- 1 [11/02/2006, 12:45] -----------------------------
MP=235861508.00
---------------------- 2 [11/02/2006, 12:50] -----------------------------
MP=235861508.00
---------------------- 3 [11/02/2006, 12:55] -----------------------------
MP=235861508.00
Code: Select all
---------------------- 12 [11/02/2006, 13:40] -----------------------------
MP=-1.00
MarketPosition (Reserved Word)
Returns a numeric value for a short or long position for the specified position.
MarketPosition(Num)
Where Num is a numeric expression representing the number of positions ago.
Remarks
-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.
Example
MarketPosition(0) returns a value of 0 if the current position is flat.