[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 28

 
Where is the "wrong parameters count" error here?
MA1 = iMA(NULL, 0, MA_Period1, MODE_SMA, PRICE_CLOSE,0);
 
Сvovan-gogan:
Where is the "wrong parameters count" error here?


Good afternoon! Thank you, sir, for asking the question. Glad to be of service.

We bow at the waist and respond intelligently:

You are obviously missing a parameter in iMA:

double iMA( string symbol, int timeframe, int period, int ma_shift, int ma_method, int applied_price, int shift)
Calculation of Moving Average.
Parameters:
symbol - Symbol name of symbol, on data of which the indicator will be calculated. NULL means current symbol.
timeframe - Period. Can be one of the periods of the chart. 0 means the period of the current chart.
period - Period of averaging for moving average calculation.
ma_shift - Indicator shift relative to the price chart.
ma_method - Averaging method. Can be any of values of Moving Average methods.
applied_price - Price used. Can be any of price constants.
shift - Index of the value obtained from the indicator buffer (shift relative to the current bar by the specified number of periods back).
--------------------------

Most likely, the parameter is missing:

ma_shift - Shift of indicator relative to the price chart.

Looking forward to your further questions!

 
Thank you very much)
 

I need your help.

This expression needs to be translated

OrderOpenPrice()-OrderClosePrice()
into number of points and calculate profit or stop for each position depending on lot. And finally print the total amount in % of profit or stop
 
Vodya:

I need your help.

I need to translate this expression

to the number of items ......


First select the desired item.

( OrderOpenPrice() - OrderClosePrice() ) /Point - this will be the profit/loss of the selected position in pips

---------------

Actually, for your calculations, it's better to use appropriate functions of I. Kim. And the task will become several times easier.

https://www.mql5.com/ru/forum/131859

https://www.mql5.com/ru/forum/131859/page3#434225

 
leonid553:


First select the correct position.

( OrderOpenPrice() - OrderClosePrice() ) * Point - this will be profit/loss of the selected position in points

---------------

Actually, for your calculations, it's better to use appropriate functions of I. Kim. And the task will become several times easier.

https://www.mql5.com/ru/forum/131859

https://www.mql5.com/ru/forum/131859/page3#434225


Thank you. But I didn't find what I need in his function. And in this case ( OrderOpenPrice() - OrderClosePrice() ) * Point I make ( OrderOpenPrice() - OrderClosePrice() ) / Point

When you multiply 000000000000000000, you get

 

Yes, of course - I made a mistake - you have to divide by Point, not multiply at all!

By function.

It's very simple. For example. You need to know the current profit (or loss) in the deposit currency of open trades (let's assume) - Bai-positions on EURUSD and Sell-positions on GBPUSD.

Take the function https://www.mql5.com/ru/forum/131859/page3#434223

and copy it to the end of your code (outside the START function)

Then current profit in currency of your positions will be (set inside of START):

double PROFIT_ EURUSD = GetProfitOpenPosInCurrency(EURUSD, OP_BUY, -1) ;

double PROFIT_FUNTDOLLAR = GetProfitOpenPosInCurrency(GBPUSD, OP_SELL, -1) ;

If you specified a magik when opening these positions, specify the magik instead of "-1".

If you need to know the profit of a position according to the current symbol, i.e. in the chart, on which the EA has been placed and is running, then :

double PROFIT_NULL = GetProfitOpenPosInCurrency(NULL, OP_SELL, -1) ;

 
leonid553:

Yes, of course - I made a mistake - you have to divide by Point, not multiply at all!

By function.

It's very simple. For example. You need to know the current profit (or loss) in the deposit currency of open trades (let's assume) - Bai-positions on EURUSD and Sell-positions on GBPUSD.

Take the function https://www.mql5.com/ru/forum/131859/page3#434223

and copy it to the end of your code (outside the START function)

Then current profit in currency of your positions will be (set inside of START):

double PROFIT_ EURUSD = GetProfitOpenPosInCurrency(EURUSD, OP_BUY, -1) ;

double PROFIT_FUNTDOLLAR = GetProfitOpenPosInCurrency(GBPUSD, OP_SELL, -1) ;

If you specified a magik when opening these positions, specify the magik instead of "-1".

If you need to know the profit of a position according to the current symbol, i.e. in the chart, on which the EA has been placed and is running, then :

double PROFIT_NULL = GetProfitOpenPosInCurrency(NULL, OP_SELL, -1) ;


Thanks for the advice.

But I want to set profit as a percentage of initial deposit and loss of deposit to be calculated. It works, but only for each trade, it is not possible to calculate the total loss.

 
Vodya:


Thanks for the tip.

But I want to calculate the profit as a percentage of the initial deposit and the loss of the deposit. I can calculate it, but only for each deal, it does not work in total.

Below are functions to calculate the Profit and Loss.

If you have the size/loss value you can calculate what it is as a percentage of the deposit.

 double Profit(){
   double profit=0; 
   for(int i=OrdersHistoryTotal()-1; i>=0; i--){
     if(!OrderSelect(i,SELECT_BY_POS,MODE_HISTORY))continue; 
     if(OrderSymbol()!=Symbol())continue;
     if(OrderMagicNumber()!=Magic)continue;
     if(OrderType()>1)continue;
     if(OrderProfit()>0)profit+=OrderProfit();
    }        
 return(profit);} 

 double Loss(){
   double loss=0; 
   for(int i=OrdersHistoryTotal()-1; i>=0; i--){
     if(!OrderSelect(i,SELECT_BY_POS,MODE_HISTORY))continue; 
     if(OrderSymbol()!=Symbol())continue;
     if(OrderMagicNumber()!=Magic)continue;
     if(OrderType()>1)continue;
     if(OrderProfit()<0)loss+=OrderProfit();
    }        
 return(loss);} 
 
charter:

Below are the functions to calculate Profit and Loss.

With the size/value of the Profit and Loss, you can calculate what this amounts to as a percentage of the deposit.


Thank you.

But when you compile in this row.

double Profit(){

it comes up with '(' - function definition unexpected

and this '}'. - unbalanced parentheses where the last return(0) is.

Where should it be pasted at all? Maybe I put it in the wrong place

Reason: