Check - what have I done wrong? - page 2

 
Natalya Smirnova #:

As I am writing for binary options I have done things a little differently:


This would probably be correct?

Here is the problem
There are 2 lines in the terminal for 1 order


And for the order which was placed by the Expert Advisor, Profit == 0

 
Natalya Smirnova #:

I think this is the problem
There are 2 lines in the terminal for 1 order


And on the order which has been placed by the Expert Advisor, Profit == 0

where did you find a price below zero - how do you show a screenshot?

You do not see it in this screenshot

 
Alexey Viktorov #:

You've already been given advice on the whole algorithm, I don't want to interfere and haven't even looked at your code and the same advice... But this

caught my eye. So my question is: Isn't it easier and more readable to use switch operator

I think it's easier to read and understand. Maybe it also works a bit faster.
Maybe instead of function use just array volume[n] ?
Although, if you're paying for every line of code, you'd better leave it that way :))
 
Nikolai Semko #:
Maybe instead of a function just use an array volume[n] ?
Although if you pay for every line of code, it's better to keep it that way :))

Maybe so... I agree.

 
Renat Akhtyamov #:

Where did you find a price less than zero, show me a screenshot?

There is no such thing on this screenshot.


I am trying to get OrderProfit() - it gives 0

here is a confirmation found profit -0.01 as it comes out of that additional line

 
Alexey Viktorov #:

Maybe so... I agree.

I don't get paid it's for myself and self-development. After work, it's interesting to do a grail quest
 

I don't get the negative price, it's still not there.

count the total profit like this (excerpt)

What you need is highlighted

   for(i=0;i<OrdersHistoryTotal();i++)

   {

      if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY))

      {

         if(OrderType()==ORDER_TYPE_BALANCE && OrderCloseTime()>startDate)Withdrawal=Withdrawal+OrderProfit()+OrderCommission()+OrderSwap();

         if((OrderType()==ORDER_TYPE_BUY || OrderType()==ORDER_TYPE_SELL))

         {

            if(OrderCloseTime()>iTime(Symbol(),PERIOD_D1,0))hystCurrDay=hystCurrDay+OrderProfit()+OrderCommission()+OrderSwap();

            if(OrderCloseTime()<iTime(Symbol(),PERIOD_D1,0) && OrderCloseTime()>iTime(Symbol(),PERIOD_D1,1))hystPrevDay=hystPrevDay+OrderProfit()+OrderCommission()+OrderSwap();

         }

      }

   }



 
Natalya Smirnova #:
I don't get paid it's for myself and self-development. After work, it's interesting to do a grail search

Don't mind me. It's just me and Nikolay who are having a little get-together...

The essence of your problem: since OrderProfit() in forex brokerage does not give any real value, you have to define a positively/negatively closed order as the difference between the close price and the open price of the order. You have already been told about this

Forum on trading, automated trading systems and strategy testing

Check what I did wrong?

Renat Akhtyamov, 2021.12.21 09:27

do not understand the logic behind it

how come?

bool profit = false;
         if(OrderClosePrice() > 0)
            profit = true;

         bool loss = false;
         if(OrderClosePrice() < 0)
            loss = true;

how the order close price may be less than zero?

the BUY order will be in the plus position if the close price is higher than the open one

here is the condition of a buy plus (excluding commissions and swap):

OrderClosePrice() > OrderOpenPrice()
If it is the other way round, that's a minus

 
Natalya Smirnova #:
I don't get paid that much for myself and my self-development. After work, it's fun to go on a grail quest.

Yes, Natalia - that was just a meme from the "When you get paid for a line of code" series.

That's the kind of humor programmers have.


You don't need a function in your case.

double SelectVolume(int n)

You just need to form variables Volume1 ... Volume10 variables should be initially formed as an array volume[10]
and then refer to its elements volume[n] by index n.
Don't worry - almost every programmer has gone through this.
The main thing is that you really like programming. I can feel it.
Then you'll go far.

 
I agree. The programming really stinks and it's very long term!!!
Not everyone ends up with a hail....