Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Auto Trend Line

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

    Auto Trend Line

    I am trying to write a simple buy and sell system based on AutoTrendLine indicator. The system will simply buy and sell based on buy and sell arrows produced by the AutoTrendLine indicator. I have no programming skills and have not been successful using the Wizard. The AutoTraendLine code seems to have a Signal=1 for a buy and Signal=2 for a sell. When used in the system code as an IF statement to initiate a long possition on Signal=1 and a short position on Signal=2, it will not work (or compile). I know I must be missing something, but don't know what. Is there such a system already out there? Any help is appreciated.

    #2
    aligator, I'm not sure how you've setup your condition, but as an exmaple this below snippet compiles and works for me here -

    if (Position.MarketPosition == MarketPosition.Flat && AutoTrendLine(false, 1, 3).Signal == 1)
    EnterLong();

    Comment


      #3
      Bertrand,

      Thanks a bunch, you snippet compiled fine.

      It does triger buys and sells, however, they seem to be random (at least to me) and occur in all directions. I am not sure what is wrong. What I really want the code to do is to trigger longs and shorts on break of the trend line when AutoTrendLine indicator generates a buy or sell signal and wait for the next trend line break to make another trade, if flat.

      Attached is the revised file with your suggested changes.

      Thanks.
      Attached Files

      Comment


        #4
        aligator, it would trigger on breaks of the trendline, as usual those methods would produce likely whipsaws before catching the run so you may need additional rules as well to be more consistent.

        I could unfortunately not take a look at your code, as the archive seems corrupted, can you please reattach it?

        Thanks

        Comment


          #5
          Thanks Bertrand for you quick responses. The file opens for me and runs, don't know what is corrupted. Attached are both the .zip and .cs files.

          Thanks again.
          Attached Files

          Comment


            #6
            I'm sorry to butt in, and I have a shameless plug -- my ProTradingTools code will allow you to get signals and trade off of our auto trendline indicator. There's a 30 day free trial if you want to try it. We're still kind of developing the software, so your input would certainly be appreciated and we could possibly modify it for you.

            Bryan

            Comment


              #7
              Originally posted by aligator View Post
              Thanks Bertrand for you quick responses. The file opens for me and runs, don't know what is corrupted. Attached are both the .zip and .cs files.

              Thanks again.
              you're welcome - first of all you would need to ensure to run the same parameters in the indicator and strategy (strength), next you might need to more clrearly define what a trend line break constitutes for you - perhaps enter by Stop / StopLimit order a few ticks above / below the signal bar to filter 'fakes'.

              Comment


                #8
                The AutoTrendLine works well as an indicator.... Anyone know how to code it to stay short while the line is Down (RED) and stay long while the Line is up (Green) this would be much more consistent than trying to catch trend breaks..... going WITH the prevailing trend basically.......

                Comment


                  #9
                  AutoTrend with Historical Lines

                  Alagator, Heres something that might help you.
                  I've modified the AutoTrend indicator (now AutoTrendH) so that it now shows historical trend lines (you can see past trendline crossings and so see why the trades occured when they did). In addition I have written a basic AutoTrendH strategy using this indicator. I have tried to structure the strategy so that you can follow it can be easily modified with additional strategy elements.
                  Download Here
                  Last edited by derekphelps; 12-16-2012, 05:33 PM.

                  Comment


                    #10
                    Originally posted by derekphelps View Post
                    Alagator, Heres something that might help you.
                    I've modified the AutoTrend indicator (now AutoTrendH) so that it now shows historical trend lines (you can see past trendline crossings and so see why the trades occured when they did). In addition I have written a basic AutoTrendH strategy using this indicator. I have tried to structure the strategy so that you can follow it can be easily modified with additional strategy elements.
                    Download
                    Hi Derek,

                    Excellent indicator! I found a bug. When you turn off history trendlines the dots is not turned off.
                    Attached Files

                    Comment


                      #11
                      I Have the same issue. Is this probably already soved somehow in the last 4 years?

                      Comment


                        #12
                        Originally posted by eddi0505 View Post
                        I Have the same issue. Is this probably already soved somehow in the last 4 years?
                        As you noted in your post, the Issue was solved 2 years ago. Perhaps try downloading the current version?
                        Contact me direct if any problems.

                        Comment


                          #13
                          Is there a way to increase the width of the trend lines? sorry i'm not a programmer. thanks in advance.

                          Comment


                            #14
                            Hello JamesBond,

                            Thank you for writing in. Please navigate to Tools -> Edit NinjaScript -> Indicator -> AutoTrendH -> OK
                            In the code editor, change the value on line 45 to increase the width of the lines:
                            Code:
                            private int     lineWidth 		= 1;
                            A value of 2 would give slightly thicker lines and a value of 5 would give significantly thicker lines.

                            Then press F5 on your keyboard to compile and save the changes.

                            Please let me know if I may be of further assistance.
                            Michael M.NinjaTrader Quality Assurance

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                            0 responses
                            558 views
                            0 likes
                            Last Post Geovanny Suaza  
                            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                            0 responses
                            324 views
                            1 like
                            Last Post Geovanny Suaza  
                            Started by Mindset, 02-09-2026, 11:44 AM
                            0 responses
                            101 views
                            0 likes
                            Last Post Mindset
                            by Mindset
                             
                            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                            0 responses
                            545 views
                            1 like
                            Last Post Geovanny Suaza  
                            Started by RFrosty, 01-28-2026, 06:49 PM
                            0 responses
                            547 views
                            1 like
                            Last Post RFrosty
                            by RFrosty
                             
                            Working...
                            X