Download MetaTrader 5
To add comments, please log in or register
Join MQL5 Cloud Network. Millions of traders are waiting for this!
sky_lc
51
sky_lc 2015.11.08 03:24 

Hello,

i´ve been trying to make my ea read the price of an horizontal line to work as a trigger. I can type the price manually and it´ll work the way I want, but if i could "type" it graphically would be great.

I´m not an expert coder... :)


I used ObjectGet. Note that I also place a horizontal line on the chart and call it "line".


 double Trigger =  ObjectGet(line, 1) ;

 when I type

Print (ObjectGet(line, 1)) ;

it plots "0.0" so i know it´s not reading anything

Im I oversimplifying this, or using the wrong expression? Can anyone shed some light?


thanks in advance

Keith Watford
Moderator
7979
Keith Watford 2015.11.08 03:43  
   ObjectGet("line",OBJPROP_PRICE1)
..
sky_lc
51
sky_lc 2015.11.08 10:44  
GumRai:
..

Ok, I'm embarassed... :) need more coffee.
GumRai, thanks so much! Almost got it right, if it wasn't everything wrong inside the (...)

Cheers
sky_lc
51
sky_lc 2015.11.08 13:04  

NICE! It lives! sort of... Now it plots something like 1.135846854955456!


But the the trigger doesn´t work, maybe i´m not following.

 is this

 double Trigger = ObjectGet("linha", OBJPROP_PRICE1) ;


the same as this?

 double Trigger = 1.13584 ;


 on the second case it works like a charm. On the first, it doesn´t. Do i need to cut number of digits? or the value I get with ObjectGet isn´t ready to be used yet?


Thank you...

honest_knave
969
honest_knave 2015.11.08 13:10  

How have you written the code for opening the trade on that trigger?

sky_lc
51
sky_lc 2015.11.08 18:01  
honest_knave:

How have you written the code for opening the trade on that trigger?


Hi Honest_Knave,


this is the part that refers to stop orders, I have other order types on the code but don´t really use them:

  //StartTime Orders
            if(StopOrder)
            {
               if(!CountBuyStop && !Count)
               {               

                     //BUY
                     BEven = False;
                     
                     double TriggerOrder = NormalizeDouble(Trigger+PriceOrder*Point+Spread,Digits);
                     double minstoplevel=MarketInfo(Symbol(),MODE_STOPLEVEL);
                     //Print("Minimum Stop Level=",minstoplevel," points");
                     
                     sl=NormalizeDouble(Trigger - Spread - StopLoss*Point + PriceOrder*Point,Digits);
                     if ( sl < minstoplevel*Point) sl = (Trigger - Spread - minstoplevel*Point);
                     
                     if(Ask < TriggerOrder)
                     {                   
                        ORDO = OrderSend(Symbol(),OP_BUYSTOP,Lots,TriggerOrder,3,sl,0,"BotOrderBuyStop",MagicStop,0,Lime);
                        Comment("BUYSTOP order opened","\n");
   
                        if(!ORDO) Alert("The BUYSTOP order isn't opened because error nº", GetLastError());
                        else Print("The BUYSTOP order was opened successfully.");
                     }
               }


PriceOrder refers to the distance in pips to the Trigger where the stop order is supposed to be.

So, as mentioned, when I define manually the Trigger value (Price) it works as expected. Maybe replacing that value by the value returned by the expression ObjectGet isn´t the way to go...

sky_lc
51
sky_lc 2015.11.08 18:11  

Can the problem be the number of times it reads price? I mean, when i type the price manualy it it is fixed and defined only once. When I ask it to read the value of the horizontal line it constantly reads the value... like a few times every second... it plots ALOT of these lines... is it bad?


2015.11.08 12:56:41.789    2015.10.08 10:33  LC_line up dn 03 EURUSD,H4: 1.117820675105485
2015.11.08 12:56:41.789    2015.10.08 10:33  LC_line up dn 03 EURUSD,H4: 1.117820675105485
2015.11.08 12:56:41.789    2015.10.08 10:33  LC_line up dn 03 EURUSD,H4: 1.117820675105485
2015.11.08 12:56:41.789    2015.10.08 10:33  LC_line up dn 03 EURUSD,H4: 1.117820675105485
2015.11.08 12:56:41.789    2015.10.08 10:33  LC_line up dn 03 EURUSD,H4: 1.117820675105485
2015.11.08 12:56:41.789    2015.10.08 10:33  LC_line up dn 03 EURUSD,H4: 1.117820675105485
2015.11.08 12:56:41.789    2015.10.08 10:33  LC_line up dn 03 EURUSD,H4: 1.117820675105485
2015.11.08 12:56:41.789    2015.10.08 10:33  LC_line up dn 03 EURUSD,H4: 1.117820675105485
2015.11.08 12:56:41.789    2015.10.08 10:33  LC_line up dn 03 EURUSD,H4: 1.117820675105485

whroeder1
13630
whroeder1 2015.11.09 12:37  
  1. How are you getting the name of the line?
  2. Check/Print _LastError after the ObjectGet
/
To add comments, please log in or register