Questions from Beginners MQL4 MT4 MetaTrader 4 - page 138

 
Hello, can you tell me if it's possible to connect a copying signal and a robot to an mt4 account and connect all this to the vps?
 
2002569:Hello, can you tell me if it's possible to connect a copying signal and a robot in mt4 and connect the whole thing to vps?

Yes of course you can!!!

 

Hi guys. Can you advise someone who is perfectly familiar with programming?

I create a horizontal line under certain conditions. I define a price with OLB in order to use OpenlineB in another code as the price of the horizontal line. In another code where it is needed it is displayed as an integer. For example the price is 110,256 and it shows 110. I found this out with Comment. Why is the exact price not displayed, what is the problem?

int OpenlineB() {
    double ma60=...;
    double ma=...;
    if((fMarketOrders(OP_BUY)==0)) { 
         ObjectCreate(0,"BUY",OBJ_HLINE,0,0,ma60+ma); }   
 int OLB=ObjectGet("BUY", OBJPROP_PRICE1);      
 return(OLB);}

int TRlineB(){
Comment(OpenlineB());
return(true);}
 
Rustam Bikbulatov:

Hi guys. Can you advise someone who is perfectly familiar with programming?

I create a horizontal line under certain conditions. I define a price with OLB in order to use OpenlineB in another code as the price of the horizontal line. In another code where it is needed it is displayed as an integer. For example the price is 110,256 and it shows 110. I found this out with Comment. Why is the exact price not displayed, what is the problem?

int double OpenlineB()

Your function returns an integer number. What you get is what is printed.
And of course, further on in the function you convert it to double format.

 
Konstantin Nikitin:

Your function returns an integer. What you get is what is printed.
And of course, further in the function you convert it to double format.

double OpenlineB() {
    double ma60=...;
    double ma=...;
    if((fMarketOrders(OP_BUY)==0)) { 
         ObjectCreate(0,"BUY",OBJ_HLINE,0,0,ma60+ma); }   
 int OLB=ObjectGet("BUY", OBJPROP_PRICE1);      
 return(OLB);}

Already tried it. It returns an integer.

 
Konstantin Nikitin:

Your function returns an integer. What you got is what you printed.
And of course, further in the function you convert it to double format.

int OpenlineB() {
    double ma60=iMA(NULL,1,5,0,1,0,1);
    double ma=(iMA(NULL,60,6205,0,1,2,1)-iMA(NULL,60,6205,0,1,3,1));
    if((fMarketOrders(OP_BUY)==0)) { 
         ObjectCreate(0,"BUY",OBJ_HLINE,0,0,ma60+ma); }   
 double OLB=ObjectGet("BUY", OBJPROP_PRICE1);      
 return(OLB);}

I got it!!! Thank you dear Konstantin!!!!!!!!!!!!!!!!!!

 
Rustam Bikbulatov:

Already tried it. It comes out as an integer.

Try using ObjectGetDouble
And change the function declaration to

double OpenlineB() {
 
Konstantin Nikitin:

Try using ObjectGetDouble

All done!

double OpenLineB() {
    double ma60=iMA(NULL,1,5,0,1,0,1);
    double ma=(iMA(NULL,60,6205,0,1,2,1)-iMA(NULL,60,6205,0,1,3,1));
    if((fMarketOrders(OP_BUY)==0)) { 
         ObjectCreate(0,"BUY",OBJ_HLINE,0,0,ma60+ma); }   
 double OLB=ObjectGet("BUY", OBJPROP_PRICE1);      
 return(OLB);}

Thank you!!!

 
Rustam Bikbulatov:

All done!

Thank you!!!

Can I truncate it a bit?

double OpenLineB() {
  double ma60=iMA(NULL,1,5,0,1,0,1);
  double ma=(iMA(NULL,60,6205,0,1,2,1)-iMA(NULL,60,6205,0,1,3,1));
  if(fMarketOrders(OP_BUY)==0) 
   ObjectCreate(0,"BUY",OBJ_HLINE,0,0,ma60+ma);
 return(ObjectGetDouble(0,"BUY",OBJPROP_PRICE));
}
 
Vitaly Muzichenko:

You could truncate it a bit.

double OpenLineB() {
  if(fMarketOrders(OP_BUY)==0) {
    double ma60=iMA(NULL,1,5,0,1,0,1);
    double ma=(iMA(NULL,60,6205,0,1,2,1)-iMA(NULL,60,6205,0,1,3,1));
    ObjectCreate(0,"BUY",OBJ_HLINE,0,0,ma60+ma);
    return ma60+ma;
  }
 return(ObjectGetDouble(0,"BUY",OBJPROP_PRICE));
}

otherwise indicator data is called from cache at every access
And it would be better to keep the level of "BUY" line in your variables and not look for it on the chart.

Reason: