Asf -- There still seem to be forum problems; emails aren't going out. I just happened to check the forum directly, and see you replied 12 hours ago!
Anyway: You're welcome! It looked like a big job for a newbie, so I jumped in.
QUESTION: What is the SYMBOL and YEAR for the charts you posted?
There may be both issues with the System Tester, and a few "logic" areas you need to be aware of and decide how to handle. I'll put that in a separate message, after you try the new code below, and see if you still have the same problems.
NOTE: Your initial and trailing stops are built-in to the indicator, in the "Sell" variable assignment. The comments may help. Also, this indicator is a "latch"; get
Roy Larsen's Tutorial if you don't already have it; it will help you wrap your head around the "latch" concept, logic, etc.
The latch part of the indicator is calculated by the "Tr" variable, and gives the indicator its value. If you plot the indicator, it will show the Highest Close while a trade is active, and "0" otherwise. Other variables within the indicator can be referenced from outside using FMLVAR(). There is no actual reason to plot the indicator itself.
{_Test} {Latch holds value of highest close during trade}
{Trade entry}
Buy:=C>Ref(C,-1) AND V>Ref(V,-1) AND PREV=0;
{Remember entry conditions for initial stop}
EntryClose:=ValueWhen(1,Buy,C);
EntryLow0:=ValueWhen(1,Buy,L);
x:=ValueWhen(1,Buy,Cum(1))+1;
EntryLow1:=ValueWhen(1,Cum(1)=x,L);
{Calc trailing-stop percentage}
Pct:=(EntryClose-EntryLow0)/EntryClose;
{Trade exit -- Initial & trailing Stops, no actual system exit}
Sell:=L<EntryLow0
OR L<EntryLow1
OR L<PREV*(1-Pct);
{Filter repeat signal, 1=Buy -1=Sell, No signal on 1st bar!}
init:=Cum(IsDefined(Buy+Sell))=1;
Season:=ValueWhen(1,Buy-Sell<>0 OR init,Buy)*2-1;
Signal:=If(Season<>Ref(Season,-1),Season,0);
{Set Latch to highest Close from filtered signal, 0=No Trade}
Tr:=If(PREV=0,If(Signal=1,C,0),If(Signal=-1,0,Max(C,PREV)));
{Plot - Display & sets indicator value for PREV logic}
Tr;
{**}
Offhand, I can't come up with an easy way to display both your "initial stop" and "trailing stop", but if you want to display just the "trailing stop", use a separate indicator, in a separate sub-window. Suggest you set the "Style" to "Dots", thicken them and plot in a separate window. To see the values, hover the mouse or right-click and click Copy, then Paste into a spreadsheet.
{_Test Stop}
{Only trailing stop}
Fml("_Test")*(1-FmlVar("_Test","Pct"));
{**}
In an Expert, use the following to show when the trade is active:
TREND or HIGHLIGHTS:
Buy: FmlVar("_Test","Season")=1;
Sell: FmlVar("_Test","Season")=-1;
Display the signals in a separate window with this:
{_Test Signal}
FmlVar("_Test","Signal");
You could also use the above for Expert SYMBOLS, but that could interfere with displaying System Tester results. I suggest you not use them for the moment.