Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multi-parameter ATM strategy

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

    Multi-parameter ATM strategy

    HI,

    Newbie question: I have combined the SampleATMStrategy with the SampleMACrossover for a Long Scalp. How do I add a second parameter (such as Double Stochastic < 20) to the "if" code? Is this correct?

    if (orderId.Length == 0 && atmStrategyId.Length == 0 && (CrossAbove(SMA(8), SMA(20), 1)), (DoubleStochastics(10) < 20, 1))


    And secondly, why do my ATM strategies show up as the same "SampleATMStrategy" when I click on the Strategies Tab, even though I give them individual names in NS Editor?

    Thanks for your help!
    Last edited by Cicero; 10-05-2020, 07:14 PM.

    #2
    Hello Cicero,

    Thanks for your post.

    Ninjascript is based on C# programming language so if you are not familiar with that you may want to search on-line for a C# tutorial to help your understanding.

    In this case the "&&" means a logical "AND" so you would write something like:

    if (orderId.Length == 0 && atmStrategyId.Length == 0 && (CrossAbove(SMA(8), SMA(20), 1)) && (DoubleStochastics(10)[0] < 20))

    Note that writing the indicators methods directly in place will work however it is not a "best Practice" and we recommend using private instances, as described in this section: https://ninjatrader.com/support/help...tm#Performance

    "And secondly, why do my ATM strategies show up as the same "SampleATMStrategy" when I click on the Strategies Tab, even though I give them individual names in NS Editor?". In a Ninjascript there are 3 places where the names should match, the file name, the Public class name, and the "Name = field in State.setDefaults. Please check that each script has the 3 matching areas.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    53 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 05-10-2026, 08:12 PM
    0 responses
    32 views
    0 likes
    Last Post CarlTrading  
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    195 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Started by CaptainJack, 04-24-2026, 11:07 PM
    0 responses
    358 views
    0 likes
    Last Post CaptainJack  
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    277 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Working...
    X