When i put it in this position to terminate the function and return the double value, i got this down error

double CalculateHH ()// This function is to get the highest high price since open price of certain order { for ( int n=OrdersTotal()-1; n>=0; n-- )// first i need to loop all orders { if (OrderSelect( n ,SELECT_BY_POS,MODE_TRADES)) // select my order of interest { if(OrderType()== OP_SELL && OrderSymbol()==Symbol() && OrderMagicNumber()==mBMagicf && n<=1 ) { datetime OOTs = OrderOpenTime(); // Assumes OrderSelect() done already int iOOTs = iBarShift(NULL,0, OOTs); // Bar of the open. #define iBarCURRENTs 0 // Include current bar. int nSinceS = iOOTs - iBarCURRENTs + 1; // No. bars since open. int iHi = iHighest(NULL,0, MODE_HIGH, nSinceS, iBarCURRENTs); double (HH) = High [iHi]; // Highest high. } } } return (HH);// Now i need to return this value but i am not sure where i should put the " return" operator??? }
Ok, i have just read and understood the idea that a UDF has to return a value and for IF statements, we need to make sure that we return a value even with false IFs. I got that.
However, when i added another function for getting the lowest low. I got this warning

double CalculateLL ()// This function is to get the highest high price since open price of certain order { for ( int n=OrdersTotal()-1; n>=0; n-- )// first i need to loop all orders { if (OrderSelect( n ,SELECT_BY_POS,MODE_TRADES)) // select my order of interest { if(OrderType()== OP_BUY && OrderSymbol()==Symbol() && OrderMagicNumber()==mBMagicf && n<=1 ) { Comment ("Order selected"); datetime OOTs = OrderOpenTime(); // Assumes OrderSelect() done already int iOOTs = iBarShift(NULL,0, OOTs); // Bar of the open. #define iBarCURRENTs 0 // Include current bar. int nSinceS = iOOTs - iBarCURRENTs + 1; // No. bars since open. int iLi = iLowest(NULL,0, MODE_LOW, nSinceS, iBarCURRENTs); double LL = High [iLi]; // Lowest low. } } } return (LL); }

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register