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 NullPointStrategies, Yesterday, 05:17 AM
    0 responses
    63 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    139 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    75 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    45 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    50 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X