[ARCHIVE!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Can't go anywhere without you - 4. - page 42
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
Do DoCs have a limit on the number of trades?
Some have not only a limit on the number of deals, but even a limit on the number of requests.
They are such inventors! :-))
The rest of them stay open till the end of the test though a conditional closing of one order should take place when another one is opened.
Another question about errors 4051 and 134 when using OrderClose(), what do they mean? I copied info from the log.
The last option seems to have worked more or less well. Although it is possible to simplify the calculations
Please advise! How can I close two pending orders with same magic, but with different lot.
int start()
{
double MyLastBullOpenPrice=0;
for(int Cnt=0;Cnt<OrdersTotal();Cnt++)
{
OrderSelect(Cnt,SELECT_BY_POS,MODE_TRADES);
if(OrderMagicNumber()==12345 && OrderType()==OP_BUY)
{
MyLastBullOpenPrice=OrderOpenPrice();
double Cena=OrderOpenPrice()+5*Point;
double Totalcena= Bid;
if (Totalcena>Cena)
{
if (OrdersTotal()>0)
{ for (int i=OrdersTotal()-1; i>=0; i--)
{ if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)
{ if(OrderMagicNumber()==12345)
{ if(OrderDelete(OrderTicket())==true)
{
Print("Error = ",GetLastError()); return(0);
}
} } } }
}
}
return(MyLastBullOpenPrice);
}
The rest of them stay open till the end of the test though a conditional closing of one order should take place when another one is opened.
Another question about errors 4051 and 134 when using OrderClose(), what do they mean? I copied info from the log.
134 - no money, 4051 - bad parameters passed to the function.
As for the point - check that the variable magick is assigned only once, preferably in function init(), otherwise, every order will have its own magick and the result will be something like you describe.
Please help me to add (or write) a character substitution function for a string through arrays.
Have two arrays of characters:
string symbols1[] = {"a", "b", "c", "d"};string symbols2[] = {"1", "2", "3", "4"};
Tried to write a function that would replace the text badc with 2143, based on the arrays, turned out like this:
string ReplaceSymbolsInStr(string text){
string textMod[] ={""};
string symbols1[] = {"a","b","c","d"};
string symbols2[] = {"1","2","3","4"};
int textLen = StringLen(text);
for (int i1=0; i1<textLen; i1++)
{
string OneSymbol = StringSubstr(text,i1,1);
for (int i2=0; i2<ArraySize(symbols1); i2++)
{
if (symbols1[i2]==OneSymbol) int PosSymbolIn1array=i2;
}
return(-1);
string OneSymbolMod = symbols2[PosSymbolIn1array];
int NewArraySize = ArraySize(textMod)+1;
ArrayResize(textMod,NewArraySize);
textMod[i1]=OneSymbolMod;
string textNew;
textNew=StringConcatenate(textMod[1],textMod[2]...);//собрать массив в строку вообще не могу :(
return (textNew);
}
}
I know it's wrong and I can't assemble the array into a string at all. Please help.
Some have not only a limit on the number of deals, but even a limit on the number of requests.
They are such inventors! :-))
Please help me to add (or write) a character substitution function in a string through arrays.
Have two arrays of characters:
string symbols1[] = {"a", "b", "c", "d"};string symbols2[] = {"1", "2", "3", "4"}
Tried to write a function that would replace the text badc with 2143, based on the arrays, turned out like this:
string ReplaceSymbolsInStr(string text){
string textMod[] ={""};
string symbols1[] = {"a","b","c","d"};
string symbols2[] = {"1","2","3","4"};
int textLen = StringLen(text);
for (int i1=0; i1<textLen; i1++)
{
string OneSymbol = StringSubstr(text,i1,1);
for (int i2=0; i2<ArraySize(symbols1); i2++)
{
if (symbols1[i2]==OneSymbol) int PosSymbolIn1array=i2;
}
return(-1);
string OneSymbolMod = symbols2[PosSymbolIn1array];
int NewArraySize = ArraySize(textMod)+1;
ArrayResize(textMod,NewArraySize);
textMod[i1]=OneSymbolMod;
string textNew;
textNew=StringConcatenate(textMod[1],textMod[2]...);//собрать массив в строку вообще не могу :(
return (textNew);
}
}
I know it's wrong and I can't assemble the array into a string at all. Please help.
You're supposed to have found the index of the character in the replacement array, so why create another array?
Try adding it to a plain text variable in the first loop:
string ReplaceSymbolsInStr(string text)
{string symbols1[] = {"a", "b", "c", "d"};
string symbols2[] = {"1", "2", "3", "4"};
string textNew="";
int textLen = StringLen(text);
for (int i1=0; i1<textLen; i1++)
{
string OneSymbol = StringSubstr(text,i1,1);
for (int i2=0; i2<ArraySize(symbols1); i2++)
{
if (symbols1[i2]==OneSymbol) {textNew = textNew + symbols2[ i2 ]; i2=ArraySize(symbols1) ; }
}
}
return (textNew);
}
Or it's even easier like this:
string ReplaceSymbolsInStr(string text)
{string symbols1[4] = {"a", "b", "c", "d"}; // array size by the number of symbols in it
string textNew="";
for (int i1=0; i1< StringLen(text) ; i1++)
{
string OneSymbol = StringSubstr(text,i1,1);
for (int i2=0; i2<ArraySize(symbols1); i2++)
{
if (symbols1[i2]==OneSymbol )
{
textNew = textNew + (i2+1); // the number of the symbol itself is added to the returned text
i2=ArraySize(symbols1) ; // completed the search loop
}
}
}
return (textNew);
}
Good day !
Could you please advise (or give an example link), how to send data in csv format automatically to e-mail?
Thank you.