- Please edit your (original) post and use the CODE
button (Alt-S)! (For large amounts of code, attach it.)
General rules and best pratices of the Forum. - General - MQL5 programming forum
Messages Editor -
For a new bar test, Bars is
unreliable (a refresh/reconnect can change number of bars on chart,)
volume is unreliable (miss ticks,) Price is unreliable
(duplicate prices and
The == operand. - MQL4 programming forum.) Always use time.
I disagree with making a new bar function, because it can only be called once per tick. A variable can be tested multiple times.
New candle - MQL4 programming forum -
int ticket=OrderSend(Symbol(),OP_SELL,lot,Bid,slippage,Bid+5000*MathPow(10,-Digits),Bid-5000*MathPow(10,-Digits),"position enable",magic,0,Red);
You buy at the Ask and sell at the Bid. So for buy orders you pay the spread on open. For sell orders you pay the spread on close.- Your buy order's TP/SL (or Sell Stop's/Sell Limit's entry) are triggered when the Bid reaches it. Not the Ask. Your SL is shorter by the spread and your TP is longer.
- Your sell order's TP/SL (or Buy Stop's/Buy Limit's entry) will be triggered when the Ask reaches it. To
trigger at a specific
Bid price, add the average spread.
MODE_SPREAD (Paul) - MQL4 programming forum - Page 3 #25 - The charts show Bid prices only. Turn on the Ask line to see how big the spread is (Tools → Options (Control-O) → charts → Show ask line.)
-
Check your return codes for errors, and report
them including GLE/LE. Don't look at it unless you have an error. Don't just silence the compiler, it is trying to help you.
What are Function return values ? How do I use them ? - MQL4 programming forum
Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles - MathPow(10,-Digits) is just Point. Do you really want your stops to be 500 PIPs?
-
if(DayOfWeek()==0 && Hour()==0 && Minute()==0 && Seconds()==0)
The market is closed Sunday at midnight. What happens if there isn't a tick exactly the first second?
- Please edit your (original) post and use the CODE
button (Alt-S)! (For large amounts of code, attach it.)
General rules and best pratices of the Forum. - General - MQL5 programming forum
Messages Editor - For a new bar test, Bars is unreliable (a refresh/reconnect can change number of bars on chart,) volume
is unreliable (miss ticks,) Price is unreliable (duplicate prices and The
== operand. - MQL4 programming forum.) Always use time.
I disagree with making a new bar function, because it can only be called once per tick. A variable can be tested multiple times.
New candle - MQL4 programming forum - You buy at the Ask and sell at the Bid. So for buy orders you pay the spread on open. For sell orders you pay
the spread on close.
- Your buy order's TP/SL (or Sell Stop's/Sell Limit's entry) are triggered when the Bid reaches it. Not the Ask. Your SL is shorter by the spread and your TP is longer.
- Your sell order's TP/SL (or Buy Stop's/Buy Limit's entry) will be triggered when the Ask reaches
it. To trigger at a specific
Bid price, add the average spread.
MODE_SPREAD (Paul) - MQL4 programming forum - Page 3 #25 - The charts show Bid prices only. Turn on the Ask line to see how big the spread is (Tools → Options (Control-O) → charts → Show ask line.)
- Check your return codes for errors, and report them including GLE/LE. Don't look at it unless you have an error. Don't just silence the
compiler, it is trying to help you.
What are Function return values ? How do I use them ? - MQL4 programming forum
Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles - MathPow(10,-Digits) is just Point. Do you really want your stops to be 500 PIPs?
- The market is closed Sunday at midnight. What happens if there isn't a tick exactly the first second?
Hello, I'm tank you for the information you gave me :)
I'm just starting to work, so forgive me for my mistakes
May I beg you to write to me this expert because I can not fix my mistakes??? :(
Expert must open a few minutes left to the end of the market in a trading account sell position and open on the other account the buy position must be used all the volume of capital and there is no limit to the profit and loss limit and, at the end, as soon as Begin the market to close the trades. In this case, an account will be profitable and another account will be Margin Call
Can you write this code for me so I can improve it? Certainly Karma will do the right thing for you :)
I used the mql5 translator .to not be upset about my mistakes
Good luck *-*
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
that after several minutes before closing the shop get a position sell and with opening the shop close?
extern int magic=1;
extern int hour=12;
extern int minutes=58;
extern int second=10;
extern int dayofweek=6;
extern double lot=1;
extern int slippage=6;
void OnTick()
{
if(Volume[0]<=1)
{
if(DayOfWeek()==dayofweek && Hour()==hour && Minute()==minutes && Seconds()==second )
{
pendsell();
}
if(DayOfWeek()==0 && Hour()==0 && Minute()==0 && Seconds()==0)
tabposition();
}
}
void pendsell()
{
int ticket=OrderSend(Symbol(),OP_SELL,lot,Bid,slippage,Bid+5000*MathPow(10,-Digits),Bid-5000*MathPow(10,-Digits),"position enable",magic,0,Red);
}
//------------------------------------------------
void tabposition()
{
for(int i=OrdersTotal()-1;i>=0;i--)
{
int ticket1=OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderMagicNumber()== magic)
{
int ticket=OrderClose(OrderTicket(),OrderLots(),Bid,slippage,Yellow);
Print("position closed");
}
}
}
is there any command that returnes the time of opening or closing the shop???????????????????????