I have searched the forums, and apparently this is a common question, however whenever I look at the responses/solutions, they seem to be unclear to me or not pertain to my situation. It's likely just me that doesn't understand, so I apologize in advance for asking this. But I am stuck and need help to move forward.
How can I use ATR to define stop placement within this context:
- Inside the OnBarUpdate() class
- Using the SetStopLoss Function
- Using NinjaScript Editor (not the Strategy Builder Wizard)
For example, suppose I have entered the market at a particular entry price. I'd like to then Set a stop loss at 2 ATR behind that.
How do I calculate and store some form of 2 ATR into a variable to be used with the SetStopLoss Function?
And a related question, how do I call the current price as of that OnBarUpdate iteration? I've seen Close[0] as one way, but not certain if that works and even if it does, I can't use it with other functions due to some error with the Type.
Thanks!
Comment