[ARCHIVE!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Can't go anywhere without you - 4. - page 622

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
I've finished the previous comment, see.
Yes, I understand now why there is a comparison for time in the loop, and time in general....
I also understand the LOGIC - mark "A", then exclude "A", but firstly, all the options WHERE this "A" can be pinned I've tried - and still the advisor returns me the last ticket, not the penultimate.
.
I have entered 2 loops (2 functions) - first your original, second with exception of "A"... run one after the other.
Prints zero....
----------------------------------------------------------------------------------------------------
if ( Hour()>=10 && Hour()<20)
{
LastClosetPoz();Sec_LastClosetPoz();
Print ( ticket2,ticket);
}
return(0);
}
//--------------------------------------------+
int LastClosetPoz()
{
int Tot=OrdersHistoryTotal(),Ticket=-1; datetime time=0;
if(Tot>0)
{
for(int i=0;i<OrdersHistoryTotal();i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==true)
{
if(OrderSymbol()==Symbol())
{
if(OrderCloseTime()>time)
{
time=OrderCloseTime();Ticket=OrderTicket(); A=Ticket;
}
}
}
else continue;
}
}
return(Ticket);
}
//--------------------------------------------
int Sec_LastClosetPoz()
{
int Tott=OrdersHistoryTotal(),Ticket2=-1; datetime time2=0;
if(Tott>0)
{
for(int i=0;i<OrdersHistoryTotal();i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==true)
{
if(OrderSymbol()==Symbol()&&OrderTicket()!=A)
{
if(OrderCloseTime()>time2)
{
time2=OrderCloseTime();Ticket2=OrderTicket();
}
}
}
else continue;
}
}
return(Ticket2);
}
Help me if I decided to write a robot in C/C++, for example. It's not a problem to write one, but how do I connect it with metatrader? How to get quotes and how to send a buy/sell signal back?
DLL - see examples. Is it possible that a programmer, who knows how to write in C/C++, is not able to deal with standard examples from МТ delivery and this despite the presence of a lot of materials on the forum?
DLL - see examples. Is it possible that a programmer who knows how to write in C/C++ is not able to understand standard examples from МТ delivery and this despite the fact that there is a lot of material on the forum?
I'm not a programmer, but sometimes write the simplest things myself. I don't need to write a complex robot in any language and it's not a problem at all. I want to write a robot with its own interface and not to execute part of functions as a dll and call them from μl. Thanks to all sorts of visual languages where this can be done without a lot of stress
Yes, I understand now why there is a comparison for time in the loop, and time in general....
I also understand the LOGIC - mark "A", then exclude "A", but firstly, all the options WHERE this "A" can be pinned I've tried - and still the advisor returns me the last ticket, not the penultimate.
.
I have entered 2 loops (2 functions) - first your original, second with exception of "A"... run one after the other.
Prints zero....
This function uses local variables, so it should not be run yes times as a separate function, make two loops one after the other in one function, or declare A as a global variable. I'll go get cigarettes and you try it, and if it doesn't work, knock me when I get back and we'll figure it out.
I'm not a programmer, but sometimes I write the simplest things myself. I want to write a simple robot in any language and it's not a problem at all. I wanted to write a whole robot with its own interface without calling Metatrader, not part of its functions in a dll and call them from μl. I have invented a lot of different visual languages, where this can be done without much effort.
If you do not want to use terminal features at all (more than a hundred different built-in functions, built-in indicators, the program interface itself), then it is not about a simple Expert Advisor, but about your own terminal, your own development, and I think they can hardly help you with that, especially in this branch.
This function uses local variables, so don't run it yes times as a separate function, make two loops one after the other in one function, or declare A as a global variable. I'll run out to get cigarettes, and you try it while, if you fail, knock me when I come back, we'll figure it out.
IS!!!! there was a small mistake...it was not Ticket but LastClosetPoz() and Sec_LastClosetPoz() that should have been printed.
I'm sure my version isn't the most elegant... but it works... How do you put two loops in one function... I don't know... I tried it... I got errors... to hell with it! (if it's not too much trouble - show me - it'll be useful to me, if not - well, never mind...) Thanks anyway.
However, I have a feeling if I need to figure out the ticket of the 35th closed transaction...I'll be in trouble with my approach :)))) hahahah
goodness that's not even on the horizon yet...3 at the most...
This function uses local variables, so don't run it yes times as a separate function, make two loops one after the other in one function, or declare A as a global variable. I'll go get some cigarettes and you can try it, and if it doesn't work, knock me when I get back and we'll figure it out.
worked until I inserted the following
if (OrderSelect( (LastClosetPoz (),SELECT_BY_TICKET)==true)) Print("Stop loss", OrderStopLoss();
it swears
')' - wrong parameters count G:\Program_Files_2\MT4-demo\experts\000.mq4 (57, 60)
I don't understand what it wants?
--------------------------------------------------------------------------------------------
FIGURED IT OUT
==true....
which is strange, because the examples in the tutorial always say so...
and it also rounded up the stop value...to the 4th digit...
IS!!!! there was a small mistake... the print should have been LastClosetPoz() and Sec_LastClosetPoz() instead of Ticket.
I'm sure my version is not the most elegant... But it works... How to insert two loops into one function... I don't know... I tried it... I got errors... to hell with it! (if it's not too much trouble - show me - it'll be useful to me, if not - well, never mind...) Thanks anyway.
However, I have a feeling if I need to figure out the ticket of the 35th closed transaction...I'll be in trouble with my approach :)))) hahahah
goodness that's not even on the horizon yet...3 at the most...
prints zeros...does not work...will not dig any more, because it is obvious that the loops are simply substituted one for the other - the volume is clearly not reduced..... and we already have a working version. I can compare orders in the first variant... and here I can't even see where the second one is... and the first one is zero...
after some minor tinkering...which clearly develops the brain, this code worked too! :))) thanks
worked until I inserted the following
if ( Print("Stop loss", OrderStopLoss());) Print("Stop loss", OrderStopLoss();
it swears
')' - wrong parameters count G:\Program_Files_2\MT4-demo\experts\000.mq4 (57, 60)
I don't understand what it wants?
Again 45, in this form OrderSelect(LastClosetPoz (),SELECT_BY_TICKET) selects among pending and open orders by default and this order is not there. PutOrderSelect(LastClosetPoz (),SELECT_BY_TICKET, MODE_HISTORY).