Break-Even stop with Point Mode activation floor

Having problem with ApplyStop using activation floor: regular backtest using "stopmodepercent" works exactly as described. "stopmodepoint" does not work at all. See code. The optimization statements are there simply to ensure all true/false combination options that might impact the function are explored, just in case.

Regular portfolio backtest with 6.35.1 x64
DJ-30 watchlist
Daily bars
2.5 years

opt0 = Optimize("JIC1",0,0,1,1);
opt1 = Optimize("JIC2",0,0,1,1);
opt2 = Optimize("JIC3",0,0,1,1);
opt3 = Optimize("JIC4",0,0,1,1);

SetOption( "AllowPositionShrinking", True );
SetOption( "AllowSameBarExit", opt0 );
SetOption( "ReverseSignalForcesExit", False );
SetOption( "MinShares", 1 );
SetOption( "ActivateStopsImmediately", opt1 );

// Break-Even stop with $2 activation floor does not work!!

"Does not work" means nothing and is not actionable. Present the case in detail, including data that you used, screenshots showing at least one, reproducible example of what precisely you think that "does not work".

Please follow this advice: How to ask a good question

Also use code tags for proper formatting.

1 Like

If you're going to assault the program on its own forum you could at least show us you've done a bit of your own homework and use code tags when listing your program.
How to ask a good question

I checked and it works just fine, but you need to turn ON the stop by specifying amount to something else than zero.


Amount == 0 is used to disable max loss stop, so you have to use non-zero (positive) value.


Thank you for giving a solution to this problem. I have found out, though, that using ANY number between -0.1 and zero will not work as well. If you try to use -0.00001 instead of the number in your example, the formula will still be "turned off".

Just out of curiosity, why has this "feature" (turning ON the function by using a non zero value) been implemented in the Point mode but not in the Percent mode?

And finally, I think it would be very useful (and time saving) to have this "feature" documented properly.

You can't use "amount" that is negative or zero. For max loss stop that amount argument is the amount of loss. So positive value means LOSS. 0.1 means loss of $0.1 per share. If you use negative loss amount it would be profit and this stop is not meant to be triggered by profit but by loss. And if you want to handle profit target you should use appropriate stop type for this purpose (profit target stop).
Generally functions should be used within their domain. As with log(x) you can't pass negative x values (or zero) because log(x) is not defined for negative inputs and zero.

For what it is worth, next version will display ERROR message when someone tries to use amount <= 0.

1 Like

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