NexusFi: Find Your Edge


Home Menu

 





Display Daily SMA within Renko chart


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one foodchain with 3 posts (0 thanks)
    2. looks_two cory with 1 posts (1 thanks)
    3. looks_3 vegasfoster with 1 posts (1 thanks)
    4. looks_4 TimeTrade with 1 posts (1 thanks)
    1. trending_up 2,390 views
    2. thumb_up 3 thanks given
    3. group 4 followers
    1. forum 6 posts
    2. attach_file 1 attachments




 
Search this Thread

Display Daily SMA within Renko chart

  #1 (permalink)
 foodchain 
san jose
 
Experience: Intermediate
Platform: ninjatrader, thinkorswim
Broker: IB
Trading: GC, CL, ES, ZF, ZN, DX, 6E
Posts: 22 since May 2010
Thanks Given: 12
Thanks Received: 1

The code below works fine with minutes chart that will display the daily 20 SMA with no problem.
Unfortunately, once i switch to Renko or Range chart, it's gone. Anyone can help, please.

 
Code
                            
protected override void Initialize()

        {
            
Add(PeriodType.Day1);
            
Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line"Plot0"));
            
Overlay                true;
        }

        
/// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        
protected override void OnBarUpdate()
        {
            
// Use this method for calculating your indicator values. Assign a value to each
            // plot below by replacing 'Close[0]' with your own formula.
            
            
if (CurrentBar 30) return;
            
            if (
BarsInProgress == 0){
                
Plot0.Set(SMA(BarsArray[1],20)[0]);
            }
        } 

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
REcommedations for programming help
Sierra Chart
How to apply profiles
Traders Hideout
NexusFi Journal Challenge - May 2024
Feedback and Announcements
MC PL editor upgrade
MultiCharts
Quant vue
Trading Reviews and Vendors
 
  #3 (permalink)
 
cory's Avatar
 cory 
virginia
 
Experience: Intermediate
Platform: ninja
Trading: NQ
Posts: 6,098 since Jun 2009
Thanks Given: 877
Thanks Received: 8,090


try this sample code

Attached Files
Elite Membership required to download: AddMA.cs
Reply With Quote
Thanked by:
  #4 (permalink)
 foodchain 
san jose
 
Experience: Intermediate
Platform: ninjatrader, thinkorswim
Broker: IB
Trading: GC, CL, ES, ZF, ZN, DX, 6E
Posts: 22 since May 2010
Thanks Given: 12
Thanks Received: 1


cory View Post
try this sample code

Cory, your code displays the 20 SMA of the Renko bar.
What I want is to display the "DAILY 20 SMA" within a 4 Renko chart.

Thanks pal

Started this thread Reply With Quote
  #5 (permalink)
 vegasfoster 
las vegas
 
Experience: Intermediate
Platform: Sierra Chart
Broker: Velocity/IB
Trading: 6E
Posts: 1,145 since Feb 2010
Thanks Given: 304
Thanks Received: 844

I think I've done it before like

 
Code
protected override void Initialize()

        {

            Add(PeriodType.Day, 1);

            Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));

            Overlay                = true;

        }



        /// <summary>

        /// Called on each bar update event (incoming tick)

        /// </summary>

        protected override void OnBarUpdate()

        {

            // Use this method for calculating your indicator values. Assign a value to each

            // plot below by replacing 'Close[0]' with your own formula.

            

            if (CurrentBar < 30) return;

            

            if (BarsInProgress == 0){

                Plot0.Set(SimpleMA);

            }

            if (BarsInProgress == 1){

                double SimpleMA = SMA(Closes[1],20)[0]);

            }


        }


It's been while though, so not sure if syntax is 100% correct or if it will make a difference even if it is, so anyone feel free to correct me, but it might be worth a try.

Reply With Quote
Thanked by:
  #6 (permalink)
 TimeTrade 
Erfurt Germany
 
Experience: Master
Platform: rtMagic, NinjaTrader
Broker: AMP/CQG, IAB
Trading: ES, 6E, FDAX, FGBL
Posts: 338 since Aug 2011
Thanks Given: 54
Thanks Received: 461


vegasfoster View Post
I think I've done it before like

 
Code
protected override void Initialize()

        {

            Add(PeriodType.Day, 1);

            Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));

            Overlay                = true;

        }



        /// <summary>

        /// Called on each bar update event (incoming tick)

        /// </summary>

        private double SimpleMA=0;

        protected override void OnBarUpdate()

        {

            // Use this method for calculating your indicator values. Assign a value to each

            // plot below by replacing 'Close[0]' with your own formula.

            

            if (CurrentBar < 30) return;

            

            if (BarsInProgress == 0){

                if(SimpleMA!=0) Plot0.Set(SimpleMA);

            }

            if (BarsInProgress == 1){

                /*double*/ SimpleMA = SMA(Closes[1],20)[0]);

            }


        }


It's been while though, so not sure if syntax is 100% correct or if it will make a difference even if it is, so anyone feel free to correct me, but it might be worth a try.

-> you need for this logic a "global variable"!

Reply With Quote
Thanked by:
  #7 (permalink)
 foodchain 
san jose
 
Experience: Intermediate
Platform: ninjatrader, thinkorswim
Broker: IB
Trading: GC, CL, ES, ZF, ZN, DX, 6E
Posts: 22 since May 2010
Thanks Given: 12
Thanks Received: 1

Thanks !

Started this thread Reply With Quote




Last Updated on May 2, 2012


© 2024 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 - Privacy Policy - Downloads - Top
no new posts