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

Everytime EMA lines cross, Enter and exit the trade once the most

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

    Everytime EMA lines cross, Enter and exit the trade once the most

    Sorry everyone..i am a noob.
    I think something is wrong with my codes. It's not working the way I want. What I want it to do is to enter long when the EMA(fast) crosses above the EMA(Slow) by $1. And it will exit the trade if EMA(fast) cross above the EMA(slow) by $5 or exit when EMA(fast) == EMA(slow)...pretty much the same for short...If u see anything wrong..please advise. Thanks much!

    //No Ninjatrader here...Codes have a lot of syntax error...it's just my idea

    If(Crossabove EMA(fast), EMA(Slow)) {

    If( EMA(fast) - EMA(slow) >1)
    EnterLong();
    If("Long"position == existed && EmA(fast) - EMA(slow) >5)
    Exitlong();
    }


    If(EMA(fast)==EMA(slow))
    Exitlong();

    ===============
    //short

    If(Crossabove EMA(Slow), EMA(fast)) {

    If( EMA(slow) - EMA(fast) >1)
    EnterShort();
    If("Short"position == existed && EmA(slow) - EMA(fast) >5)
    ExitShort();
    }


    If(EMA(fast)==EMA(slow))
    ExitShort();

    #2
    Hello Feng,

    Thank you for your post.

    There are a couple issues with capitalization here, which is important since C# is case sensitive.
    If should be lower case if
    Crossabove should be CrossAbove

    Your syntax for verifying a long or short position is not correct. Should use the MarketPosition property for this:


    I recommend playing with the condition builder at first and then seeing how the code is displayed to get the proper syntax.

    There is also a built in crossover strategy that you can use for help on proper syntax.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      I am aware of all the syntax error..I don't have ninjatrader or any complier on me now. I just want to know if there is any logical error with the codes. When I backtested and looked at the chart, i could tell the codes did not work preoperly. Thanks!
      Last edited by feng2088; 02-08-2010, 12:42 PM.

      Comment


        #4
        Hello,

        Unfortunately we're not able to offer support for this or debugging. Looking briefly over your code I'm not able to see anything that stands out. If you have compiled NinjaScript code that is not working as expected please post the code sample or attach the file.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Thank you. I will post my code tonight when I get home.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by helpwanted, Today, 03:06 AM
          1 response
          7 views
          0 likes
          Last Post sarafuenonly123  
          Started by Brevo, Today, 01:45 AM
          0 responses
          7 views
          0 likes
          Last Post Brevo
          by Brevo
           
          Started by aussugardefender, Today, 01:07 AM
          0 responses
          5 views
          0 likes
          Last Post aussugardefender  
          Started by pvincent, 06-23-2022, 12:53 PM
          14 responses
          242 views
          0 likes
          Last Post Nyman
          by Nyman
           
          Started by TraderG23, 12-08-2023, 07:56 AM
          9 responses
          384 views
          1 like
          Last Post Gavini
          by Gavini
           
          Working...
          X