QUOTE:
..generates signals in the Strategy Monitor, but after the same time they dissapears... Why?..
Alerts disappear when the strategy no longer generates a signal, simple as that.
Now let's go for the errors in your script:
1. StreamingStrategyRun: int bar = Bars.Count - 1;
This is fine for a screener, but
IsLastPositionActive will never be true because the script will never create a position (you're not processing any history to do so). It can only generate an alert.
2. BacktestingStrategyRun: for (int bar = startBarPosition; bar < Bars.Count - 1; bar++)
If you stop on the second to last bar, properly formed signals like
SellAtMarket(bar + 1, LastPosition); can
never create an Alert since you're not processing the last bar. The for loop must run to bar < Bars.Count;
Here are three errors, for example in your BacktestingStrategyRun:
3. Even if you fixed #2, the following malformed statements cannot generate Alerts:
SellAtLimit(bar, LastPosition, Close[bar] - priceLagValue);
ShortAtLimit(bar, Close[bar] - priceLagValue);
ShortAtLimit(bar, Close[bar] - priceLagValue);
These statuements are the definition of "peeking". Always pass bar + 1 to Market, Stop, or Limit orders (unless you're intentionally trying to prove some non-causal theory).
Finally, although it's considered "legal" to execute AtClose orders on the current bar, these too will never generate an Alert. For more, see the wealthScript Programming Guide > Programming Trading Strategies > Alerts > How to: Alert for AtClose Signals.