Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 75
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
SELL_Lvl is the number of knees (orders) of the sell grid andSELL_NoLossLevel is the total level (price) of the CU of these orders. Well, the idea is the following: we need a line drawn at the level of a Buy Line and redrawn respectively when new Lines are opened. I do not know how to do it.
Don't understand how to determine the BU line of all orders?
Can you tell me how to write it down to save resources and get up-to-date prices?
if(OrderSelect(i,SELECT_BY_POS, MODE_TRADES)) {
if(OrderSymbol()==symb) {
if(OrderType()==OP_BUY) {
tk=OrderTicket();
SymbolInfoTick(OrderSymbol(),Last_Tick); <<<
ask=Last_Tick.ask;
bid=Last_Tick.bid;
...
or like this?
for(int i=OrdersTotal(); i>=0; i--) {
if(OrderSelect(i,SELECT_BY_POS, MODE_TRADES)) {
if(OrderSymbol()==symb) {
if(OrderType()==OP_BUY) {
tk=OrderTicket();
ask=Last_Tick.ask;
bid=Last_Tick.bid;
...
Can you tell me how to write it down to save resources and get up-to-date prices?
if(OrderSelect(i,SELECT_BY_POS, MODE_TRADES)) {
if(OrderSymbol()==symb) {
if(OrderType()==OP_BUY) {
tk=OrderTicket();
SymbolInfoTick(OrderSymbol(),Last_Tick); <<<
ask=Last_Tick.ask;
bid=Last_Tick.bid;
...
or like this?
for(int i=OrdersTotal(); i>=0; i--) {
if(OrderSelect(i,SELECT_BY_POS, MODE_TRADES)) {
if(OrderSymbol()==symb) {
if(OrderType()==OP_BUY) {
tk=OrderTicket();
ask=Last_Tick.ask;
bid=Last_Tick.bid;
...
Can you tell me how to write it down to save resources and get up-to-date prices?
if(OrderSelect(i,SELECT_BY_POS, MODE_TRADES)) {
if(OrderSymbol()==symb) {
if(OrderType()==OP_BUY) {
tk=OrderTicket();
SymbolInfoTick(OrderSymbol(),Last_Tick); <<<
ask=Last_Tick.ask;
bid=Last_Tick.bid;
...
or like this?
for(int i=OrdersTotal(); i>=0; i--) {
if(OrderSelect(i,SELECT_BY_POS, MODE_TRADES)) {
if(OrderSymbol()==symb) {
if(OrderType()==OP_BUY) {
tk=OrderTicket();
ask=Last_Tick.ask;
bid=Last_Tick.bid;
...
I would say it depends on the size of OrdersTotal() and the probability of price changes during the cycle.
In my opinion, getting fresh data directly in the loop is more correct.
And I think additional variables (highlighted in the code) are absolutely unnecessary.
There is an example in the documentation.
It would probably be better to go through the orders in the loop and, provided that the next order is lower than the previous one, select it for further work with it. Thus, when we exit the loop, the order to be deleted is already selected.
Or, you can first save its position in the list of orders in the loop and then select it after exiting the loop using the index saved in the loop.
The first option is more correct. The second one should writeSymbolInfoTick(symb,Last_Tick); <<<<
Yes, I just copied it and didn't notice.
I'm wondering ifSymbolInfoTick is the right way to put it inside the loop, if it's needed there, or if it can be put before the loop. Used in trailing stop, can pull grid up to 50pc.
Yes, I just copied it and didn't notice.
I'm wondering ifSymbolInfoTick is the right way to put it inside the loop, if it's needed, or if it can be put before the loop. Used in trailing stop, can pull a grid of up to 50pc.
Can't figure out how to determine the BU line of all orders?
For trailing stop it is of course better once before the cycle.
I'm now slowly rewriting it for 5. I mean that price may change very quickly and the level may be less than the stop-loss value, which will lead to an error. I mean that the price may change very quickly and the level will be less than the allowable stop level, which will lead to an error.
I understand that this"SymbolInfoTick" hat is needed to get actual prices?