Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 404

 
Vinin:
Only four functions are accessed by the server. Opening, modifying and closing (deleting) an order
artmedia70:
Trading functions. They are the only ones that send a request specifically to the trade server and receive a response from it.

Thank you.

 
Roger:
The user can sort the history for visual perception only, the position numbers in the history cannot be changed.


How can you tell if a strategy is profitable or unprofitable based on the indicators?
 
khorosh:

And if you are going to take the function apart, you should not have cut the function's header, there is important information there.

Returns the type of the last position opened or -1 - this means that if there are no closed positions, then when the function is called, its value will be equal to -1

sy - name of the instrument (currency pair)

mn - magic number. If we set -1, the function will return the type of the last closed order no matter what magic number is used

Know this too, except for the "magic number" feature.
Thank you for providing useful guidance.
There is no need to truncate the description of the variables.

artmedia70:

1. let's dispense with the sarcasm, ok? He made your learning comfortable and easy. What does genius have to do with it?
2. Argumentative.
3. You don't understand a damn thing judging by your comments in the code.
4. It happens.

Regarding item 2, here's an example:

There are less unnecessary things.

1 - there was no sarcasm! The genius lies in the fact that it made my learning comfortable and easy.
2 - as many people as there are opinions. :)
3 - it's still understandable. I didn't clarify the variable goals being performed, which caused this opinion to emerge.

Thank you for the detailed description of the function strings action, I made sure of my understanding of the presented function.

Please note that we were now engaged in a virtual conversation on four topics simultaneously. It's very advantageous to lay out your answers on the internet point by point, but some people take it as an insult, sorry.

By the way, address me as "you" as my age does not allow me to be addressed as "you" (an opinion formed in relation to ninth grade social studies course).
khorosh:

1 - Your examples are not correct. 2 - When you call a function that has parameters, you must give the values of those parameters in parentheses, separated by commas. You should also be aware that not all functions are assigned values. 3 - If the type of the function is void, then it has no meaning and is intended to perform some action, or to calculate some variables. In the latter case, you need to know the names of these variables in order to use the results of this function.

Excuse me, the answer is broken down into paragraphs.
1 - my examples are incorrect - this is a consequence of my ignorance.
2 - I completely forgot about the brackets. Thank you. They reminded me of them.
3 - void ? Can it be used instead of a bool when calculating by actions (*, /, +, - )?


artmedia70:

The compiler will generate an error on this line saying that the variable is not declared.

The minimum requirement is this:


Yes, yes! I forgot about the brackets, but I've been reminded, thank you anyway!
 
Profitov:

How can you tell from the history that the strategy is profitable or loss-making, based on indicator readings?

The indicators use close/open prices and highs/minimums of bars for calculations.
The values of close/open prices and highs/minimums of bars are stored in the history.
Then, indicators get values of close/open prices, highs/minimums of bars from history,
accordingly indicator makes calculations from history.
it can be concluded that if the strategy is based on indicator indications, you can check if it is profitable or unprofitable using historical data.

Vinin:

You should first familiarise yourself with the concept of a function. And then you can move on to what they do and how to use them.

Familiarised with the three interpretations of the word 'function'.
 
Link_x:


3 - void ? Is it possible to use it instead of bool when counting by actions (*, /, +, - )?

I don't understand the question. The documentation gives an example of a void type function which prints the error name:

void errmesg(string s)
  {
   Print("error: "+s);
  }
 

And maybe after the third time someone will still pay attention to my request?

Wrote a CAM function, but the tester gives error 4051, i.e. impossible number of lots. Anyone have an opinion on this?

double FindRightLot (int otype) // функция поиска лота, необходимого для выхода из просадки после 
                               //закрытия сетки ордеров
{
  double Lot=0; double TotalLot=0;
  for (int i = OrdersTotal()-1; i>0; i--)
  {
    if (OrderSelect(i, SELECT_BY_POS,MODE_TRADES))
    {
       if (OrderSymbol()==Symbol() && OrderMagicNumber()==Magic && OrderType() == otype)
       {
         if (otype == OP_BUY)
         {
           Lot = NormalizeDouble (((OrderOpenPrice()-Bid)*Point)*OrderLots()/TP,2); 
           if (Lot>0)
           {
              TotalLot= TotalLot+Lot;
           }
         }
           
       
         else if (otype == OP_SELL)
         {
           Lot = NormalizeDouble (((Ask-OrderOpenPrice())*Point)*OrderLots()/TP,2);
           if (Lot>0)
           {
            TotalLot= TotalLot+Lot;
           }
           
         }
       }
     }
   }
   return (TotalLot);
   
 }
 
Trader7777:

And maybe after the third time someone will still pay attention to my request?

Wrote a CAM function, but the tester gives error 4051, i.e. impossible number of lots. Anyone have an opinion on this?


Does the price need to be multiplied by Points?

(OrderOpenPrice()-Bid)*Point)
 
Trader7777:

And maybe the third time someone will still pay attention to my request?

I wrote the function by SAM, but the tester gives error 4051, i.e. impossible number of lots. Anyone have an opinion on this???

 double Lot=0; double TotalLot=0;
if (Lot>0)
Note the value of the variable which sets the number of lots when a position is opened.
This value is zero.
It is impossible to open a position with zero volume for trading.



vadynik:


Does the price need to be multiplied by Points?


It's also possible, the main thing is to write the code correctly.
 
vadynik:


Does the price need to be multiplied by the Points?


Let's assume I bought at 1.50,000 and the price went up to 1.49950. If you do not multiply by Points, it comes out 0.0005*0.1/100=0.0000005 not enough


If multiplied, then 50*0.1/100= 0.05 is the right value.

 
Link_x:
Note the value of the variable which sets the number of lots when a position is opened.
This value is zero.
It is impossible to open position with zero volume for trading.




This is also possible, the main thing is to write the code correctly.



Are you sure you know what you're talking about?
Reason: