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

Strategy: trade with manually drawn trendlines

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

    Strategy: trade with manually drawn trendlines

    Hello,

    I manually draw a trend line on a chart and tag it with "LineUptrend".

    Now I would like to set up a strategy that only takes long trades, as long as the graph is above "LineUptrend". Once the graph crosses "LineUptrend", the strategy should not take trades anymore. There will be more criterias to specify the trade entries, but this is the part I'm struggling with. Is it possible to set this up with strategy builder?

    Further: Would it be possible to adjust this line manually, while the strategy is running?

    Please also see the attached image.

    Thanks a lot in advance for help!

    #2
    Hello mo_fi,

    Yes, you can loop through the DrawObjects collection, and project intercepts along the y-axis.

    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Dear Chelsea, thank you for your reply. This looks quite complex.
      I have another idea: I noticed that I can create an alert for the LineUptrend line. So the alert would be: "if graph crosses below LineUptrend then show a pop-up message." This works.
      Is it possible to use this alert as a condition in the strategy builder? Or is there a way in ninjascript to use the alert as a condition / trigger?

      Comment


        #4
        Hello mo_fi,

        A drawing object would not be selectable in the Strategy Builder. An alert cannot be selected in the Strategy Builder. This would require unlocking the script and coding by hand.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Thank you Chelsea,
          How would I call this specific alert ("Line 50 Alert") in Ninjascript, so I can use it as a condition?

          Comment


            #6
            Hello mo_fi,

            if (/* condition here */)
            {
            Alert("Line 50 Alert");
            }

            Below is a link to the help guide on Alert().
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Hello Chelsea,
              Thank you, but I would like to have it the other way round. The Alert should be the condition, not the resulting action.
              So the logic should look something like this:

              if (Alert("Line 50 Alert"))
              {
              do the following: --> action
              }

              Is this possible?

              Comment


                #8
                Hello mo_fi,

                An alert is an action. This is a message appearing in the Alerts window. This cannot be used in a condition. Just like an order cannot be used in a condition as submitting an order is also an action.

                The condition should be the criteria that triggers the alert. Like the price crossing a plot line or something.
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  Hello Chelsea,
                  thank you for clarification and for your help. I must have misunderstood you at post #4, now it's clear.
                  Would it be possible to only call the "condition" part of the alert in ninjascript?

                  What I mean is:

                  Line Alert 50 has a condition and an action as follows:
                  condition = MES crosses below LineUptrend
                  action = Show Pop up

                  Can I reference this condition (MES cross below LineUptrend) in ninjascript and use it for some other action?

                  Please also see the screenshot.

                  Comment


                    #10
                    Hello mo_fi,

                    No, Alerts in the Alerts window cannot be used in a strategy, as mentioned in post #4.

                    The Strategy Builder cannot use drawn objects, but you can unlock the script and code logic for crossing a manually drawn line.

                    An example of this post posted in post #2.
                    Chelsea B.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by cre8able, Today, 03:20 PM
                    0 responses
                    5 views
                    0 likes
                    Last Post cre8able  
                    Started by Fran888, 02-16-2024, 10:48 AM
                    3 responses
                    47 views
                    0 likes
                    Last Post Sam2515
                    by Sam2515
                     
                    Started by martin70, 03-24-2023, 04:58 AM
                    15 responses
                    114 views
                    0 likes
                    Last Post NinjaTrader_Jesse  
                    Started by The_Sec, Today, 02:29 PM
                    1 response
                    7 views
                    0 likes
                    Last Post NinjaTrader_Jesse  
                    Started by jeronymite, 04-12-2024, 04:26 PM
                    2 responses
                    31 views
                    0 likes
                    Last Post NinjaTrader_BrandonH  
                    Working...
                    X