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

BUY SELL SIGNAL using ema 8 10 21

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

    BUY SELL SIGNAL using ema 8 10 21

    Click image for larger version

Name:	image.png
Views:	137
Size:	31.3 KB
ID:	1290172
    hi guys if anyone with has an experience with ninjascript editor i get a lot of error trying to add simple filters to this indicator that show arrows to filter signals here are the condition for the filters :

    first for the buy signal i want to add the filter of the 8ema must be abov the 10ema and the 21 ema and for the sell case i want the 8 ema to be under the 10 ema and under the 21 ema, the buy signal the candle must close above the 8 ema and for the sell the candle must close undder the 8 ema + sound alert when arrow prints

    if anyone can help debugging this code i will be more than happy it a good strategy for scalping between .

    here is the code that gets a tone of errors :

    // Inside NinjaTrader.NinjaScript.Indicators namespace

    region Using declarations
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Xml.Serialization;
    using NinjaTrader.Cbi;
    using NinjaTrader.Gui;
    import NinjaTrader.Gui.Chart;
    import NinjaTrader.Gui.SuperDom;
    import NinjaTrader.Gui.Tools;
    import NinjaTrader.Data;
    import NinjaTrader.NinjaScript;
    using NinjaTrader.Core.FloatingPoint;

    #endregion

    namespace NinjaTrader.NinjaScript.Indicators
    {
    public partial class SCALPbuysell : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
    {
    // Existing code...

    region Properties
    [Browsable(false)]
    [XmlIgnore]
    public Series<double> EMA8 { get; private set; }

    [Browsable(false)]
    [XmlIgnore]
    public Series<double> EMA10 { get; private set; }

    [Browsable(false)]
    [XmlIgnore]
    public Series<double> EMA21 { get; private set; }
    #endregion

    protected override void OnStateChange()
    {
    // Existing code...

    if (State == State.SetDefaults)
    {
    // Set default values for existing parameters...

    EMA8 = new Series<double>(this);
    EMA10 = new Series<double>(this);
    EMA21 = new Series<double>(this);
    }
    }

    protected override void OnBarUpdate()
    {
    // Calculate EMAs
    double ema8Value = EMA(Closes[0], 8)[0];
    double ema10Value = EMA(Closes[0], 10)[0];
    double ema21Value = EMA(Closes[0], 21)[0];

    // Buy Signal Filter: 8 EMA above 10 EMA and 21 EMA, Candle closes above 8 EMA
    bool buyFilter = ema8Value > ema10Value && ema8Value > ema21Value && Close[0] > ema8Value;

    // Sell Signal Filter: 8 EMA below 10 EMA and 21 EMA, Candle closes below 8 EMA
    bool sellFilter = ema8Value < ema10Value && ema8Value < ema21Value && Close[0] < ema8Value;

    // Your main logic here...
    if (buyFilter)
    {
    // Buy Signal Action
    Print("Buy Signal on " + this.Name);
    // Your logic for Buy Signal...
    }
    else if (sellFilter)
    {
    // Sell Signal Action
    Print("Sell Signal on " + this.Name);
    // Your logic for Sell Signal...
    }
    }

    // Remaining code from the provided BuySellCandleMarker class goes here...
    }
    }

    #2
    Hello kamikaz98,

    What are the errors you would like assistance with?

    For this to be an indicator the class should be declared as:
    Code:
    public class SCALPbuysell : Indicator
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      hi chelsea B most errors are CS0117
      some times the ema is identified as variable instead of being a type i tried to complie many times it doesn't work thank you for the response

      Comment


        #4
        Hello kamikaz98,

        Please provide the full error message which will include line numbers (or provide a screenshot).

        May I confirm you have changed the class definition as directed and are still getting the errors?

        [Browsable(false)]
        [XmlIgnore]
        public Series<double> EMA8 { get; private set; }​

        May I inquire why you are using 'private set' in the setter of public properties? (Are there still compile errors if you remove the private access modifier keyword?)
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Click image for larger version

