Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Moving Average Cross colors

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

    Moving Average Cross colors

    Please help! I'm trying to color two moving averages based on when MA1 is above MA2.

    What I'm trying to achieve is to have both MA's Green when MA1 is above MA2 and Both MA's Red when MA1 is below MA2.

    Here is the code I have been working on but it doesnt do what I am trying to achieve. Any help would be appreciated.

    thanks.

    Jason


    protected override void Initialize()
    {
    Add(new Plot(Color.FromKnownColor(KnownColor.SpringGreen), PlotStyle.Line, "FastAbove"));
    Add(new Plot(Color.FromKnownColor(KnownColor.Red), PlotStyle.Line, "FastBelow"));
    Add(new Plot(Color.FromKnownColor(KnownColor.DarkViolet), PlotStyle.Line, "SlowAbove"));
    Add(new Plot(Color.FromKnownColor(KnownColor.Red), PlotStyle.Line, "SlowBelow"));
    Overlay = false;
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {

    bool Bearish=(EMA(6)[0] < SMA(14)[0]);
    bool Bullish=(EMA(6)[0] > SMA (14) [0]);


    if (Bearish)
    FastBelow.Set(EMA(6)[0]);
    if (Bearish)
    SlowBelow.Set(SMA(14)[0]);

    if (Bullish)
    FastAbove.Set(EMA(6)[0]);
    SlowAbove.Set(SMA(14)[0]);
    }

    #2
    Hi Jason, please work alongside this reference sample here for your coding task - http://www.ninjatrader.com/support/f...ead.php?t=3227
    BertrandNinjaTrader Customer Service

    Comment


      #3
      MA crossover

      Guess this is doing what you are looking. Coded for NT7
      Regards.

      Finn "Jurbol"
      Last edited by finnbjurvoll; 11-10-2011, 05:10 PM.

      Comment


        #4
        Finnbjurvoll -

        Yes ! Thank you! That is exactly what I was looking for. I was looking for the indicator in the 'edit ninja script' section of the tools menu and I cant find this indicator listed with the other indicators in NinjaTrader. I'm not able to edit the indicator. Do you know why? Does it have something to do with the DLL file?

        The indicator does what I was looking but I was trying to edit it so the longer MA was an SMA and the Shorter MA was an EMA.

        Excellent work. Thanks.

        Comment


          #5
          Edit Indicator

          If you imported it in NT7, you should be able to edit the indicator. How did you install the indicator? Didi you use : File > Utilities > Import NinjaScript?

          Comment


            #6
            Yes. That is how I imported it but I'm not able to see it in the available list of indicators to edit. Its really strange.

            I looked in the directory : documents/NinjaTrader7/bin/Custom
            and it looks like the .cs and .dll files are in there. Is that where they are supposed to be? I'm not sure why NinjaTrader would put them there.

            Comment


              #7
              Jason

              Ok, I think maybe i exported it the wrong way However, I reprogrammed it so the slow is now a sma. I guess you will be able to open this one. Please let me know i you need more help. Finn
              Attached Files

              Comment


                #8
                Please ignore previous message

                Jason, please ignor the previous file, I did a mistake in the code, this is the one you want.
                Attached Files

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by t.kelly4149, Today, 05:36 PM
                1 response
                8 views
                0 likes
                Last Post bltdavid  
                Started by SilverSurfer1, Today, 06:29 PM
                0 responses
                16 views
                0 likes
                Last Post SilverSurfer1  
                Started by trader3000a, Today, 01:06 PM
                1 response
                9 views
                0 likes
                Last Post NinjaTrader_ShawnB  
                Started by marcus2300, Today, 11:45 AM
                3 responses
                31 views
                0 likes
                Last Post marcus2300  
                Started by pel11, Today, 11:06 AM
                0 responses
                13 views
                0 likes
                Last Post pel11
                by pel11
                 
                Working...
                X