- Limit trading to a single pair.
- question on global variables
- My EA should continue trading as long as signal exists, help needed!!!
datetime newbar;
int start()
{
if(newbar==Time[0])return(0);
else newbar=Time[0];
//your program
}
datetime newbar;
int start()
{
if(newbar==Time[0])return(0);
else newbar=Time[0];
//your program
}
Roger:
Thanks for the quick reply. I was also thinking this might work:
int start()
{
int total;
string symbol;
total = OrdersTotal()
if(total>0 && symbol = Symbol()) return (0); //Abort! A Position For This Pair is Already Open
//the rest of my program code
}
The idea id to make sure that if there is already an opened order for a particular pair, the EA will not open another position for that pair even if trade conditions are met. SO if I have a GBPUSD position open, the EA can still open a EURUSD position, but it will not open another GBPUSD position until the first one is closed. I don't mind if one position is opened and then closed and then another position (same pair) is opened and closed during the same bar. I just don't want 2 positions in the same pair opened at the same time. So do you think the code above will do it? Should I change the return(0); to return; (doesn't return(0); take the program back to int start())?
Very close. Try this:
int start()
{
int total,ord,i;
string symbol;
total = OrdersTotal();
for(i=0;i<total;i++)
{
OrderSelect(i,SELECT_BY_POS);
if(OrderSymbol() = Symbol())ord++;
}
if(ord>0) return (0); //Abort! A Position For This Pair is Already Open
//the rest of my program code
}
Very close. Try this:
int start()
{
int total,ord,i;
string symbol;
total = OrdersTotal();
for(i=0;i<total;i++)
{
OrderSelect(i,SELECT_BY_POS);
if(OrderSymbol() = Symbol())ord++;
}
if(ord>0) return (0); //Abort! A Position For This Pair is Already Open
//the rest of my program code
}
Thanks, Roger. I'll add this code and test it over the next few days. Appreciate your help.
Thanks, Roger. I'll add this code and test it over the next few days. Appreciate your help.
Hey, Roger:
I had another question. Have you heard of client - side pending orders? Essentially, it allows you to hid your entry point, sl, and tp until the order is executed. Do you know the programming code to make standard pending orders client side pending orders? My objective is to be able to place a long and short pending order in the same account with the same currency (my broker no longer allows heding because of the new Anti-Heding Rule). Can you help?
Actually, not, so sorry. When I had got that problem, I've changed my broker.
Thanks. Roger. Can pick your brain again? What does the function "void" mean? I allowed another programmer to make some changes to my EA, and there is a line that says "void UpDateClosures" with some code follwing in brackets? Can you explain?
Don't worry, nothing special. It means something matters inside this function (for example print smth) and you don't need to use its result in further.
OK: So whatever is inside the function only occurs once and not every incoming tick? The reason I ask is because I have placed the code to abort placing another when there is already one on in the market, but the EA seems to ignore that and continues to places multiple market orders as long as the conditions are met. I am going to test some changes I made and see if I can get it to behave. If I can't in the next couple of days, can you take a look my code for this function and give me some advice?
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use