trendline trigger

Back to topics list To post a new topic, please log in or register
eddieTrader 2015.05.15 15:48


I am learning about how to capture the value of a trendline and then use it as a trigger for a buy/sell order.

So I made a very very simple EA. I have this small piece of code to place a buy order.

The idea was that I would manually draw a line in a chart, change its name to "my_trendline" and I would move it very close to the price so that when the price goes equal or below this line, a buy order is placed.

Since I am interested in the current BID and the current value on the trendline I am using shift=0 in the ObjectGetValueByShift.

However this is not working.

Am I doing it in the propper way?

int start() {

   if ( (Bid<=ObjectGetValueByShift("my_trendline", 0)) && (OrdersTotal()== 0) )
      place_a_buy = place_Buy(1, 1, 100, 1, 150, 3, 1, 1, 1, "");

WHRoeder 2015.05.15 21:06 #
eddieTrader: However this is not working.
  1. "Doesn't work" is meaningless - just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires - meaningless. There are no mind readers here.
  2. Check your return codes (OrderSend and OrderSelect) What are Function return values ? How do I use them ? - MQL4 forum and Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
  3. Add print statements (including values) before and inside your if's and find out why.

GumRai 2015.05.16 01:03 #

You should at least check the value returned from ObjectGetValueByShift. It may not be so important hre as you are checking for a bid value lower than the returned value

   double my_trendline_value=ObjectGetValueByShift("my_trendline",0);
      Comment("Trend Line Not Found");
   if(Bid<=my_trendline_value && OrdersTotal()==0)


We have no idea what place_Buy does 

Back to topics list  

To add comments, please log in or register