• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Switching direction

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

    Switching direction

    I am trying to set up a notification for when an indicator switches direction. This seems pretty simple but my code isn't working and I'm not great with trouble shooting yet. What am I doing wrong here? Is there an easier way of doing this?

    Code:
    if 	(
    					
    	SMA(20)[0] < SMA(20)[1]
            && SMA(20)[1] > SMA(20)[2]
    			
    	)
    					
    	DrawArrowUp("UpTrend"+CurrentBar, 0, Low[0] - 5, bullColor);

    #2
    Hello BReal,


    Could you please reply with your script attached, so that I may investigate this behavior further?


    You can attach your strategy to your response by going to File > Utilities > Export NinjaScript > Export selected source files > select your script > select the right arrow > Export. The file will be located under (My) Documents\NinjaTrader 7\bin\Custom\ExportNinjaScript.




    You could post the script to your forum reply, or send an email to platformsupport [at] ninjatrader [dot] com with the script as an attachment. In the email please include a link to this forum thread.
    Shawn B.NinjaTrader Customer Service

    Comment


      #3
      Here is the file. Thanks!
      Attached Files

      Comment


        #4
        Hello BReal,


        You could use CurrentBar to ensure there are enough bars on the chart. Here is an example that checks to make sure you have at least 20 or more bars.
        Code:
        protected override void OnBarUpdate() { if(CurrentBar < 20) return;
        Here is the CurrentBar help guide to assist you further.
        Here is a page from our forum on how to Make sure you have enough bars in the data series you are accessing.
        Shawn B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by franki, Yesterday, 08:10 PM
        1 response
        5 views
        0 likes
        Last Post NinjaTrader_EricB  
        Started by ballboy11, Yesterday, 05:22 PM
        0 responses
        3 views
        0 likes
        Last Post ballboy11  
        Started by ballboy11, Yesterday, 04:33 PM
        2 responses
        4 views
        0 likes
        Last Post ballboy11  
        Started by dedouglas, Yesterday, 03:16 PM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by TradeMyth, Yesterday, 02:45 PM
        3 responses
        27 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Working...
        X