Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

RSI25 Short Strategy Unable to implement

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

    RSI25 Short Strategy Unable to implement

    Hi all,

    I am trying to write RSI25 Strategy for Short Only, here is my codes:
    __________________________________________________ ________
    #region Using declarations
    using System;
    using System.ComponentModel;
    using System.Diagnostics;
    using System.Drawing;
    using System.Drawing.Drawing2D;
    using System.Xml.Serialization;
    using NinjaTrader.Cbi;
    using NinjaTrader.Data;
    using NinjaTrader.Indicator;
    using NinjaTrader.Gui.Chart;
    using NinjaTrader.Strategy;
    #endregion

    // This namespace holds all strategies and is required. Do not change it.
    namespace NinjaTrader.Strategy
    {
    /// <summary>
    /// Enter the description of your strategy here
    /// </summary>
    [Description("Enter the description of your strategy here")]
    public class QuanRSIShort : Strategy
    {
    #region Variables
    // Wizard generated variables
    private int period = 2; // Default setting for Period
    string op="";
    // User defined variables (add any user defined variables below)
    #endregion

    /// <summary>
    /// This method is used to configure the strategy and is called once before any strategy method is called.
    /// </summary>
    protected override void Initialize()
    {
    CalculateOnBarClose = true;
    Add(QuanRSI(period));
    Add(EMA(period));
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    if(CrossAbove(QuanRSI(period),75,1) && Close[0]<EMA(period)[0])
    {
    EnterShort(DefaultQuantity, "EnterShort");
    }
    if(CrossBelow(QuanRSI(period),45,1))
    {
    ExitShort("ExitShort");
    }
    }

    #region Properties
    [Description("")]
    [GridCategory("Parameters")]
    public int Period
    {
    get { return period; }
    set { period = Math.Max(1, value); }
    }
    #endregion
    }
    }
    __________________________________________________ ____________
    Successfully Compile without any implementation.
    Hope somebody can help me.
    Thank you.

    #2
    Hello qzhang119,

    Thank you for your post and welcome to the NinjaTrader support forum!

    You have stated you are able to compile this strategy without any compile errors, but are unable to implement the strategy. I was also able to compile this strategy without any compile errors, however I was able to enable the strategy on the Strategies tab of the Control Center.

    Please advise if you are receiving an error message when enabling the strategy on your chart or on the Strategies tab of the Control Center.
    If you are receiving an error message, do you receive the same message when enabling the SampleMACrossOver that is preloaded in NinjaTrader?

    I look forward to assisting you further.

    Comment


      #3
      Thanks for your assistance Patrick.
      I am able to enable the strategy, but there is no result - no entry & exit.
      I have try to adjust my variables, but still no outcomes.
      Here are some screenshots:



      Thanks.

      Comment


        #4
        Hello qzhang119,

        Thank you for your response.

        I have the same results using your strategy. I recommend debugging your NinjaScript code to discover exactly why the entry orders are never executed.
        I would start with the conditions to enter, by placing a Print() statement after the condition to see if the condition is ever meet such as the following:
        Code:
        if(CrossAbove(QuanRSI(period),75,1) && Close[0]<EMA(period)[0])
        {
        [B]Print("Enter Short Condition has been meet.");[/B]
        EnterShort(DefaultQuantity, "EnterShort");
        }
        For information on debugging your NinjaScript code please visit the following link: http://www.ninjatrader.com/support/f...ead.php?t=3418

        Please let me know if I may be of further assistance.

        Comment


          #5
          Hi Patrick,

          I delete "Close[0]<EMA(period)[0]" in "if(CrossAbove(QuanRSI(period),75,1) && Close[0]<EMA(period)[0])"
          And the strategy works, I cannot figure out why that condition sentence blocked my strategy, do you have any idea?

          Thanks a lot

          Comment


            #6
            Hello qzhang119,

            Thank you for your response.

            This could be due to the fact that the current price is never less than the EMA when the QuanRSI crosses above 75 within the last bar. Of course this would require further troubleshooting on your end to determine if this is for certain.

            Please let me know if I may be of further assistance.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by burtoninlondon, Today, 12:38 AM
            0 responses
            10 views
            0 likes
            Last Post burtoninlondon  
            Started by AaronKoRn, Yesterday, 09:49 PM
            0 responses
            14 views
            0 likes
            Last Post AaronKoRn  
            Started by carnitron, Yesterday, 08:42 PM
            0 responses
            11 views
            0 likes
            Last Post carnitron  
            Started by strategist007, Yesterday, 07:51 PM
            0 responses
            14 views
            0 likes
            Last Post strategist007  
            Started by StockTrader88, 03-06-2021, 08:58 AM
            44 responses
            3,983 views
            3 likes
            Last Post jhudas88  
            Working...
            X