NexusFi: Find Your Edge


Home Menu

 





Double MA and Triple MA Script


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one Sadboybh with 3 posts (0 thanks)
    2. looks_two cory with 2 posts (0 thanks)
    3. looks_3 Big Mike with 2 posts (1 thanks)
    4. looks_4 Quick Summary with 1 posts (0 thanks)
    1. trending_up 4,770 views
    2. thumb_up 2 thanks given
    3. group 2 followers
    1. forum 8 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
Sadboybh
Bahrain
 
Posts: 12 since May 2011
Thanks Given: 4
Thanks Received: 0

Hi guys,
I am trying to make a script that consists of 2 original SMA indicators , I tried so many ways to duplicate the original but it didn't work out for me..

I would highly appreciate it if someone can tell me how to make a double or triple version of the original SMA.

one more thing: Can I set the value of one SMA to CalculateOnBarClose = false, and the other one to CalculateOnBarClose = true !!!

Thanks...


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Datafeed for Atas
Platforms and Indicators
Warsh Drops Easing Bias, December Hike Now Above 50% -- …
Prediction Markets & Event Contracts
Without Pulisic, USA 61.5% Live vs. Australia -- France …
Prediction Markets & Event Contracts
Would a node-based workflow for automated trading be useful?
Traders Hideout
Daytrading to swingtrading
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Want your NinjaTrader indicator created, free?
5 thanks
BERN ALGOS algo trading journal
1 thanks
Afternoon-close session
1 thanks
Franks Trading Journey
1 thanks
Denied 20K payouts: Alpha Futures
1 thanks
  #3 (permalink)
 
cory's Avatar
 cory 
virginia
 
Experience: Intermediate
Platform: ninja
Trading: NQ
Posts: 6,099 since Jun 2009
Thanks Given: 877
Thanks Received: 8,098


is this NT7? just specify MA of MA of MA you don't need any script.


Reply With Quote
  #4 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 R.I.P. 1977-2026 
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,669 since Jun 2009
Thanks Given: 33,669
Thanks Received: 102,586


Sadboybh View Post
I would highly appreciate it if someone can tell me how to make a double or triple version of the original SMA.

 
Code
                            
#init

private double dsma;

#onbarupdate
dsma SMA(SMA(Close20), 100); 
Will give you a double sma.


Quoting 
one more thing: Can I set the value of one SMA to CalculateOnBarClose = false, and the other one to CalculateOnBarClose = true !!!

No.

Mike




We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on X Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #5 (permalink)
Sadboybh
Bahrain
 
Posts: 12 since May 2011
Thanks Given: 4
Thanks Received: 0


Big Mike View Post
 
Code
                            
#init
private double dsma;

#onbarupdate
dsma SMA(SMA(Close20), 100); 
Will give you a double sma.



No.

Mike

thank you mike,
but if i set the previous code, how will i be able to customize each plots characteristics, for example if i wanna add a condition that changes the 20SMA color when it crosses above the 100SMA !!

if both SMAs has one defined variable which is private double dsma, how will i be able to change each SMA's separately ? what's the unique definition for the 20SMA ? and whats is for the 100SMA ?

thanks in advance


Reply With Quote
  #6 (permalink)
Sadboybh
Bahrain
 
Posts: 12 since May 2011
Thanks Given: 4
Thanks Received: 0

plus it keeps on telling me that cannot convert ninjatrader.type.indicator.SMA to double !!!!


any other thoughts bro ?


Reply With Quote
  #7 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 R.I.P. 1977-2026 
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,669 since Jun 2009
Thanks Given: 33,669
Thanks Received: 102,586


Sadboybh View Post
plus it keeps on telling me that cannot convert ninjatrader.type.indicator.SMA to double !!!!


any other thoughts bro ?

Type-o in my code. I haven't used NT in 18 months, give me a small break Add [0] to end to reference DataSeries.

 
Code
                            
dsma SMA(SMA(Close20), 100)[0]; 



Sadboybh View Post
thank you mike,
but if i set the previous code, how will i be able to customize each plots characteristics, for example if i wanna add a condition that changes the 20SMA color when it crosses above the 100SMA !!

if both SMAs has one defined variable which is private double dsma, how will i be able to change each SMA's separately ? what's the unique definition for the 20SMA ? and whats is for the 100SMA ?

thanks in advance

Try watching @sam028's basic intro webinar on NT programming which covers multi color plots:


And/or @shodson's NT webinar which gives you the basic building blocks of C#:


Or look at any one of the hundreds of indicators on nexusfi.com (formerly BMT) that have multicolor plots and look at the code and learn. Try also buying some C# books to get you started.

Mike




We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on X Visit my NexusFi Trade Journal Reply With Quote
  #8 (permalink)
 
cory's Avatar
 cory 
virginia
 
Experience: Intermediate
Platform: ninja
Trading: NQ
Posts: 6,099 since Jun 2009
Thanks Given: 877
Thanks Received: 8,098

or search for double or triple
https://nexusfi.com/search/attachments/


Reply With Quote
  #9 (permalink)
 
RJay's Avatar
 RJay 
Hartford, CT. USA
 Vendor: www.innovative-trading-solutions-online.com 
 
Experience: Intermediate
Platform: NinjaTrader
Broker: AMP/CQG, Kinetick
Trading: ES
Posts: 687 since Jun 2009
Thanks Given: 765
Thanks Received: 789

or just look at NT's TRIX indicator for code on building a triple MA.


Reply With Quote
Thanked by:




Last Updated on June 17, 2011


© 2026 NexusFi®, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Downloads - Top
no new posts