[Archive!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Couldn't go anywhere without you - 2. - page 229

 
Sh.ProTrader:

Hi all!

Can you please help me with this question?

I'm trying to get the exact value of opening(Open[i]) or closing(Close[i]) of EURUSD currency pair with five-digit value after zero, but in response I always get rounded value!


use the DoubleToStr(value, Digits) function when displaying the value;
 

Hello.

I have a question as a beginner:

how to get data in MQL4 about the current "Profit" by open positions and total; how to get data about the current balance.

 

The Documentation has an account information item. if there is no function for any order information, you have to go through all orders and get the required information for the right ones.

 

Can you tell me how to determine whether a candle closed below or above a certain Fibonacci level?

Close[i] is clear, but how do I know where the level is relative to price?

 
alsu:
use DoubleToStr(value, Digits) when displaying the value;

Thank you very much!

I've already figured it out, searched the whole forum, on this topic, but no one has answered clearly, that in fact everything is simple.

It turns out that the value is rounded to 4 digits only when trying to print it using Alert(), Comment() or Print() without DoubleToStr(value, Digits).

And to calculate the program uses the values without rounding to the 4th sign, if you want to round must use the

NormalizeDouble( value, Dijist).

So you should just read the help more attentively and everything will be fine ;)

 
fury2006:

Can you tell me how to determine if a candle closed below or above a certain Fibonacci Fan level?

Close[i] is clear but how do I know where the level is relative to the price?


The level price must be requested programmatically. For this purpose, you must have previously placed and configured (all programmatically) the "Fibo" object on the chart. This is not as easy as it may seem at first glance. However, Gods do not burn the pot. I once had to play with Fibo levels. And now I am working with processing of these levels. In general, if you want you can figure it out.

Here is an example of code to create a Fibo on a chart.

if(Ind1>Ind2 && Ind2!=0){//индикатор прорисовался вверх, рисуем фибо вверх
      IndUp=true;IndDown=false;
      fff=ObjectFind("FiboLewels");
      if(fff==-1){
        if(!ObjectCreate("FiboLewels",OBJ_FIBO,0,Time[Maximum(Ind1)],Ind1,Time[Minimum(Ind2)],Ind2)){
          GeneralError();
        }
        if(!ObjectSet("FiboLewels",OBJPROP_COLOR,Red)||!ObjectSet("FiboLewels",OBJPROP_LEVELCOLOR,Blue)){
          GeneralError();
        }
        // ------ Устанавливаем количество уровней фибо ----------
                                if(!ObjectSet("FiboLewels",OBJPROP_FIBOLEVELS,22)){
                                        GeneralError();
                                }
                                // ------- Устанавливаем свойства фибоуровней ------------
                                if(!ObjectSet("FiboLewels",OBJPROP_FIRSTLEVEL+0,0)){GeneralError();}
                                if(!ObjectSetFiboDescription("FiboLewels", 0,"0.0     %$")){GeneralError();}
   
                                if(!ObjectSet("FiboLewels",OBJPROP_FIRSTLEVEL+1,0.118)){GeneralError();}
                                if(!ObjectSetFiboDescription("FiboLewels", 1,"11.8     %$")){GeneralError();}

                                if(!ObjectSet("FiboLewels",OBJPROP_FIRSTLEVEL+2,0.236)){GeneralError();}
                                if(!ObjectSetFiboDescription("FiboLewels", 2,"23.6     %$")){GeneralError();}

                                if(!ObjectSet("FiboLewels",OBJPROP_FIRSTLEVEL+3,0.382)){GeneralError();}
                                if(!ObjectSetFiboDescription("FiboLewels", 3,"38.2     %$")){GeneralError();}

                                if(!ObjectSet("FiboLewels",OBJPROP_FIRSTLEVEL+4,0.5)){GeneralError();}
                                if(!ObjectSetFiboDescription("FiboLewels", 4,"50.0     %$")){GeneralError();}

                                if(!ObjectSet("FiboLewels",OBJPROP_FIRSTLEVEL+5,0.618)){GeneralError();}
                                if(!ObjectSetFiboDescription("FiboLewels", 5,"61.8     %$")){GeneralError();}

                                if(!ObjectSet("FiboLewels",OBJPROP_FIRSTLEVEL+6,0.764)){GeneralError();}
                                if(!ObjectSetFiboDescription("FiboLewels", 6,"76.4     %$")){GeneralError();}

                                if(!ObjectSet("FiboLewels",OBJPROP_FIRSTLEVEL+7,0.882)){GeneralError();}
                                if(!ObjectSetFiboDescription("FiboLewels", 7,"88.2     %$")){GeneralError();}

                                if(!ObjectSet("FiboLewels",OBJPROP_FIRSTLEVEL+8,1)){GeneralError();}
                                if(!ObjectSetFiboDescription("FiboLewels", 8,"100.0     %$")){GeneralError();}

                                if(!ObjectSet("FiboLewels",OBJPROP_FIRSTLEVEL+9,1.118)){GeneralError();}
                                if(!ObjectSetFiboDescription("FiboLewels", 9,"111.8     %$")){GeneralError();}

                                if(!ObjectSet("FiboLewels",OBJPROP_FIRSTLEVEL+10,1.236)){GeneralError();}
                                if(!ObjectSetFiboDescription("FiboLewels", 10,"123.6     %$")){GeneralError();}

                                if(!ObjectSet("FiboLewels",OBJPROP_FIRSTLEVEL+11,1.382)){GeneralError();}
                                if(!ObjectSetFiboDescription("FiboLewels", 11,"138.2     %$")){GeneralError();}

                                if(!ObjectSet("FiboLewels",OBJPROP_FIRSTLEVEL+12,1.618)){GeneralError();}
                                if(!ObjectSetFiboDescription("FiboLewels", 12,"161.8     %$")){GeneralError();}

                                if(!ObjectSet("FiboLewels",OBJPROP_FIRSTLEVEL+13,2)){GeneralError();}
                                if(!ObjectSetFiboDescription("FiboLewels", 13,"200.0     %$")){GeneralError();}

                                if(!ObjectSet("FiboLewels",OBJPROP_FIRSTLEVEL+14,2.382)){GeneralError();}
                                if(!ObjectSetFiboDescription("FiboLewels", 14,"238.2     %$")){GeneralError();}

                                if(!ObjectSet("FiboLewels",OBJPROP_FIRSTLEVEL+15,2.618)){GeneralError();}
                                if(!ObjectSetFiboDescription("FiboLewels", 15,"261.8     %$")){GeneralError();}

                                if(!ObjectSet("FiboLewels",OBJPROP_FIRSTLEVEL+16,3)){GeneralError();}
                                if(!ObjectSetFiboDescription("FiboLewels", 16,"300.0     %$")){GeneralError();}

                                if(!ObjectSet("FiboLewels",OBJPROP_FIRSTLEVEL+17,3.382)){GeneralError();}
                                if(!ObjectSetFiboDescription("FiboLewels", 17,"338.2     %$")){GeneralError();}

                                if(!ObjectSet("FiboLewels",OBJPROP_FIRSTLEVEL+18,3.618)){GeneralError();}
                                if(!ObjectSetFiboDescription("FiboLewels", 18,"361.8     %$")){GeneralError();}

                                if(!ObjectSet("FiboLewels",OBJPROP_FIRSTLEVEL+19,4)){GeneralError();}
                                if(!ObjectSetFiboDescription("FiboLewels", 19,"400.0     %$")){GeneralError();}

                                if(!ObjectSet("FiboLewels",OBJPROP_FIRSTLEVEL+20,4.236)){GeneralError();}
                                if(!ObjectSetFiboDescription("FiboLewels", 20,"423.6     %$")){GeneralError();}

                                if(!ObjectSet("FiboLewels",OBJPROP_FIRSTLEVEL+21,4.618)){GeneralError();}
                                if(!ObjectSetFiboDescription("FiboLewels", 21,"461.8     %$")){GeneralError();}
      } 
    }

I had to make a subroutine to request the price of the level. Here it is (you can figure it out if you want)

// ------------- PriceSignLevelUp() -----------------------------------------------
// функция возвращает цену сигнального уровня при прорисовке индикатора вверх
//---------------------------------------------------------------------------------
double PriceSignLevelUp(double Level,double Ind1,double Ind2){
  double Fibo0=0,Fibo100=0,Rst=0;
  Fibo0=Ind2;
  Fibo100=Ind1;
  Rst=Ind1-Ind2;
  switch(Level){
    case 0:          Level=NormalizeDouble(Fibo0,digits); break;
    case 11.8:       Level=NormalizeDouble(Fibo0+Rst*0.118,digits); break;
    case 23.6:       Level=NormalizeDouble(Fibo0+Rst*0.236,digits); break;
    case 38.2:       Level=NormalizeDouble(Fibo0+Rst*0.382,digits); break;
    case 50:         Level=NormalizeDouble(Fibo0+Rst*0.5,digits); break;
    case 61.8:       Level=NormalizeDouble(Fibo0+Rst*0.618,digits); break;
    case 76.4:       Level=NormalizeDouble(Fibo0+Rst*0.764,digits); break;
    case 88.2:       Level=NormalizeDouble(Fibo0+Rst*0.882,digits); break;
    case 100:        Level=NormalizeDouble(Fibo100,digits); break;
    case 111.8:      Level=NormalizeDouble(Fibo0+Rst*1.118,digits); break;
    case 123.6:      Level=NormalizeDouble(Fibo0+Rst*1.236,digits); break;
    case 138.2:      Level=NormalizeDouble(Fibo0+Rst*1.382,digits); break;
    case 161.8:      Level=NormalizeDouble(Fibo0+Rst*1.618,digits); break;
    case 200:        Level=NormalizeDouble(Fibo0+Rst*2,digits); break;
    case 238.2:      Level=NormalizeDouble(Fibo0+Rst*2.382,digits); break;
    case 261.8:      Level=NormalizeDouble(Fibo0+Rst*2.618,digits); break;
    case 300:        Level=NormalizeDouble(Fibo0+Rst*3,digits); break;
    case 338.2:      Level=NormalizeDouble(Fibo0+Rst*3.382,digits); break;
    case 361.8:      Level=NormalizeDouble(Fibo0+Rst*3.618,digits); break;
    case 400:        Level=NormalizeDouble(Fibo0+Rst*4,digits); break;
    case 423.6:      Level=NormalizeDouble(Fibo0+Rst*4.236,digits); break;
    case 461.8:      Level=NormalizeDouble(Fibo0+Rst*4.618,digits); break;
  }         
  return(Level);
}
 

Good evening! I myself last night reviewed the book, new dimensions of trading, Williams, yesterday to 30, today to 50 pages.

I've got a robot, but it does not work at all, no trades in the tester, and Alert("buy",GetLastError()) says nothing.

I would love to take any sound advice, please.

