Is there any difference if I place Applystop() on top or bottom?

Firstly, I've tried to put Applystop() on the very top as below:

stop = Optimize("stop", 1.0, 1.0, 7.0, 0.5);
ApplyStop( type=0, mode=1, amount=stop, exitatstop=1, volatile=False, ReEntryDelay=0, ValidFrom =0, ValidTo = -1);
//
period = Optimize("period", 100, 100, 300, 10);
m = MA( Close, period ); 
Buy = Cross( Close, m ); Short = Cross( m, Close ); 
Sell = Short;  Cover = Buy;

Then, I've tried to put Applystop() on the very bottom as below:

period = Optimize("period", 100, 100, 300, 10);
m = MA( Close, period ); 
Buy = Cross( Close, m ); Short = Cross( m, Close ); 
Sell = Short;  Cover = Buy;
//
stop = Optimize("stop", 1.0, 1.0, 7.0, 0.5);
ApplyStop( type=0, mode=1, amount=stop, exitatstop=1, volatile=False, ReEntryDelay=0, ValidFrom =0, ValidTo = -1);

It seems no difference after I ran some optimizes.
Is there any difference if I place Applystop() on top or bottom?

Thank you very much! :smiley:

ApplyStop is a switch for the backtester. It is only interpreted by the BACKTESTER, when backtest is run, not "inside" the formula at the place of the call. Therefore location of ApplyStop in the code does not matter as long as you do not use Equity() function (because that function runs in-place backtest for you).

4 Likes

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