Help about price current Bar

 

Hello, I'm newbie, but I'm trying to develop an EA.

I would like to open long or short positions on the basis of my signal at determinate price. 

in particular:

OrderSend with OP_BUY or OP_SELL at price of open current bar.

OrderClose at price of close current bar.

Thank's  a lot... 

 

If you want help with developing your EA, you will need to show what you have done so far.

You also need to describe precisely what you need help with.

 

Ok, I try to explain better:

this is my buy at newBar after RSI signal:

result=OrderSend(Symbol(),OP_BUY,LotsOptimized(),Ask,0,0,0,"",MAGICMA,0,Blue);

and this is my sell at newBar after RSI signal:

result=OrderSend(Symbol(),OP_SELL,LotsOptimized(),Bid,0,0,0,"",MAGICMA,0,Red);

The problem is that the sell, open short position at price of new open bar (Open[0]) and this for me is ok, but the buy open long position at price  that I understand...

Thank's  for the help... 

 

What's your question?

  Do you want to know, why your code doesn't work?

  Or do you want to know how it works?

 

The code for calculate next bar work fine.  

I want to know how to buy at the  opening price of the next bar and sell at the closing price of the bar... 

Thank's 

 
traderforlife:

The code for calculate next bar work fine.  

I want to know how to buy at the  opening price of the next bar and sell at the closing price of the bar... 

Thank's 

You cannot guarantee to sell at the closing price of a bar. You don't know a bar has closed until the new bar opens, so you can only trade at the opening price of the new bar. And then you cannot guarantee that you will actually get that price due to slippage.
 
GumRai:
You cannot guarantee to sell at the closing price of a bar. You don't know a bar has closed until the new bar opens, so you can only trade at the opening price of the new bar. And then you cannot guarantee that you will actually get that price due to slippage.
Ok, so for buy at opening price and sell at closing price of a bar I have to open a trade from next bar and trade in the past?
The command is like this:

result=OrderSend(Symbol(),OP_BUY,LotsOptimized(), Open[1],0,0,0,"",MAGICMA,0,Blue);

result=OrderSend(Symbol(),OP_SELL,LotsOptimized(),Close[1],0,0,0,"",MAGICMA,0,Red);

 
traderforlife:

OrderSend with OP_BUY or OP_SELL at price of open current bar.

OrderClose at price of close current bar.

  1. You can't open a market order "at price of open current bar" except on the first tick of the new bar and only for a sell. A buy has to add the spread.
  2. The Bid is the "price of close current bar." You can't know the final close until a new bar starts, and then it's not the "current bar."
  3. learn to code it, or pay someone. We're not going to code it FOR you.
    We are willing to HELP you when you post your attempt (using SRC) and the nature of your problem.
 
In fact, I assumed to be a novice, I'm also studying through your suggestions.
Excuse me for not using the SRC function.

Thanks again for your time.
Reason: