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

 

Hello! Could you please tell me how you can find out the value stored in the buffer (I mean the value that is on the zig-zag peak), if you only know the bar.

Thanks

 
if the bar is known and the buffer is a timeseries array, the value is Buffer[i]
 
Can't a user function return 2 values?
 
eddy:
Can't a user-defined function return 2 values?

No, you can't - it's not a procedure in Pascal. :-)))
 
eddy:
can't you make a user function return 2 values?


You can make one user function call the other...

For example, reread... from the textbook...

"

The trading strategy imposes requirements on the content and technology of the trading criteria function. Any function can return only one value. Therefore, if the Expert Advisor has a strategy that involves only mutually exclusive trading criteria, the value returned by the function can be set to one of the criteria. But if a strategy allows operation of several criteria at the same time, their values must be passed for processing to other functions using global variables.

The trade strategy implemented in the Expert Advisor under consideration involves only mutually exclusive criteria. That's why the Criterion() function presented here uses the value returned by the function to pass the calculated criteria to other functions.

 
eddy:
can't you make a user function return 2 values?

You can assign a variable globally and retrieve its value in a function.

The function will only return one, but you can get as many as you want.

Example:

  int OpendBuy(){
   int OpendPos=0;
   for(int cnt=OrdersTotal()-1; cnt>=0; cnt--){
     if(OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES)){ 
       if(OrderMagicNumber()==Magic){
         if(OrderSymbol()==Symbol()){
           if(OrderType()==OP_BUY)OpendPos++;
           Ticket =OrderTicket();                    // Номер выбранн. орд.
           Type   =OrderType();                      // Тип выбранного орд.
           Price  =OrderOpenPrice();                 // Цена выбранн. орд.
           SL     =OrderStopLoss();                  // SL выбранного орд.
           TP     =OrderTakeProfit();                // TP выбранного орд.
    } } } }     
 return(OpendPos);} 
 
exactly. values can be passed using global variables
 
Can anyone tell me if anyone has a piece of software that has a high and low zig-zag vertex connection. Thank you
 
pyatka__ASD:
Can anyone tell me if anyone has a piece of software that has a high and low zig-zag vertex connection. Thanks

Look in CodeBase. There's a...
 
eddy:
can't you make a custom function return 2 values?

You can. Return to the parameters. For example:

void TestFunction (double &return_value1, double &return_value2)
{
// вычисления...

   return_value1 = выражение; //возвращаем значения
   return_value2 = выражение;
}
Reason: