Coding help - page 130

 

I don't know if they are objects or buffers. Is it also possible to send orders in the indicator so i don't need any expert advisor? What is the algorithm to open orders with no stoploss and take profit?

But I think I want an expert advisor, open orders by the appearance of the arrows and close the orders when the close signal comes. Can I identify the opened orders by symbol?

 
arroganzmaschine:
I don't know if they are objects or buffers. Is it also possible to send orders in the indicator so i don't need any expert advisor? What is the algorithm to open orders with no stoploss and take profit?

1. Objects are going to be visible in the objects list

2. No. You can not manage orders from an indicator

3. To open orders (ant type of orders) you have to use order send. Help for OrderSend() function :

______________________________________

int OrderSend(string symbol, int cmd, double volume, double price, int slippage, double stoploss, double takeprofit, string comment=NULL, int magic=0, datetime expiration=0, color arrow_color=CLR_NONE)

The main function used to open a position or place a pending order.

Returns number of the ticket assigned to the order by the trade server or -1 if it fails. To get additional error information, one has to call the GetLastError() function.

Notes:

At opening of a market order (OP_SELL or OP_BUY), only the latest prices of Bid (for selling) or Ask (for buying) can be used as open price. If operation is performed with a security differing from the current one, the MarketInfo() function must be used with MODE_BID or MODE_ASK parameter for the latest quotes for this security to be obtained. Calculated or unnormalized price cannot be applied. If there has not been the requested open price in the price thread or it has not been normalized according to the amount of digits after decimal point, the error 129 (ERR_INVALID_PRICE) will be generated. If the requested open price is fully out of date, the error 138 (ERR_REQUOTE) will be generated independently on the slippage parameter. If the requested price is out of date, but present in the thread, the position will be opened at the current price and only if the current price lies within the range of price+-slippage.

StopLoss and TakeProfit levels cannot be too close to the market. The minimal distance of stop levels in points can be obtained using the MarketInfo() function with MODE_STOPLEVEL parameter. In the case of erroneous or unnormalized stop levels, the error 130 (ERR_INVALID_STOPS) will be generated.

At placing of a pending order, the open price cannot be too close to the market. The minimal distance of the pending price from the current market one in points can be obtained using the MarketInfo() function with the MODE_STOPLEVEL parameter. In case of false open price of a pending order, the error 130 (ERR_INVALID_STOPS) will be generated.

Applying of pending order expiration time can be disabled in some trade servers. In this case, when a non-zero value is specified in the expiration parameter, the error 147 (ERR_TRADE_EXPIRATION_DENIED) will be generated.

On some trade servers, the total amount of open and pending orders can be limited. If this limit has been exceeded, no new position will be opened (or no pending order will be placed) and trade server will return error 148 (ERR_TRADE_TOO_MANY_ORDERS). Parameters:

[TD="width: 100%"]Stop loss level.

[TR]

[TD]takeprofit [TD] - [TD="width: 100%"]Take profit level.

[TR]

[TD]comment [TD] - [TD="width: 100%"]Order comment text. Last part of the comment may be changed by server.

[TR]

[TD]magic [TD] - [TD="width: 100%"]Order magic number. May be used as user defined identifier.

[TR]

[TD]expiration [TD] - [TD="width: 100%"]Order expiration time (for pending orders only).

[TR]

[TD]arrow_color [TD] - [TD="width: 100%"]Color of the opening arrow on the chart. If parameter is missing or has CLR_NONE value opening arrow is not drawn on the chart.
symbol[/TD] -[/TD] Symbol for trading.[/TD]

[/TR]

cmd[/TD] -[/TD] Operation type. It can be any of the Trade operation enumeration.[/TD]

[/TR]

volume[/TD] -[/TD] Number of lots.[/TD]

[/TR]

price[/TD] -[/TD] Preferred price of the trade.[/TD]

[/TR]

slippage[/TD] -[/TD] Maximum price slippage for buy or sell orders.[/TD]

[/TR]

stoploss[/TD] -

Sample:

int ticket;

if(iRSI(NULL,0,14,PRICE_CLOSE,0)<25)

{

ticket=OrderSend(Symbol(),OP_BUY,1,Ask,3,Ask-25*Point,Ask+25*Point,"My order #2",16384,0,Green);

if(ticket<0)

{

Print("OrderSend failed with error #",GetLastError());

return(0);

}

}

 

Can I mail you the indicator so you can give me some advice?

 
arroganzmaschine:
Can I mail you the indicator so you can give me some advice?

You can post it (if it is not a private or a commercial indicator)

 

It's private . I think I have to read all the stuff to get to my solution.

Can I close the orders from a specific Symbol where the close signal appears?

 
arroganzmaschine:
It's private . I think I have to read all the stuff to get to my solution. Can I close the orders from a specific Symbol where the close signal appears?
Try going through these two threads first :
https://www.mql5.com/en/forum/173136

https://www.mql5.com/en/forum/173171

also it might be good that you start from this post https://www.mql5.com/en/forum/172969/page2 and it will be much easier to find information about mql coding if you follow the links from that post

 

Thank you, I will reply later.

 

Mladen, quick question please, does (perfect trend line) ptl2 and alerts indicator repaint?

 

I saw that there are also alerts. They are sent when some IndexBuffers have the right value.

Can I send my orders with some if{-clauses?

 
funayot:
Mladen, quick question please, does (perfect trend line) ptl2 and alerts indicator repaint?

No, The '(perfect trend line) ptl2 and alerts' indicator does not repaint after closed bar!

Reason: