I am not very proficient in coding and wonder if anyone could give me
an assist with building a contingent stop.
Here's what I am trying to do.
Step 1: Enter the top ranked ETF based on a position score
PositionScore = Score;
My position scoring code is set up so that the score is either a
number positive or zero and then the best score is selected. (no
shorts allowed)
Step 2: Hold for a minimum number of bars or days (i.e. a minimum
hold before rechecking the scoring)
HMB = Optimize("Hold Min Bars", 3, 3, 14, 1);
SetOption("HoldMinBars", HMB);
Step 3: Exit the position based on the following in this order:
3.1. Exit at a given trailing stop loss based on ATR
ATRMult = Optimize("ATR Setting", 3, 2, 5, .1 );
ApplyStop(stopTypeTrailing, stopModePoint, ATRMult*ATR(14), True, True );
3.2. Exit at a given profit objective
ApplyStop( stopTypeProfit, stopModePercent, Optimize( "max. loss stop
level", 3, 2, 30, 1 ), True, ReEntryDelay = 1 );
Actually what I'd really like to do in step 3.2. is tighten up the
trailing stop loss when the % profit objective is reached. And, I
don't want to reenteer (see Step 4).
3.3. Exit on the HoldMinBars setting if the current stock is not the
top ranked in the scoring code any longer
Step 4: Do not re-enter the last buy stock until a different one is
selected (i.e. there really is no reentry until it falls below the
highest score and then rises to the top again)
Anyway, my coding skills end with the above. 3.2 is not the way I
would like it and 4 I have no idea how to do.
Tks K