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, 03-31-2026, 09:41 PM
    1 response
    45 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    21 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    31 views
    1 like
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    50 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    42 views
    0 likes
    Last Post CarlTrading  
    Working...
    X