Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy not working

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

    Strategy not working

    Hi,

    I have created a simple strategy using the Wizard.

    The strategy I have is when price crosses above a 50 EMA a buy will occur and when the price crosses below the EMA is triggers a sell.

    When backtesting it no trades occur, not sure if my code is correct.

    Screenshots:

    Code:




    Uploaded with ImageShack.us







    Thanks
    Ivan
    Last edited by ibrown; 01-09-2012, 12:33 PM.

    #2
    ibrown,

    You are adding EMA's with 0 period. You will want to use something like EMA(50), etc. Currently what you have is a CrossAbove() and CrossBelow() condition for two equal EMA's.

    Please let me know if I may assist further.
    Adam P.NinjaTrader Customer Service

    Comment


      #3
      I have now added the 50 but still not getting anything.

      Code:
      protectedoverridevoid Initialize()
      {
      Add(EMA(
      50));
      Add(EMA(
      50));
      Add(EMA(
      50));
      Add(EMA(
      50));
      SetProfitTarget(
      "", CalculationMode.Ticks, 50);
      SetStopLoss(
      "", CalculationMode.Ticks, 25, false);
      CalculateOnBarClose =
      true;
      }
      ///<summary>
      /// Called on each bar update event (incoming tick)
      ///</summary>
      protectedoverridevoid OnBarUpdate()
      {
      // Condition set 1
      if (CrossAbove(EMA(50), EMA(50), 1))
      {
      EnterLong(
      1, "");
      }
      // Condition set 2
      if (CrossBelow(EMA(50), EMA(50), 1))
      {
      EnterShort(
      1, "");
      }

      Comment


        #4
        not sure if it makes any difference I trading the EUR/USD on 24/7 session templete using a tick chart.

        Comment


          #5
          ibrown,

          CrossAbove(EMA(50),EMA(50),1) will never occur because its basically asking, if a 50 period ema crosses above a 50 period ema. I would suggest using two different periods for the EMA. What are you trying to do? Close crossing the EMA or two EMA's crossing eachother?
          Adam P.NinjaTrader Customer Service

          Comment


            #6
            i am wanting to use just 1 EMA with price crossing it.

            Comment


              #7
              ibrown,

              You probably want to use CrossAbove(Close,EMA(50),1) and CrossBelow(Close,EMA(50),1).

              Please let me know if I may assist further.
              Adam P.NinjaTrader Customer Service

              Comment


                #8
                not sure what to do next. can't work out how to do it in the Wizard but I haven't compiled or clicked unlock code.

                Comment


                  #9
                  ibrown,

                  Please see the attached screenshot. It should show you how to implement the CrossAbove condition.

                  Please let me know if I may assist further.
                  Attached Files
                  Adam P.NinjaTrader Customer Service

                  Comment


                    #10
                    ah yep looks like its done it!!!

                    Screenshot:

                    Comment


                      #11
                      ibrown,

                      I am happy you have resolved your issue.

                      Here is a youtube video on automated strategy development : https://www.youtube.com/watch?v=fVFq...1&feature=plcp

                      Please don't hesitate to contact us should you require additional assistance.
                      Adam P.NinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                      0 responses
                      656 views
                      0 likes
                      Last Post Geovanny Suaza  
                      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                      0 responses
                      371 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by Mindset, 02-09-2026, 11:44 AM
                      0 responses
                      109 views
                      0 likes
                      Last Post Mindset
                      by Mindset
                       
                      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                      0 responses
                      574 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by RFrosty, 01-28-2026, 06:49 PM
                      0 responses
                      579 views
                      1 like
                      Last Post RFrosty
                      by RFrosty
                       
                      Working...
                      X