[Archive!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Couldn't go anywhere without you - 2. - page 357

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
Would you mind posting the code? Maybe a pseudo code. How do you mean without start...? It's a basic function, like main() in C++.
It depends on what tasks you are going to solve and determine the location of your code in the body of the EA program. No one is obliging us to keep the code in the start() function!
The start() function is one of three predefined in our code template. It should be present at least!, because the parent program - the terminal program (this is main(), the main), performing its main tasks, receiving a fresh quote from the server (roughly) just look into your function start and execute the code, which is in it, if it will just return(), then the start function will stop here.
if there is a buy signal
check open sell orders
if there is, close
if there is not, open buy
if there is a sell signal
check open buy orders
if there is, close
if there is not, open buy
help to write the following.
if there is a buy signal
Check open Sell orders
if so, close
if there is no signal to buy
if there is a sell signal
Check open buy orders
if yes we close
if no signal, reopen buy
Start writing yourself - we will help you
here is a starting point to help you https://book.mql4.com/ru/
Start writing yourself - we'll help you
here you go https://book.mql4.com/ru/
I've already "started".
total=OrdersTotal();
if(CONDITION to open a buy order)
if(total<1)
{
ticket=OrderSend(Symbol(),OP_BUY,Lot,Ask,3,Bid-StopLoss*Point,Bid+100*Point, "Buy",1111,0,Green);
if(ticket<0)
{
Print("OrderSend failed with error #",GetLastError());
return(0);
}
}else
{
if(OrderSelect(0,SELECT_BY_POS,MODE_TRADES))
{
if(OrderType()==OP_SELL)
OrderClose(NULL,Lot,Ask,3);
return(0);
}
}
help to write the following.
if there is a buy signal
Check open Sell orders
if yes, close
If there is no signal we may open a buy order
Thank you very much for your help, but I've done things a bit differently and your approach is a bit unclear to me.
Could you explain to me how to sell it all? There's just a lot I don't understand here.
You've been very helpful.
Tried flipping everything to sell - failed. no trades open
Error 130. - Stops are not right, so where do we have them there?
Now it opens an order for each bar, but I need only one.
total=OrdersTotal();
if(total<1)
etc.
Hmm, I went deeper into the game - bids and asks to change etc... thanks for that)
I got the stops sorted out too.