• 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

Strategy : Buy/Sell signal on Chart

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

    Strategy : Buy/Sell signal on Chart

    Hi,

    I am trying to understand NinjaScript and its working.
    I have written a very basic logic which should show arrow on chart whenever the condition matches.

    Code:
            protected override void OnBarUpdate()
            {
                if(High[2] > High[0] && High[1] > High[0]){
                    Draw.ArrowUp(this, "tag1", true, 0, Low[0] - TickSize, Brushes.White);
                }
            }
    I am following below steps.
    1) Compile NinjaScript
    2) Open Chart for a stock
    3) Open Strategy and add the Strategy which I just added and compiled.

    At this point I am expecting that the Arrow Up symbol should appear on all the historic bars where the condition is matching.
    But that's not happening.

    Am I missing something here ?
    Or is it that the Arrow Up would appear for all future bars once the strategy is applied and will not appear for past bars ?

    Please share your inputs..

    Thanks in advance!!

    #2
    Hello leo11,

    If a tag name is re-used the object is re-drawn in the new location at the new price. If the tag name is unique a new object is drawn using the provided price and time.

    Have you used a unique tag name or re-used a tag name?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_ChelseaB View Post
      Hello leo11,

      If a tag name is re-used the object is re-drawn in the new location at the new price. If the tag name is unique a new object is drawn using the provided price and time.

      Have you used a unique tag name or re-used a tag name?
      HI NinjaTrader_ChelseaB,

      Thanks for your response.
      I am not aware of concept of tags yet and simply used the Arrow Up logic that I found on some help forum.

      I have modified the tag name and it should now definitely be unique.
      Draw.ArrowUp(this, "tag1_657657", true, 0, Low[0] - TickSize, Brushes.White);

      Tried it and don't see any Arrow up on Price chart.
      You said new object will be drawn. Will it be drawn over candlestick/price chart ?

      I am not getting a clue here. Is there any good document or video I can refer to, which shows how to display strategy buy and sell signals over a price chart.

      Regards,

      Comment


        #4
        SampleMACrossOver

        Just had a look at SampleMACrossOver strategy which is supplied OOTB with NinjaTrader.
        Looking at below logic(AddChartIndicator) it looks like that smaFast and smaSlow lines would appear over the chart when this Strategy is added to a chart.

        Code:
                    else if (State == State.DataLoaded)
                    {
                        smaFast = SMA(Fast);
                        smaSlow = SMA(Slow);
        
                        smaFast.Plots[0].Brush = Brushes.Goldenrod;
                        smaSlow.Plots[0].Brush = Brushes.SeaGreen;
        
                        AddChartIndicator(smaFast);
                        AddChartIndicator(smaSlow);
                    }
        But again this is not happening. And I only see price bars on the chart and MA indicators are not added.
        Will really appreciate any help on this.

        Regards,
        Last edited by leo11; 08-12-2018, 03:37 AM.

        Comment


          #5
          Hello leo11,

          Thank you for the reply.

          In regard to the drawing object, can you right click on the chart and select Drawing Tools -> Drawing Objects to see if the object is listed? This will help determine if the arrow was drawn at all, or if it is missing.

          The tag you have used, while that is a unique tag is not what Chelsea had mentioned in regard to being unique. That would need to use a variable such as CurrentBar:

          Code:
          Draw.ArrowUp(this, "tag1" + CurrentBar, true, 0, Low[0] - TickSize, Brushes.White);
          This would mean on each new bar, a new tag is used and it is no longer a static value. This is how to have historical drawings in addition to the most recent bar. The code you have now is likely only drawing on the most recent bar to the very right of the chart.

          Regarding the SampleMACrossOver, are you applying the strategy directly to the chart and also enabling it with the Enabled checkbox? The SampleMACrossOver should show MA plots when applied directly to a chart. If you are applying items to the control center strategies tab, that would make them run in the background instead of on the chart directly.

          We do have a video that covers basic strategy development which you can find here: https://youtu.be/HCyt90GAs9k

          This does not contain drawings specifically but would be helpful to ensure you are following the necessary steps to enable a script and have it run.

          I look forward to being of further assistance.
          JesseNinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Fness2020, Yesterday, 08:29 PM
          1 response
          27 views
          0 likes
          Last Post NinjaTrader_PaulH  
          Started by Hurrikane, Yesterday, 09:18 PM
          1 response
          14 views
          0 likes
          Last Post NinjaTrader_PaulH  
          Started by stewarco, Today, 05:46 AM
          1 response
          6 views
          0 likes
          Last Post NinjaTrader_Jermaine  
          Started by andrewtrades, Yesterday, 08:24 PM
          2 responses
          15 views
          0 likes
          Last Post NinjaTrader_ChristopherD  
          Started by authenticx, Yesterday, 10:07 PM
          1 response
          35 views
          0 likes
          Last Post NinjaTrader_PatrickG  
          Working...
          X