//+------------------------------------------------------------------+
//| Aligator.mq4 |
//| Copyright © 2011, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2011, MetaQuotes Software Corp.
#property link "http://www.metaquotes.net"
extern int jaw_period=13,teeth_period=8,jaw_shift=8,tteeth_period=5,teeth_shift=5,lips_period=3,lips_shift=3;
extern double volume=0.1,stoploss=20,takeprofit=50;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialisation function |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int tiket;
int start()
{double blu,red,grin;
//----
blu= iAlligator( 0, 0, jaw_period, jaw_shift, tteeth_period, teeth_shift, lips_period, lips_shift, MODE_SMA,PRICE_CLOSE,MODE_GATORJAW, 0) ;
red= iAlligator( 0, 0, jaw_period, jaw_shift, tteeth_period, teeth_shift, lips_period, lips_shift, MODE_SMA,PRICE_CLOSE,MODE_GATOREETH, 0) ;
grin= iAlligator( 0, 0, jaw_period, jaw_shift, tteeth_period, teeth_shift, lips_period, lips_shift, MODE_SMA,PRICE_CLOSE,MODE_GATORLIPS, 0) ;
//----


double Fractalu,Fractall;Fractalu=iFractals( 0, 0, MODE_UPPER, 0) ;Fractall=iFractals( 0, 0,MODE_LOWER, 0);


if (Fractalu>0&&Fractalu>blu&&Fractalu>red&&Fractalu>grin)
{ tiket= OrderSend( 0, OP_BUY, volume, Bid, Point*3, Bid- stoploss*Point, Bid+ takeprofit*Point, "Pose66", 1234567890, 0, Red);Alert("buy",GetLastError());}

if (Fractall>0&&Fractalu<blu&&Fractalu<red&&Fractalu<grin)


{ tiket= OrderSend( 0, OP_SELL, volume, Ask, Point*3, Ask+ stoploss*Point, Ask- takeprofit*Point, "Pose66", 1234567890, 0, Blue);Alert("sell",GetLastError());}




return(0);
}
//+------------------------------------------------------------------+

 
Dimka-novitsek:

Good evening! I myself last night reviewed the book, new dimensions of trading, Williams, yesterday to 30, today to 50 pages.

I've got a robot, but it does not work at all, no trades in the tester, and Alert("buy",GetLastError()) says nothing.

I would love to get any sound advice, please.

//+------------------------------------------------------------------+
//| Aligatorny.mq4 |
//| Copyright © 2011, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2011, MetaQuotes Software Corp.
#property link "http://www.metaquotes.net"
extern int jaw_period=13,teeth_period=8,jaw_shift=8,tteeth_period=5,teeth_shift=5,lips_period=3,lips_shift=3;
extern double volume=0.1,stoploss=20,takeprofit=50;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialisation function |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int tiket;
int start()
{double blu,red,grin;
//----
blu= iAlligator( 0, 0, jaw_period, jaw_shift, tteeth_period, teeth_shift, lips_period, lips_shift, MODE_SMA,PRICE_CLOSE,MODE_GATORJAW, 0) ;
red= iAlligator( 0, 0, jaw_period, jaw_shift, tteeth_period, teeth_shift, lips_period, lips_shift, MODE_SMA,PRICE_CLOSE,MODE_GATOREETH, 0) ;
grin= iAlligator( 0, 0, jaw_period, jaw_shift, tteeth_period, teeth_shift, lips_period, lips_shift, MODE_SMA,PRICE_CLOSE,MODE_GATORLIPS, 0) ;
//----


double Fractalu,Fractall;Fractalu=iFractals( 0, 0, MODE_UPPER, 0) ;Fractall=iFractals( 0, 0,MODE_LOWER, 0);


if (Fractalu>0&&Fractalu>blu&&Fractalu>red&&Fractalu>grin)
{ tiket= OrderSend( 0, OP_BUY, volume, Bid, Point*3, Bid- stoploss*Point, Bid+ takeprofit*Point, "Pose66", 1234567890, 0, Red);Alert("buy",GetLastError());}

if (Fractall>0&&Fractalu<blu&&Fractalu<red&&Fractalu<grin)


{ tiket= OrderSend( 0, OP_SELL, volume, Ask, Point*3, Ask+ stoploss*Point, Ask- takeprofit*Point, "Pose66", 1234567890, 0, Blue);Alert("sell",GetLastError());}




return(0);
}
//+------------------------------------------------------------------+


"Everything has already been stolen before you", as well as "Your horses are quietly galloping"... :-)))

See here.

 

Thank you!!!

But I also wanted to learn how to code, so I wanted to understand what's wrong.

 

What could be causing the error (wrong price)?