[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 305

 
ksyusha-Z:
The calm before the storm. Let's get ready for another week. Fat profits and skinny (like my chow-chow) elks to you, dear programmers and other profit wrestlers in the coming week.

Thank you! Same to you!

PS Just in case, don't overfeed the doggy this week :)

 

Hi all, could you please tell me if NULL means any value? Well if I don't want to send a specific value to a function but I want it to be any value. Do I write NULL then in function call?

 
Pyro:

Hi all, could you please tell me if NULL means any value? Well if I don't want to send a specific value to a function but I want it to be any value. Do I write NULL then in function call?

NULL or 0 (zero) means it is a pair/instrument on which chart the EA/indicator is set.
 
Is it possible to make it possible not to prescribe the value of variables sent to the function when calling the function? That is, if I don't need, say, to compare OrderOpenPrice, not to rewrite the function again, how can I make the value of OpderOpenPrice always be true when comparing inside the called function? I hope I formulated what I need clearly.
 
Pyro:
Is it possible to make it possible not to prescribe the value of variables sent to the function when calling the function? That is, if I don't need, say, to compare OrderOpenPrice, not to rewrite the function again, how can I make the value of OpderOpenPrice always be true when comparing inside the called function? I hope I formulated what I need clearly.


- Is there a black top and a white bottom?
- Yes!
- Is there a white top and a black bottom?
- Yes!

Which one do you really need? I hope I formulated it clearly?

 
Pyro:
Is it possible to make it possible not to write the value of the variables sent to the function when calling the function...?
This is provided in standard functions for some parameters, it can also be prescribed in user parameters. If there is no such parameter in the call, the default parameter is accepted.
int OrderSend( string symbol, int cmd, double volume, double price, int slippage, double stoploss, double takeprofit, string comment=NULL, int magic=0, 
datetime expiration=0, color arrow_color=CLR_NONE) 
 
Pyro:
Is there any way to avoid writing the value of variables sent to the function when calling the function? That is, if I don't need, say, comparison of OrderOpenPrice without rewriting the function, how can I make the value of OpderOpenPrice always be true when making comparison inside the called function? I hope I've made it clear what I need.

You decide which variables you want for the function.

The function will work even if you do not send any variable values to it.

For example:

Function for calculating the current profit for an EA set on a chart:

 double CurrProfit(){
   double Prof=0; 
   for(int cnt=OrdersTotal()-1; cnt>=0; cnt--){
     OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);      
     if(OrderSymbol()==Symbol()){
       if(OrderMagicNumber()==Magic){
         if(OrderType()==OP_BUY || OrderType()==OP_SELL) 
             Prof+=OrderProfit()+OrderSwap()+OrderCommission();
    } } }       
 return(Prof);} 
Same, but with division of current profit by buy and sell profit and for the specified instrument:
 double CurrProfit(int OP, string Symbl){
   double Prof=0; 
   for(int cnt=OrdersTotal()-1; cnt>=0; cnt--){
     OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);      
     if(OrderSymbol()==Symbl){
       if(OrderMagicNumber()==Magic){
         if(OP==OP_BUY)Prof+=OrderProfit();
         if(OP==OP_SELL)Prof+=OrderProfit();
    } } }       
 return(Prof);} 

The same, but with division of the current profit into profit from buy and sell and for an EA with a specified magic number:

double CurrProfit(int OP, int MagicNumber){
   double Prof=0; 
   for(int cnt=OrdersTotal()-1; cnt>=0; cnt--){
     OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);      
     if(OrderSymbol()==Symbol()){
       if(OrderMagicNumber()==MagicNumber){
         if(OP==OP_BUY)Prof+=OrderProfit();
         if(OP==OP_SELL)Prof+=OrderProfit();
    } } }       
 return(Prof);} 
 
Hi there! I'm a newbie! Very much needs your advice!!! I was training on the demo, all was normal. I threw it in the real. And messed up so that now I sit and wonder how to fix it. In general, are sets at 1.4057, and bonds 1.4244.Sels and bonds equal in number, 5 pieces.Advice how to get out of this situation.
 
monstrochka:
I need your advice very much!!! I was training on the demo, all was normal. I threw it in the real, and messed up so that now I sit and wonder how to fix it. In general, the seals are at 1.4057, and buy 1.4244. seals and buy equal amounts, 5 pieces. advise how to get out of this situation. because I tried myself, so worse done ((((

Setting locks, i.e. opening equal counter positions, is tantamount to closing a position.

Lock is self-defeating, guided by a passionate desire "not to spoil" the balance sheet picture.

 
DhP:

Setting locks, i.e. opening equal counter positions, is tantamount to closing a position.

Lock is self-defeating, guided by a passionate desire not to "mess up" the balance sheet picture.

I understand that, but I do not know how to get out of this situation.
Reason: