- ago
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]...
0
1,414
4 Replies

Reply

Bookmark

Sort
- ago
#1
Hmm...
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).
0
- ago
#2
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...
1
- ago
#3
OK thanks, I indeed overlooked the "return".
0
- ago
#4
How would I make such a rule using building blocks? Seems to be easy but can't figure it out :/
0

Reply

Bookmark

Sort