CODE:
//--- Setup --- // Close above SMA + ATR: significant uptrend if(bars.Close[idx] < sma100[idx] + atr10[idx]) return;
While your comment says: Close above SMA..., the code seems to work the other way around?
if(bars.Close[idx] < sma100[idx]...
Rename
Hmm...
This is a more complete code snippet:
It says: If the Close is higher or equal to SMA plus ATR we proceed to PlaceTrade(),
if not, we return from the Execute() method.
And true, inside the if condition it is reversed logic. I prefer doing it this way because it saves some curly braces and - more important - indentation levels, which get confusing quickly if there are several conditions in a row (like here).
This is a more complete code snippet:
CODE:
// Close above SMA + ATR: significant uptrend if(bars.Close[idx] < sma100[idx] + atr10[idx]) return; ... PlaceTrade(...)
It says: If the Close is higher or equal to SMA plus ATR we proceed to PlaceTrade(),
if not, we return from the Execute() method.
And true, inside the if condition it is reversed logic. I prefer doing it this way because it saves some curly braces and - more important - indentation levels, which get confusing quickly if there are several conditions in a row (like here).
The style mentioned above goes against the "The Single Return Law"
(see https://www.anthonysteele.co.uk/TheSingleReturnLaw.html)
which is rather outdated nowadays anyway...
(see https://www.anthonysteele.co.uk/TheSingleReturnLaw.html)
which is rather outdated nowadays anyway...
OK thanks, I indeed overlooked the "return".
How would I make such a rule using building blocks? Seems to be easy but can't figure it out :/
Your Response
Post
Edit Post
Login is required