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

Problem showing arrows and sounds on strategy wizards

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

    Problem showing arrows and sounds on strategy wizards

    Hi, I am trying to use ninjaseven and write a simple strategy using strategy wizard. I can't seem to get any arrows to show up at all or a sound to play when the close crosses above or below the SAR. I had the same problem on Ninja 6. I posted the code below. Any ideas would be appreciated. Thanks. DJ

    // 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 Parabolic : Strategy
    {
    #region Variables
    // Wizard generated variables
    private int myInput0 = 1; // Default setting for MyInput0
    // 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;
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    // Condition set 1
    if (CrossAbove(Close, ParabolicSAR(0.02, 0.4, 0.04), 1))
    {
    DrawArrowDown("My down arrow" + CurrentBar, false, 1, 0, Color.Red);
    PlaySound(@"C:\Program Files\NinjaTrader 7\sounds\Alert1.wav");
    }

    // Condition set 2
    if (CrossBelow(Close, ParabolicSAR(0.02, 0.4, 0.07), 1))
    {
    DrawArrowUp("My up arrow" + CurrentBar, false, 0, 0, Color.Lime);
    PlaySound(@"C:\Program Files\NinjaTrader 7\sounds\Alert2.wav");
    }
    }

    #region Properties
    [Description("")]
    [GridCategory("Parameters")]
    public int MyInput0
    {
    get { return myInput0; }
    set { myInput0 = Math.Max(1, value); }
    }
    #endregion
    }
    }

    #region Wizard settings, neither change nor remove
    /*@
    <?xml version="1.0" encoding="utf-16"?>
    <NinjaTrader>
    <Name>Parabolic</Name>
    <CalculateOnBarClose>True</CalculateOnBarClose>
    <Description>Enter the description of your strategy here</Description>
    <Parameters>
    <Parameter>
    <Default1>
    </Default1>
    <Default2>1</Default2>
    <Default3>
    </Default3>
    <Description>
    </Description>
    <Minimum>1</Minimum>
    <Name>MyInput0</Name>
    <Type>int</Type>
    </Parameter>
    </Parameters>
    <State>
    <CurrentState>
    <StrategyWizardState xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <Name>Flat</Name>
    <Sets>
    <StrategyWizardStateSet>
    <Actions>
    <StrategyWizardAction>
    <DisplayName>Down arrow</DisplayName>
    <Help />
    <MemberName>DrawArrowDown</MemberName>
    <Parameters>
    <string>tag</string>
    <string>autoScale</string>
    <string>barsAgo</string>
    <string>y</string>
    <string>color</string>
    </Parameters>
    <Values>
    <string>"My down arrow"</string>
    <string>False</string>
    <string>1</string>
    <string>0</string>
    <string>Color.Red</string>
    </Values>
    <WizardItems>
    <StrategyWizardItem>
    <DisplayName />
    <IsIndicator>false</IsIndicator>
    <IsInt>false</IsInt>
    <IsMethod>false</IsMethod>
    <IsSet>true</IsSet>
    <MemberName />
    <Parameters />
    <Values />
    <WizardItems />
    </StrategyWizardItem>
    <StrategyWizardItem>
    <DisplayName />
    <IsIndicator>false</IsIndicator>
    <IsInt>false</IsInt>
    <IsMethod>false</IsMethod>
    <IsSet>true</IsSet>
    <MemberName />
    <Parameters />
    <Values />
    <WizardItems />
    </StrategyWizardItem>
    <StrategyWizardItem>
    <DisplayName>Numeric value</DisplayName>
    <IsIndicator>false</IsIndicator>
    <IsInt>true</IsInt>
    <IsMethod>false</IsMethod>
    <IsSet>true</IsSet>
    <MemberName>1</MemberName>
    <Parameters />
    #endregion

    #2
    Hello djkiwi,

    Welcome to the NinjaTrader forums!

    I'm not sure why the sound isn't playing. To start troubleshooting this I would go the location of the sound folder, double click the file, and verify you can hear the sound.

    Your arrows aren't drawing because of the Y value specified. See the corrected Draw code below, which draws arrows near Bar Highs and Lows. I've also attached a screenshot for how you would set up one side of this in the strategy wizard.

    Code:
     
    DrawArrowDown("My down arrow" + CurrentBar, false, 0, Low[0] - TickSize, Color.Red);
     
    DrawArrowUp("My up arrow" + CurrentBar, false, 0,High[0] + TickSize, Color.Lime);
    Attached Files
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Strategy in ninja 7

      Thanks Ryan. Well it all turned to custard on me. I am trying to figure out these strats but not finding it easy. I prepared this (file attached) in strategy wizard which works ok ninja trader 6 where all orders are activated but does not activate in ninja 7. Also not sure how you get the Ticks -1 as I get Low [0] Tick + -1 (so not sure why the + is there) when I try to do what you suggested using offset -1. I cannot get any strategies to work at all in ninja 7 even the sample ones. Not sure if I have a setting wrong somewhere. Nothing seems to activate.

      Cheers
      DJ
      Attached Files

      Comment


        #4
        djkiwi,

        To troubleshoot strategy order issues with NinjaTrader, add TraceOrders = true to your Initialize method. You can then view output for orders through Tools > Output window.

        There's nothing wrong with typing a value of -1 for a tickoffset.
        Low[0] + -1 * TickSize is the same as Low[0] - 1 * TickSize

        Above statement is likely not contributing to your strategy order issues. If there's any issue with the code then you will get compile errors and are unable to start the strategy.

        There has been a change in strategy activation from version 6.5 to 7. Once strategies are applied to a chart, they must be Enabled. Right click on chart > Strategies > Highlight a strategy and set Enabled to true.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Thanks for the help Ryan, it's the Activate True I didn't see, so arrows are fine now. One other thing though. I unlocked a strategy U did in strategy wizard and added some code then saved it as a different name. When I try to select the strategy it doesn't show up in the strategies window anywhere. It shows up in the directory ok and the file name shows as correct. I logged off ninja and went back in and still not there. Any ideas on this one? Thanks. DJ

          1.

          Comment


            #6
            UPDATE: I now have the strategy file showing but doesnt update. I made a change to the strategy saved it and replaced it but still has old version. Seems some lag somewhere. Thanks. DJ

            Comment


              #7
              Hello,

              I will have someone reply to you on Monday. Thank you for your patience.
              DenNinjaTrader Customer Service

              Comment


                #8
                Hello djkiwiw,

                Make sure you've compiled code recently and then remove and reapply any instances of the strategy. That should ensure you're using the latest version of your code.
                Ryan M.NinjaTrader Customer Service

                Comment


                  #9
                  arrows &amp; sounds open source code???

                  Hello, I saw your post, and it seems that u r doing something like I am looking for and that is the open source code here in Ninja 7 for my programmer to use in an auto trader using those arrow pivot points. What are u working on, and can i help?

                  Comment


                    #10
                    Sar offset issue

                    Hi Guys, I have a question parabolic SAR. When I place SAR on the chart as an indicator with a -1 offset it shows up ok. However when I try to do the same thing in strategy wizard ie place an arrow above the SAR with the offset the offset doesn't work. I can see it in the strategy wizard ok when I edit the file but when I view the code or run the strategy the offset doesn't appear or work. Attached is a picture of the chart where you can see the SAR indicator but no offset working on the arrow. Also code is below where you can see no offset shows up. Any ideas would be appreciated. Thanks. DJ

                    // Condition set 1
                    if (CrossBelow(Close, ParabolicSAR(0.015, 0.4, 0.04), 1)
                    && Close[0] < EMA(34)[0])
                    {
                    DrawTriangleDown("My triangle down" + CurrentBar, false, 0, Close[0] + 20 * TickSize, Color.Red);
                    PlaySound(@"C:\Program Files\NinjaTrader 7\sounds\Russell SAR Sell signal.wav");
                    }

                    // Condition set 2
                    if (CrossAbove(Close, ParabolicSAR(0.015, 0.4, 0.04), 1)
                    && Close[0] > EMA(34)[0])
                    {
                    DrawTriangleUp("My triangle up" + CurrentBar, false, 0, Close[0] + -20 * TickSize, Color.Lime);
                    PlaySound(@"C:\Program Files\NinjaTrader 7\sounds\Russell SAR Buy signal.wav");
                    Attached Files

                    Comment


                      #11
                      I don't follow here, djkiwi.

                      Your code is drawing arrows at + / - 20 ticks from the close. Is this what you intend or something else?
                      Ryan M.NinjaTrader Customer Service

                      Comment


                        #12
                        Hi Ryan, hope all is well. Actually the arrows are drawing ok but are not offsetting. If you look closely at the thumbnail you will notice the red dot SAR and the arrow one bar along . I did this by plotting the SAR indicator. What I am trying to do is offset the arrow as well so it is above the first dot of the offset SAR and gives me an alert. I can only get it to appear on the second no matter what I seem to try.

                        The only way I could see doing this was using a strategy, as per the code below. It basically draws the arrow once the closing price crosses above or below SAR. The problem when I put a -1 in the offset box of the SAR in strategy wizard it does not offset. In fact the -1 doesnt show up when I view the code but I can see it when I edit the code. Is this any clearer? Thanks. DJ

                        Code:

                        / Condition set 1
                        if (CrossBelow(Close, ParabolicSAR(0.015, 0.4, 0.04), 1)
                        && Close[0] < EMA(34)[0])
                        {
                        DrawTriangleDown("My triangle down" + CurrentBar, false, 0, Close[0] + 20 * TickSize, Color.Red);
                        PlaySound(@"C:\Program Files\NinjaTrader 7\sounds\Russell SAR Sell signal.wav");
                        }

                        // Condition set 2
                        if (CrossAbove(Close, ParabolicSAR(0.015, 0.4, 0.04), 1)
                        && Close[0] > EMA(34)[0])

                        Comment


                          #13
                          Let's clarify your expectation of offset. Offsets in the strategy wizard only apply to the Y (price) axis.

                          Where are you filling in the offset value, and what do you expect this to do? A screenshot of yours may be helpful to see where you're putting in this value.
                          Ryan M.NinjaTrader Customer Service

                          Comment


                            #14
                            Sar

                            Hi Ryan here you go. Is this the way to do the displacement? Thanks. DJ
                            Attached Files

                            Comment


                              #15
                              Hi Ryan, alternatively maybe it's better to put this code from the strategy wizard somehow in the parabolic SAR indicator.

                              // Condition set 1
                              if (CrossBelow(Close, ParabolicSAR(0.015, 0.4, 0.04), 1)
                              && Close[0] < EMA(34)[0])
                              {
                              DrawTriangleDown("My triangle down" + CurrentBar, false, 0, Close[0] + 20 * TickSize, Color.Red);
                              PlaySound(@"C:\Program Files\NinjaTrader 7\sounds\Russell SAR Sell signal.wav");
                              }

                              // Condition set 2
                              if (CrossAbove(Close, ParabolicSAR(0.015, 0.4, 0.04), 1)
                              && Close[0] > EMA(34)[0])
                              {
                              DrawTriangleUp("My triangle up" + CurrentBar, false, 0, Close[0] + -20 * TickSize, Color.Lime);
                              PlaySound(@"C:\Program Files\NinjaTrader 7\sounds\Russell SAR Buy signal.wav");

                              What do you think? Cheers. DJ

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Brevo, Today, 01:45 AM
                              0 responses
                              3 views
                              0 likes
                              Last Post Brevo
                              by Brevo
                               
                              Started by aussugardefender, Today, 01:07 AM
                              0 responses
                              3 views
                              0 likes
                              Last Post aussugardefender  
                              Started by pvincent, 06-23-2022, 12:53 PM
                              14 responses
                              240 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
                               
                              Started by oviejo, Today, 12:28 AM
                              0 responses
                              6 views
                              0 likes
                              Last Post oviejo
                              by oviejo
                               
                              Working...
                              X