Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Add EMA directional filter to existing strategy

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Add EMA directional filter to existing strategy

    Hi,

    With the kind help of others, I have manged to generate the attached HMA crossover strategy (it actually uses the slope of the HMA to emulate the crossover), to which I would now like to add a simple longer term, back-testable EMA condition "Longs only when Price > EMA / Shorts only when Price < EMA.

    Whilst this is straightforward to do in the Strategy Builder, having compiled the strat, I cannot of course reopen it within the Strat Builder to add the condition & my coding grammar is insufficient to put the code in EXACTLY the right place with the correct punctuation. Would some kind soul please show me where & how to do this in the NinjaScript Editor?

    Attached Files

    #2
    Hello jtrade,

    Thank you for writing in.

    If you are used to coding in the Strategy Builder, what you could do is start a new strategy temporarily through the builder. Set up the condition and actions how you desire, then click on the "View Code" button to see the code for the strategy. Under the OnBarUpdate() section you should be able to see the different sets of conditions, which you can then copy and paste into your HMAslope script as needed below Set 2 as shown in this screenshot:
    World's leading screen capture + recorder from Snagit + Screencast by Techsmith. Capture, edit and share professional-quality content seamlessly.


    This is a helpful workaround for editing a script after you have unlocked it from the Strategy Builder. Please let me know if I may be of further assistance.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    80 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    40 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    63 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    63 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    54 views
    0 likes
    Last Post CarlTrading  
    Working...
    X