[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 362
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
Greetings all,
Can you advise me if there is a script that automatically sets SL after opening a trade?
I have a lot of trades, I don't always have time to set it, sometimes I forget.
Can you tell me if there is a script that automatically sets SL after a trade is opened?
How can I read CSV-files with volumes in what format?
You need it to check the real volumes and indicators like Chaikin's Indicator or Money Flow Indicator on an hour or day timeframe
an example of exporting quotes format http://www.finam.ru/analysis/export/default.asp
How can CSV files with volumes be read? in which format? is a special script being written?
File operations through WinAPI edit to suit your needs
Where is the error?
if (BUY TERMINAL)
if(OrderSymbol()==symbol)
{
RefreshRates(); // price refresh
ticket=OrderSend(Symbol(),OP_BUY,Lot,Ask,3,Bid-StopLoss*Point,Bid+TakeProfit*Point, "Buy",1111,0,Green);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice());
}
else Print("Error opening BUY order : ",GetLastError());
return(0);
}else
{
if(OrderSelect(0,SELECT_BY_POS,MODE_TRADES))
{
if(OrderType()==OP_SELL)
RefreshRates(); // price refresh
OrderClose(NULL,Lot,Bid,3);
return(0);
}
}
meaning:
if the condition to buy is met
If there are no open trades on this pair
open a buy
if there is more than one open trade at this pair
trade "X to buy" is opened
Otherwise we receive an error when a deal is opened
otherwise select an open order on this pair
If the order to sell
then close on the market
we go back in a loop.
I got an error in the terminal with the code I have now - invalid ticket for OrderClose function
help me solve this problem
Where is the error?
if (CONDITION TO BUY)
if(OrderSymbol()==symbol)
{
RefreshRates(); // refresh prices
ticket=OrderSend(Symbol(),OP_BUY,Lot,Ask,3,Bid-StopLoss*Point,Bid+TakeProfit*Point, "Buy",1111,0,Green);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice());
}
else Print("Error opening BUY order : ",GetLastError());
return(0);
}else
{
if(OrderSelect(0,SELECT_BY_POS,MODE_TRADES))
{
if(OrderType()==OP_SELL)
RefreshRates(); // price refresh
OrderClose(NULL,Lot,Bid,3);
return(0);
}
}
the meaning is:
if the condition to buy is met
if there are no open deals on this pair
open a buy
if there are more than one open deal at this pair
trade "X to buy" is opened
otherwise we give out an error of deal opening
Otherwise select an open order at this pair
If the order to sell
close it on the market
go back to the loop.
The code I have now in my terminal gives me an error invalid ticket for OrderClose function
Please help me solve this problem
Well, your code is a mess - it doesn't do what it says in the intended algorithm at all.
I suggest that you first understand the correct use of the functions
1) invalid ticket for OrderClose function
read about the OrderClose function https://docs.mql4.com/ru/trading/OrderClose
What you have: OrderClose(NULL,Lot,Bid,3);
Is there an order with a ticket NULL?
2) Sell orders close at Ask price
Standard script modify.mq4 in the terminal
Thank you!
I dragged it to the chart window, asked - connect to chart. clicked OK. But when opening trades, it doesn't work.
The log shows 2 messages at once:
1. loaded succesfully
2. removed
Why would it remove itself?
Thank you!
I dragged it to the chart window, asked - connect to chart. clicked OK. But when opening trades, it doesn't work.
The log shows 2 messages at once:
1. loaded succesfully
2. removed
Why can it remove itself?
If you still need an order trawl, you don't need a script, but an advisor... see this page.