Results 1 to 3 of 3
 1 Attachment(s)    

Thread: (Req) Trendline indicator

  1. #1
    Member
    Join Date
    Nov 2009
    Location
    Germany
    Posts
    69

    Default (Req) Trendline indicator

    Hello everyone!

    I am not a good coder so my hope is to find someone with a better skill than mine in this nice place here:

    You will find a "Demark-Trendline-Indicator" attached.
    I tried to modify this indicator to use it with RSI. The target was to get some nice trendlines on the indicator:
    ...
    I failed.

    So,
    is here anyone who can help me with my problem??? Any other solution to get the trendlines is also welcome. :-)
    Attached Files Attached Files

  2. #2
    Administrator funyoo's Avatar
    Join Date
    Sep 2008
    Posts
    7,003

    Default

    Quote Originally Posted by starger View Post
    Hello everyone!

    I am not a good coder so my hope is to find someone with a better skill than mine in this nice place here:

    You will find a "Demark-Trendline-Indicator" attached.
    I tried to modify this indicator to use it with RSI. The target was to get some nice trendlines on the indicator:
    ...
    I failed.

    So,
    is here anyone who can help me with my problem??? Any other solution to get the trendlines is also welcome. :-)
    Hi starger,

    Trendlines are very subjective, there is different ways to define them.

    Here is a code that you can use :

    Code:
    extern int sensitivity=3;                // difference between first high/low and second high/low to check if a trendline is possible
    extern int barstocheck=23;               // bars to check to get our trendline
    extern int checkshift=1;                 // first bar to check
    Code:
    if(timex!=Time[0]){
                ObjectDelete("LL");
                ObjectDelete("LL2");
                for(i=checkshift;i<=barstocheck-sensitivity;i++){
                   if(ObjectFind("LL2")!=-1)continue;
                   for(int k=sensitivity;k<=barstocheck;k++){
                      if(ObjectFind("LL2")!=-1)continue;
                      if(ObjectFind("LL2")==-1 && i+k<=barstocheck){
    
                         ObjectDelete("LL");
    
                         ObjectCreate("LL",OBJ_TREND,0,0,0,0,0);
                         ObjectSet("LL",OBJPROP_TIME1,Time[i+k]);
                         ObjectSet("LL",OBJPROP_TIME2,Time[i]);
                         ObjectSet("LL",OBJPROP_PRICE1,Low[i+k]);
                         ObjectSet("LL",OBJPROP_PRICE2,Low[i]);
                         ObjectSet("LL",OBJPROP_COLOR,Red);
    
                         ObjectCreate("LL2",OBJ_TREND,0,0,0,0,0);
                         ObjectSet("LL2",OBJPROP_TIME1,Time[i]);
                         ObjectSet("LL2",OBJPROP_TIME2,Time[i+k]);
                         ObjectSet("LL2",OBJPROP_PRICE1,Low[i]);
                         ObjectSet("LL2",OBJPROP_PRICE2,Low[i+k]);
                         ObjectSet("LL2",OBJPROP_COLOR,Red);
                      }
                      for(int j=checkshift;j<=barstocheck;j++){
                         if(ObjectFind("LL2")!=-1 && Low[j]<ObjectGetValueByShift("LL2",j))ObjectDelete("LL2");
                      }
                   }
                }
                
                ObjectDelete("HH");
                ObjectDelete("HH2");
                for(i=checkshift;i<=barstocheck-sensitivity;i++){
                   if(ObjectFind("HH2")!=-1)continue;
                   for(int p=sensitivity;p<=barstocheck;p++){
                      if(ObjectFind("HH2")!=-1)continue;
                      if(ObjectFind("HH2")==-1 && i+p<=barstocheck){
    
                         ObjectDelete("HH");
    
                         ObjectCreate("HH",OBJ_TREND,0,0,0,0,0);
                         ObjectSet("HH",OBJPROP_TIME1,Time[i+p]);
                         ObjectSet("HH",OBJPROP_TIME2,Time[i]);
                         ObjectSet("HH",OBJPROP_PRICE1,High[i+p]);
                         ObjectSet("HH",OBJPROP_PRICE2,High[i]);
                         ObjectSet("HH",OBJPROP_COLOR,Blue);
    
                         ObjectCreate("HH2",OBJ_TREND,0,0,0,0,0);
                         ObjectSet("HH2",OBJPROP_TIME1,Time[i]);
                         ObjectSet("HH2",OBJPROP_TIME2,Time[i+p]);
                         ObjectSet("HH2",OBJPROP_PRICE1,High[i]);
                         ObjectSet("HH2",OBJPROP_PRICE2,High[i+p]);
                         ObjectSet("HH2",OBJPROP_COLOR,Blue);
                      }
                      for(int q=checkshift;q<=barstocheck;q++){
                         if(ObjectFind("HH2")!=-1 && High[q]>ObjectGetValueByShift("HH2",q) && ObjectGetValueByShift("HH2",q)!=0)ObjectDelete("HH2");
                      }
                   }
                }
                timex=Time[0];
          }
    You can replace Low[x] and High[x] with iRSI(NULL,0,rsiperiod,PRICE_CLOSE,x).

    More informations about objectcreate :

    ObjectCreate - MQL4 Documentation

  3. #3
    Member
    Join Date
    Nov 2009
    Location
    Germany
    Posts
    69

    Default

    Thanks for your help . :-)

Similar Threads

  1. TrueTL - True Trendline Indicator
    By Styan in forum Indicators
    Replies: 73
    Last Post: 05-09-2017, 15:13
  2. MT Trendline EA
    By tamaraofx in forum Expert advisors backtesting
    Replies: 5
    Last Post: 09-12-2014, 12:58
  3. Anyone Can Make EA for this Instant Trendline Filter Indicator
    By abedin in forum Ideas for expert advisors
    Replies: 0
    Last Post: 01-21-2010, 01:28
  4. TrendLine Breakout EA
    By funyoo in forum Expert advisors backtesting
    Replies: 11
    Last Post: 10-27-2009, 15:38

Tags for this Thread

color, high, indicator, low, mql, rsi

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •