TrendLine question

Examples step by step how to make your own automated strategy or user indicator
Message
Author
csipi
Posts: 3
Joined: Mon Apr 22, 2013 9:15 am

TrendLine question

#1 Postby csipi » Mon Apr 22, 2013 9:21 am

Hello guys,
I'm new in ForexTester programming.
I created lots of expert advisors in mql4, but now i must to translate one to ForexTester.
Can somebody help me, how can i get the value of a trend line at the current bar?
I can get the trendline properties(name, price1, etc.), but i can't find any function like getValueByShift in mql4.
I tried to shift the trend line times to the past and ask it length with the iBarShift function, but sometimes, it returns -1 (first i get the correct value, then during the next bar -1, then the correct value again. It is randomly).
Could somebody help me?

Thank you

csipi
Posts: 3
Joined: Mon Apr 22, 2013 9:15 am

#2 Postby csipi » Thu Apr 25, 2013 3:41 am

Nobody?

FX Helper
Posts: 1479
Joined: Mon Apr 01, 2013 3:55 am

#3 Postby FX Helper » Sat Apr 27, 2013 10:27 am

Please try this function. It should do what you need.

Code: Select all

function GetTrendLineValue (TrendLineName: string) : double;
var y, x1,x2,x, y1, y2: double;
begin
    if ObjectExists(TrendLineName) then  begin  y1 := ObjectGet(TrendLineName, OBJPROP_PRICE1);
                                              y2 := ObjectGet(TrendLineName, OBJPROP_PRICE2);
                                              x1 := ObjectGet(TrendLineName, OBJPROP_TIME1);
                                              x2 := ObjectGet(TrendLineName, OBJPROP_TIME2);
                                              x:=iTime('GBPCHF', 1, 0);
                                              y:=(x-x1)*(y2-y1)/(x2-x1)+y1;
                                              result:=y;
                                          end
                                         else result:=-1;


end;

csipi
Posts: 3
Joined: Mon Apr 22, 2013 9:15 am

#4 Postby csipi » Sun Apr 28, 2013 4:37 am

Hello,
I tried this before, but it doesn't work well when the trendline goes through one or more weekend period.

Thank you for your answer, other idea? :)

FT Support
Posts: 905
Joined: Sat Jul 11, 2009 10:54 am

#5 Postby FT Support » Mon Apr 29, 2013 4:38 am

Sorry but trendlines in Forex Tester are not designed to work with "one point in future" especially if you draw them through weekend. Please try using the ray with 2 points in known data, this should work.
Check our other product here:
http://www.forexcopier.com


Return to “Programming lessons”

Who is online

Users browsing this forum: No registered users and 9 guests