Name:	image.png
Views:	91
Size:	75.7 KB
ID:	1290256
          actualy im using chatgpt to correct the errors but still same

          here is the code

          // Inside NinjaTrader.NinjaScript.Indicators namespace

          region Using declarations
          using System;
          using System.Collections.Generic;
          using System.ComponentModel;
          using System.ComponentModel.DataAnnotations;
          using System.Linq;
          using System.Text;
          using System.Threading.Tasks;
          using System.Windows;
          using System.Windows.Input;
          using System.Windows.Media;
          using System.Xml.Serialization;
          using NinjaTrader.Cbi;
          using NinjaTrader.Gui;
          import NinjaTrader.Gui.Chart;
          import NinjaTrader.Gui.SuperDom;
          import NinjaTrader.Gui.Tools;
          import NinjaTrader.Data;
          import NinjaTrader.NinjaScript;
          using NinjaTrader.Core.FloatingPoint;

          #endregion

          namespace NinjaTrader.NinjaScript.Indicators
          {
          public partial class SCALPbuysell : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
          {
          // Existing code...

          region Properties
          [Browsable(false)]
          [XmlIgnore]
          public Series<double> EMA8 { get; private set; }

          [Browsable(false)]
          [XmlIgnore]
          public Series<double> EMA10 { get; private set; }

          [Browsable(false)]
          [XmlIgnore]
          public Series<double> EMA21 { get; private set; }
          #endregion

          protected override void OnStateChange()
          {
          // Existing code...

          if (State == State.SetDefaults)
          {
          // Set default values for existing parameters...

          EMA8 = new Series<double>(this);
          EMA10 = new Series<double>(this);
          EMA21 = new Series<double>(this);
          }
          }

          protected override void OnBarUpdate()
          {
          // Calculate EMAs
          double ema8Value = EMA(Closes[0], 8)[0];
          double ema10Value = EMA(Closes[0], 10)[0];
          double ema21Value = EMA(Closes[0], 21)[0];

          // Buy Signal Filter: 8 EMA above 10 EMA and 21 EMA, Candle closes above 8 EMA
          bool buyFilter = ema8Value > ema10Value && ema8Value > ema21Value && Close[0] > ema8Value;

          // Sell Signal Filter: 8 EMA below 10 EMA and 21 EMA, Candle closes below 8 EMA
          bool sellFilter = ema8Value < ema10Value && ema8Value < ema21Value && Close[0] < ema8Value;

          // Your main logic here...
          if (buyFilter)
          {
          // Buy Signal Action
          Print("Buy Signal on " + this.Name);
          // Your logic for Buy Signal...
          }
          else if (sellFilter)
          {
          // Sell Signal Action
          Print("Sell Signal on " + this.Name);
          // Your logic for Sell Signal...
          }
          }

          // Remaining code from the provided BuySellCandleMarker class goes here...
          }
          }

          Comment


            #6
            Hello kamikaz98,

            The errors are for lines 15 and 17.

            It may be an issue with the import keyword instead of the using keyword.

            import NinjaTrader.Gui.Chart;
            import NinjaTrader.Gui.SuperDom;
            import NinjaTrader.Gui.Tools;
            import NinjaTrader.Data;
            import NinjaTrader.NinjaScript;

            May I inquire why you are using the import keyword instead of the using keyword?​
            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Haiasi, 04-25-2024, 06:53 PM
            2 responses
            16 views
            0 likes
            Last Post Massinisa  
            Started by Creamers, Today, 05:32 AM
            0 responses
            4 views
            0 likes
            Last Post Creamers  
            Started by Segwin, 05-07-2018, 02:15 PM
            12 responses
            1,785 views
            0 likes
            Last Post Leafcutter  
            Started by poplagelu, Today, 05:00 AM
            0 responses
            3 views
            0 likes
            Last Post poplagelu  
            Started by fx.practic, 10-15-2013, 12:53 AM
            5 responses
            5,407 views
            0 likes
            Last Post Bidder
            by Bidder
             
            Working...
            X