Short position is entered even when positionscore is positive


I’m trying to understand the behavior of positionscore. I read the manual and the help documents. It is my understanding that a short position is entered into only if the position score is negative. I tried the code in the manual

SetOption("InitialEquity", 20000 );
RoundLotSize = 1; 

posqty = Optimize("PosQty", 4, 1, 20, 1 );
SetOption("MaxOpenPositions", posqty);

// desired position size is 100% portfolio equity
// divided by PosQty positions

PositionSize = -100/posqty; 

// The system is very simple...
// MA parameters could be optimized too...
p1 = 10;
p2 = 22;
// simple MA crossover
Short=Cross( MA(C,p1) , MA(C,p2) );
Buy=Cross( MA(C,p2) , MA(C,p1) );
// always in the market 

// now additional score 
// that is used to rank equities 
// when there are more ENTRY signals that available
// positions/cash
PositionScore = 100-RSI(); // prefer stocks that have low RSI;

Exploration shows a positioscore of 55.32 for AXJL

But in the backtester the positionscore is -55.32

Is this the correct behavior or I used wrong settings? If this is correct, is there any document/discussion about this?


I think your wording is not correct.
Long and short positions are only entered when their respective "Long" or "Short" Arrays have a signal, ie. that bar is value 1.

PositionScore merely gives preference like a ranking as to which signals are stronger and then taken depending on PositionSize or other restrictions like number of open trades etc

* higher positive score means better candidate for entering long trade
* lower negative score means better candidate for entering short trade

so if you want this to be in effect properly, 50-RSI() makes more sense as you get a range from 50 to -50,
but if you are doing ranking with 100-RSI(), it just means that short signals have low positive score.
Therefore, if no other signals exist, and there is only one symbol which has Short marked and low positionScore, it will be eligible for a trade provided other conditions are ok.

An easy way to specify Long/short only or both, you can check this:
In the Analysis Settings window, "General" tab you have to select
Positions: "Long and short" option


:warning:The sign of position score ONLY affects ROTATIONAL mode :warning:

Since you are using REGULAR mode (not rotational), the side of trade is solely controlled by Buy and Short variables. And you would get SHORT trade if Short variable is set to true.
In regular mode only absolute value of PositionScore counts to perform ranking, not choose the side.


Thanks for the clarification

Do the followings work in REGULAR mode?

SetOption("MaxOpenLong", 5);
SetOption("MaxOpenShort", 5);
SetOption("SeparateLongShortRank", True);


See doc: AFL Function Reference - Set Options

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.