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
Thanks for the reply ... So, to search orders in the trading history, we use the functionOrdersHistoryTotal, which, after discarding everything we don't need, looks like this
for(int i=OrdersHistoryTotal()-1; i>=0; i--) // - the question here is what "accTotal" meansin the function template that we discarded, and why did you take "i--" and not "i++" as in the template?
- the second functionOrderComment returns the comment of the selected order if it is selected by the previous functionOrdersHistoryTotal, takes the form
if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)) //- where "i", this is "i>=0" from the previous function, and "SELECT_BY_TICKET" was replaced with "SELECT_BY_POS" and "MODE_HISTORY" was added- why?
- The third line is definition, we don't actually need to check the necessary order since we only have market orders closed by TP and SL in this history (we might have a closed pending order, but it will be rare), all other order parameters are not important to us. The only important thing is the amount of closed orders in the history will constantly increase, is it possible to make our recalculation take certain amount of the last orders, for example, 5-10, and not all of them?
- The last four lines are quite clear, the only question is about the PlaySound function, the code of which should be inserted after each"Print("..." linelike this
OrderComment returns the comment of the selected order, if it is selected by the previous functionOrdersHistoryTotal - this function doesn't select anything - it returns the total number of closed and deleted orders(The number of closed and deleted orders in the history of the current account, loaded in the client terminal. The size of the history list depends on current settings of the "Account History" tab of the terminal. Quotation from the tutorial).
accTotal in the example from the tutorial:
int i,accTotal=OrdersHistoryTotal(); - This is an int variable - taking value OrdersHistoryTotal
for(i=0;i<accTotal;i++)// How to loop through history list is not important from first to last order or vice versa, it still goes through all list in sequence.
But in the previous case, we have 1 less variable, but the request OrdersHistoryTotalis processed in every cycle.
SELECT_BY_POS - the index parameter contains the index number of the order in the list, the list itself is the second operator - MODE_HISTORY is the list of closed, MODE_TRADES - open or pending. SELECT_BY_TICKET - the ticket number is passed in the index parameter. Which should be taken somewhere before the order is selected.
- Thelast four lines are generally clear, the only question is about the PlaySound function, the code of which should be inserted after each "Print("..." linein the following form:
bool PlaySound(
string payment // file name
)
; ...
Or is it also converted somehow?
Declare
then what will Print print? And under what condition?
What is the point of this action? To play a sound when the order is closed and to write the comment (by TP or SL)?
Thanksto Vitalie Postolache for the help, thanks for the advice, and the information on these textbooks is probably a little late for me to study in my sixth decade, I probably can not do so much, I should have earlier, but there was no time. I'm really boring you here, sorry if that, I won't go on, I'm leaving.
By the way, I also have a question.
I need to write a Spread check.
I have been using a simple request for its value and prohibition to open an order if spread exceeds the specified value.
But what has happened is that when spread is decreasing, the EA opens an order and that spread increases.
Now I cannot find the correct way to take it into account: if we add the spread to the array every tick, how big will the array get? Then again, for how long will it last?
Of course, we may not use similar values or use only smaller and bigger values, but in this case we have to reset it to zero somehow.
And most importantly, I cannot understand if I should take into account the minimum and maximum spread or an indication of its jumps.{
datetime time; // время начала периода
double open; // цена открытия
double high; // наивысшая цена за период
double low; // наименьшая цена за период
double close; // цена закрытия
long tick_volume; // тиковый объем
int spread; // спред
long real_volume; // биржевой объем
};
{
datetime time; // время начала периода
double open; // цена открытия
double high; // наивысшая цена за период
double low; // наименьшая цена за период
double close; // цена закрытия
long tick_volume; // тиковый объем
int spread; // спред
long real_volume; // биржевой объем
};
int spread;// spread
i.e. no
{
datetime time; // время начала периода
double open; // цена открытия
double high; // наивысшая цена за период
double low; // наименьшая цена за период
double close; // цена закрытия
long tick_volume; // тиковый объем
int spread; // спред
long real_volume; // биржевой объем
};
If you ask for the current bar, then the current spread, if from history, then at the time of closing.
I understand correctly, that to write data to the array, you need to assign each cell a different value array1[i] = x; indicating a specific cell number
or can the array be filled sequentially from i=0 onwards?
I understand correctly, that to write data to the array, you need to assign each cell a different value array1[i] = x; indicating a specific cell number
or can the array be filled sequentially from i=0 onwards?
What's the difference? I think it's just two different paths.