Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Help developing simple oscillator

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

    Help developing simple oscillator

    Hi,
    I want to develop an oscillator. I have candlesticks on my chart and 2 moving averages. SMA 25 and SMA 300. If a candlestick is above SMA 25 I want a blue colored bar to appear on the oscillator. When a candlestick is above SMA 300 I want the oscillator to have a green colored bar. When a candlestick is below SMA 300 I want the oscillator to have a red bar, and when a candlestick is below SMA 25 I want it to have grey bar.
    I also want this oscillator to be in pane 2 (below the candlesticks on the chart). I'm using 5 minute candles.

    How can this be done, and is it easy to do? Thanks for any help.

    Edit: If this can't be done, then simply the candlestick being below/above SMA 300 producing red/green bars would be sufficient.

    #2
    Yes this can be done and its not that complex at all.

    I suggest starting off looking at the indicator development tutorials in our Help Guide as a starting point to gain experience with developing indicators.

    Once you have reviewed the tutorials the following code will make more sense:

    if (Close[0] > SMA(25)[0]) BarColor = Color.Blue;

    If you do not have the time to invest, you can alway opt to contact one of our qualified NinjaScript Consultants.

    RayNinjaTrader Customer Service

    Comment


      #3
      Take this as an inspiration:

      Comment


        #4
        Thanks.

        I have another question. Can another time frame be 'called on'? For example, the chart that's open is the 15 minute chart, but in the indicator I want to use another time frame as a reference (like the 30 minute time frame for example). How can that be used?

        The code I use now is this:

        if (Close[0] < SMA(Close, 25)[0])
        do something here;

        But that code only uses the opened time frame as a reference. I want the SMA to be calculated as if it was being calculated on the 30 minute chart, instead of the opened 15 minute chart. How can this be done?

        Comment


          #5
          Multi-series is not supported in indicator development but will be for NT7. However, multi-series is supported currently for strategy development. More information on that in the link below.

          RayNinjaTrader Customer Service

          Comment


            #6
            Is there another way to calculate what a 25 SMA is on a 30 minute chart in an indicator while you're using a 15 minute chart?

            Comment


              #7
              Not at this time unfortunately.
              RayNinjaTrader Customer Service

              Comment


                #8
                Is there a mathematical way to do it?

                Comment


                  #9
                  Likely could be done but outside what we provide support for.
                  RayNinjaTrader Customer Service

                  Comment


                    #10
                    Any hint as to where I might look for something like that, or what I could search for?

                    Comment


                      #11
                      Unfortunately I don't have a hint to share.
                      RayNinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by DJ888, 04-16-2024, 06:09 PM
                      4 responses
                      12 views
                      0 likes
                      Last Post DJ888
                      by DJ888
                       
                      Started by terofs, Today, 04:18 PM
                      0 responses
                      11 views
                      0 likes
                      Last Post terofs
                      by terofs
                       
                      Started by nandhumca, Today, 03:41 PM
                      0 responses
                      7 views
                      0 likes
                      Last Post nandhumca  
                      Started by The_Sec, Today, 03:37 PM
                      0 responses
                      3 views
                      0 likes
                      Last Post The_Sec
                      by The_Sec
                       
                      Started by GwFutures1988, Today, 02:48 PM
                      1 response
                      9 views
                      0 likes
                      Last Post NinjaTrader_Clayton  
                      Working...
                      X