i could use some assistance with a matter that should be very simple for the experts on the nt support staff. i have been doing some tests and evaluations on the nt optimization engine and also trying to evaluate some simple strategies derived from the sample strategies that come with the nt platform.
when i run an optimization process over the parameters for the sample sma cross over strategy, i like to use the same range of values for both parameters (1 to 50) and often times the best results from the optimization are such that what should be the "fast" sma is calculated for a larger period than the "slow" sma. this means the "fast" sma ends up in fact being the "slow" sma and the strategy tries to counter every trend instead of going with it.
i want these strategies to only follow trends, not try to counter them, so i would like to force the nt platform to optimize both parameters over the same range but only consider the results for the cases where the period for sma2 ("slow") is in fact larger than the period for sma1 ("fast").
protected override void OnBarUpdate() { if (CurrentBar < BarsRequiredToTrade) return; if (CrossAbove(smaFast, smaSlow, 1)) EnterLong(); else if (CrossBelow(smaFast, smaSlow, 1)) EnterShort(); }
my best guess is that the following modification to the line (¿filter?) before the conditions for the entries should work. ¿is this correct?
if (CurrentBar < BarsRequiredToTrade OR Fast > Slow) return;
¿could there be any other ways to do this that worked better for optimization purposes?
i also have two further questions regarding how i could impose conditions similar to this on a strategy:
- if i wanted to use more than 2 smas and wanted to use similar conditions to the one mentioned before, ¿would inserting this line before the conditions for the entries work?
if (CurrentBar < BarsRequiredToTrade OR Sma1 > Sma2 OR Sma2 > Sma3) return;
- and, ¿how could i do if i wanted to invert these conditions so that instead of disabling the entire strategy if any of the statements was true as in the previous cases, i now wanted the strategy to only be enabled if all the conditions i listed were true simultaneously? something like the following line:
{only} if (CurrentBar >= BarsRequiredToTrade && Sma1 < Sma2 && Sma2 < Sma3) {then go on with the subsequent commands}
very well, thanks, regards.
Comment