
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
so can anyone help me please? example it will only trade one order in 5 am - 10 am but can trade again in another time..
It is very simple, You need to check order open time of last order in history and then check the day with TimeDay function. If it is today then do not trade.
It is very simple, You need to check order open time of last order in history and then check the day with TimeDay function. If it is today then do not trade.
can you give me a simple script on how to use them? i am not a programmer, sorry
thank you!
1 trailing stop / multiple orders
im trying to make an EA that will modify all open orders stoploss to equal the same as the current stoploss, so that all orders will close at the same level
extern int profit = 100;
extern int stop = 20;
int start()
{
int i, HstTotal=OrdersHistoryTotal();
for(i = HstTotal-1; i >= 0; i --)
{
if(!OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)) continue;
OrderModify(i,OrderOpenPrice(),Bid-Point*stop,profit,0,Green);
}
}
Use OrdersTotal() and MODE_TRADES instead
It is very simple, You need to check order open time of last order in history and then check the day with TimeDay function. If it is today then do not trade.
for(int k=0;k<OrdersTotal();k++)
{
OrderSelect(k,SELECT_BY_POS,MODE_TRADES;
if(OrderSymbol()== "GBPUSD" && OrderMagicNumber()== Magic_Number)
{
if(OrderOpenTime() != TimeCurrent ()) {Trade = true;}
if(OrderOpenTime() == TimeCurrent ()) {Trade = false;}
}
}
what did i do wrong?please help
Corrections in Red below.
Robert
for(int k=0;k<OrdersTotal();k++)
{
OrderSelect(k,SELECT_BY_POS,MODE_TRADES)
if(OrderSymbol()== Symbol() && OrderMagicNumber()== Magic_Number)
{
if(TimeDay(OrderOpenTime()) != Day()) {Trade = true;}
if(TimeDay(OrderOpenTime()) == Day() ) {Trade = false;}
}
}
The same type of code can be used to check if the open time is between two hours or even times to the minute like 11:45 to prevent a new trade.
int openHour = TimeHour(OrderOpenTime());
if (openHour > 10 && openHour < 13) Trade = false;
if (openHour = 13) Trade = true;
what did i do wrong?please helpATTN Programmers - Problem with new 6 digit prices
To all Programmers.
It has come to my attention that there is a problem with some brokers using an additional decimal place for prices. This will cause a problem anywhere Point is used in a calculation for things like StopLoss, TakeProfit or Breakout Levels.
There is a simple solution.
I now use the following function and replace all reference to Point with myPoint.
I declare a variable at the top of the EA.
double myPoint;
then in init I use the funtion to set the value.
init()
{
myPoint = SetPoint();
}
Then the function.
// Set Point value to 2 or 4 decimal places
// to handle brokers who use 3 and 5 decimal places
double SetPoint()
{
double mPoint;
if (Digits < 4)
mPoint = 0.01;
else
mPoint = 0.0001;
return(mPoint);
}
There would also be a problem with some indicators that use Point to determine where to draw lines or size of histograms.
Please pass this along to any forum or group where programmers need this information.
I already posted at Yahoo group MTE & I.
Hope this helps.
Robert
Gidday
I am looking for some help I can't seem to work out how to exit a position in a certian number of bars/days. eg I go long on monday and the system exits on the close 5 bars/days later.
Any help would be good
Cheers
Beno
Beno,
You could use code similar to above post for not trading. Just check if current day is the number of days later for closing from the open day. The code could be modified to use hours or minutes as well.
Another way would be to calculate the time to close the trade as exit_time when the trade is open. Then to exit just check the exit_time in your check exit code.
You would need to use the proper formula to add the correct value to the open time to obtain the close time. This would use the number of minutes per bar * the number of bars later to close added to the OrderOpenTime().
Hope this helps.
Robert
Gidday
I am looking for some help I can't seem to work out how to exit a position in a certian number of bars/days. eg I go long on monday and the system exits on the close 5 bars/days later.
Any help would be good
Cheers
Beno