Hi experts,
Im a newie in terms of programming in MQL and I have an EA in where I want ONLY to open orders in OPEN PRICE since my strategy would require this.
Is there any procedure or mql part of code that I can use for this target?, or maybe some topics about functions?
I'm not very clear on what you mean . . .
If you are placing a Market order you place a Buy at ask and a Sell at Bid. If you want to know the Open price of a bar on the current chart timeframe then you can use Open[bar_number] if you want t different timeframe you can use iOpen()
Hi RaptorUK
First of all thanks a lot for your quick reply,
I am using...
sell_stop_tt = OrderSend("EURUSD", OP_SELLSTOP, lot, Trading_ratio, 0, SL, TP , sCommentPrefix + "_eu", Magic_sell, 0, Red);in order to put buy and sell stops in ask and bid, and then I use the function
sell_tt = OrderSend("EURUSD", OP_SELL, lot, StrToDouble(DoubleToStr(Bid,Digits)), Slippage, SL_a, TP_a, sCommentPrefix + "_eu", Magic_sell, 0, Red);
in order to launch the sell order to market due some entry filters. Given that, where should I use the Open[bar_number] that you propose me? In the same routine or inside the OrderSend? I am confused with that...
I´ll paste some part of the routine that open the sell operation for shedding some light on it
Thanks a lot for your help!
void OpenSellOrder() { int vs_2; double SL_a = 0, double TP_a = 0; SL_a = 0; if (SL > 0) if (SL> MarketInfo("EURUSD",MODE_STOPLEVEL)) SL_a = Bid + SL*Point; else SL_a = Bid + MarketInfo("EURUSD",MODE_STOPLEVEL)*Point ; vs_2 = OrderSend("EURUSD", OP_SELL, Lot , StrToDouble(DoubleToStr(Bid,Digits)), Slippage, SL_a ,TP_a ,sCommentPrefix + "_eu", Magic, 0, Red); }
Hi RaptorUK
First of all thanks a lot for your quick reply,
I am using...
sell_stop_tt = OrderSend("EURUSD", OP_SELLSTOP, lot, Trading_ratio, 0, SL, TP , sCommentPrefix + "_eu", Magic_sell, 0, Red);in order to put buy and sell stops in ask and bid, and then I use the function
sell_tt = OrderSend("EURUSD", OP_SELL, lot, StrToDouble(DoubleToStr(Bid,Digits)), Slippage, SL_a, TP_a, sCommentPrefix + "_eu", Magic_sell, 0, Red);
Do not do this . . .
StrToDouble(DoubleToStr(Bid,Digits))
there is no need, just use Bid
Given that, where should I use the Open[bar_number] that you propose me? In the same routine or inside the OrderSend? I am confused with that...
I'm not sure what you mean by . . . . " I want ONLY to open orders in OPEN PRICE" can you explain please ?
Zerit0,
Creating an EA which operates in "Open prices mode" (like in the strategy tester of your mt4 terminal) requires an EA which opens and closes orders based on the close of the last bar aka bar[1].
Example:
if(close[2]<close[1]){ send a buy/sell order} // close[1] is the last closed bar. // "open price" means - if close two is less than close one, the buy/sell order will be sent at Open[0] (the open of the latest bar).
"Every tick mode" is when an EA opens and closes orders based on the current bar aka bar[0].
In "Every tick mode" an EA closes orders if High[0] or Low[0] touch an indicator, a previous candlestick High or Low, etc.
Thank you.
int start(){ static datetime Time0; if (Time0 == Time[0]) return(0); Time0 = Time[0]; // Start of a new bar.
WHRoeder,
Live trading may always run in "every tick mode", but that does not mean that orders must be placed by the tick. Orders can be placed after the close of the previous bar,candlestick or line and at the open of a new bar,candlestick or line. I believe "Open prices only mode" has nothing to do with ticks in regard to order opens and/or order closes of EAs running in this mode.
(I believe you are expressing that when trading live without an EA, trading is done by the tick I suppose. Please correct if incorrect.)
Thank you for your response.
- What the OP was asking about: "I want ONLY to open orders in OPEN PRICE." If you ONLY want to trade the the open of a new bar, do what I said "Wait for a new bar, THEN check your conditions. Your "every tick mode" is only a function of the tester and is irrelevant to the OP's question.
- This forum is about MetaQuotes Language 4 and auto trading There for "trading live without an EA, trading is done by the tick I suppose. Please correct if incorrect.)" is incorrect as that would be off topic. Trading by EA is also by the tick, just the programmer decides what ticks to ignore.
- Why are you thanking me about a response to someone else's question?
I'm not very clear on what you mean . . .
If you are placing a Market order you place a Buy at ask and a Sell at Bid. If you want to know the Open price of a bar on the current chart timeframe then you can use Open[bar_number] if you want t different timeframe you can use iOpen()
-
Your post is almost unintelligible. If you are using mechanical translation, you must use simple language structure.
Please post only in English on this forum. "hwe", "wht", "n", "u", "plz", "hw", "kw" are not words.
Please don't write ur - it's "you are" or "your" - MQL4 programming forum 2014.03.04Use the automatic translation tool if needed.
- OrderOpenPrice() returns the price that the order was opened at. iOpen returns the starting price of a candle. They will always be different unless you sell at the very first tick of a new candle.
Wait for a new bar, THEN check your conditions. Live trading is ALWAYS 'every tick mode'
can someone here help me out!!..when take a buy order,the order opens above the ask price ,this happens everytime,bt whn i take a sell order it opens exact at market price bid perfectly.how do i correct the ordersend function for a buy order.i m working on broker hotforex
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi experts,
Im a newie in terms of programming in MQL and I have an EA in where I want ONLY to open orders in OPEN PRICE since my strategy would require this.
Is there any procedure or mql part of code that I can use for this target?, or maybe some topics about functions?
Thanks a lot for your help.
Best regards,