Edit Your Comment
Need some coding advise
會員從May 02, 2012開始
15帖子
Aug 24, 2015 at 17:04
會員從May 02, 2012開始
15帖子
Hi everybody,
I wanted to modify some of the codes from my existing EA.
I'm wondering if there's any Angels out there who is willing to help :)
1st : I need the EA to memorize/store the pair symbol(s) for further analysis
-------------------------------------------------------------------------------------------------------
{
if (abc > xyz)
{
string rberPair=MarketInfo(Symbol); // I need a code to remember the pair symbol(s) for other execution out from this loop. There'll be up to 28 symbols to memorize if condition met.
} IS THIS CORRECT? If not, anyone care to provide some guidance? Thanks
}
===============================================================================
2nd : After getting the Symbols,
--------------------------------------------
// this is the outer loop for further analysis and execution
if rberPair >1; // I need to check that if there's symbol exist, then proceed with the below analysis
{
if def>ghi
{buy(rberPair)
since buy order has been placed, I need to erase this symbol from the (rberPair) slot
Appreciate if anyone could draft me the coding.
Thanking you in advance for your time and kindness.
Have a nice day.
I wanted to modify some of the codes from my existing EA.
I'm wondering if there's any Angels out there who is willing to help :)
1st : I need the EA to memorize/store the pair symbol(s) for further analysis
-------------------------------------------------------------------------------------------------------
{
if (abc > xyz)
{
string rberPair=MarketInfo(Symbol); // I need a code to remember the pair symbol(s) for other execution out from this loop. There'll be up to 28 symbols to memorize if condition met.
} IS THIS CORRECT? If not, anyone care to provide some guidance? Thanks
}
===============================================================================
2nd : After getting the Symbols,
--------------------------------------------
// this is the outer loop for further analysis and execution
if rberPair >1; // I need to check that if there's symbol exist, then proceed with the below analysis
{
if def>ghi
{buy(rberPair)
since buy order has been placed, I need to erase this symbol from the (rberPair) slot
Appreciate if anyone could draft me the coding.
Thanking you in advance for your time and kindness.
Have a nice day.
會員從Nov 21, 2011開始
1601帖子

forex_trader_25447
會員從Dec 21, 2010開始
127帖子
Aug 25, 2015 at 10:02
會員從Dec 21, 2010開始
127帖子
All your writing is full of errors !!!
You define rberPair as string , then compare rberPair to Integer.
MarketInfo have 2 parameters , one is _Symbol (or Symbol()) , you not enter second.
Mine idea is :
1.1 You have to define a list of Symbol, you are going to use, alike :
string MySymbol[28] = {Simbol00,...,Symbol27} // SymbolIndex= from 0 to 27
1.2 Then You can select Symbol this way :
string rberPair=MySymbol[SymbolIndex]; // SymbolIndex= from 0 to 27
2.1 Where you want to search Symbol :
- in selected (MySymbol) // on of 28
- or in Market Watch // did you know what is this
2.2 or the easy way : Your program lines must be like this :
{ string rberPair=""; // main program varible
...
rberPair=""; // OnInit section : no selected Symbol ;
...
// Main program
{ if (abc > xyz) string rberPair=MySymbol[SymbolIndex]; // here select Symbol by SymbolIndex
....
if ( rberPair!="" )
if ( def>ghi ) { buy(rberPair); rberPair="";} // deselect Symbol when order BUY placed
}
}
You define rberPair as string , then compare rberPair to Integer.
MarketInfo have 2 parameters , one is _Symbol (or Symbol()) , you not enter second.
Mine idea is :
1.1 You have to define a list of Symbol, you are going to use, alike :
string MySymbol[28] = {Simbol00,...,Symbol27} // SymbolIndex= from 0 to 27
1.2 Then You can select Symbol this way :
string rberPair=MySymbol[SymbolIndex]; // SymbolIndex= from 0 to 27
2.1 Where you want to search Symbol :
- in selected (MySymbol) // on of 28
- or in Market Watch // did you know what is this
2.2 or the easy way : Your program lines must be like this :
{ string rberPair=""; // main program varible
...
rberPair=""; // OnInit section : no selected Symbol ;
...
// Main program
{ if (abc > xyz) string rberPair=MySymbol[SymbolIndex]; // here select Symbol by SymbolIndex
....
if ( rberPair!="" )
if ( def>ghi ) { buy(rberPair); rberPair="";} // deselect Symbol when order BUY placed
}
}

forex_trader_25447
會員從Dec 21, 2010開始
127帖子
Aug 25, 2015 at 10:08
(已編輯Aug 25, 2015 at 10:09)
會員從Dec 21, 2010開始
127帖子
GlobalVariable in Terminal are used to store information when Terminal restarted. (computer is off)
.... that is not what he need.
He simply need to select Symbol in one part (function) of the program,
and use it in other part (function)
.... that is not what he need.
He simply need to select Symbol in one part (function) of the program,
and use it in other part (function)
Aug 26, 2015 at 22:13
會員從Sep 20, 2014開始
342帖子
I agree with Ivan.
You want to use a list of pairs, and lists are arrays. So lets say I want to go through a list of 2 pairs and do something, say print if the condition is met, it be something like this in Metatrader:
string Symbols[2]={"EURUSD","GBPUSD"};
for (int j = 0; j < ArraySize(Symbols); j++){
if (Symbol() == Symbols[j]){
Print ("Symbol is ", Symbols[j]);
}
}
So in this example if you ran your code on a chart and Symbol() returns either EURUSD or GBPUSD it will print it. Viola. Working with a list. Expand at will....
You want to use a list of pairs, and lists are arrays. So lets say I want to go through a list of 2 pairs and do something, say print if the condition is met, it be something like this in Metatrader:
string Symbols[2]={"EURUSD","GBPUSD"};
for (int j = 0; j < ArraySize(Symbols); j++){
if (Symbol() == Symbols[j]){
Print ("Symbol is ", Symbols[j]);
}
}
So in this example if you ran your code on a chart and Symbol() returns either EURUSD or GBPUSD it will print it. Viola. Working with a list. Expand at will....
會員從Nov 21, 2011開始
1601帖子
Aug 26, 2015 at 22:30
會員從Nov 21, 2011開始
1601帖子
I think he wants to compare past data with live data.
Let's say 10 min ago or 1 hour ago... what was the price at specific time?
Using global var is still the easiest way to perform this requirement...
Global var can be updated whenever condiions are met at some point... Later on, To open trade or not, he probably wants to identify the speed of Price action...
Let's say 10 min ago or 1 hour ago... what was the price at specific time?
Using global var is still the easiest way to perform this requirement...
Global var can be updated whenever condiions are met at some point... Later on, To open trade or not, he probably wants to identify the speed of Price action...
Aug 27, 2015 at 06:16
(已編輯Aug 27, 2015 at 06:41)
會員從Sep 20, 2014開始
342帖子
Still don't see why you'd need a global variable.
Do the array of pairs, then do the arrays of data. The data is already stored, no need to send it to a global variable. Just call it with functions. iClose or iOpen or any of those will call historic data points.
Only time I've ever had to use a global variable is if more than one EA is referencing data or I'm running more than 1 EA on an account.
Obviously coding is like painting. It's a very individual thing and all methods are correct. Some might be prettier than others, but at the end of the day its still a painting.
All my work runs on arrays as outlined above. So easy to dump or add pairs. Can have 1000 lines of code I simply add the pair to the array and even better, on my API I simply added an array of account numbers. So if I trade 1 account or 1000, 1 pair or 100, makes almost no difference.
Do the array of pairs, then do the arrays of data. The data is already stored, no need to send it to a global variable. Just call it with functions. iClose or iOpen or any of those will call historic data points.
Only time I've ever had to use a global variable is if more than one EA is referencing data or I'm running more than 1 EA on an account.
Obviously coding is like painting. It's a very individual thing and all methods are correct. Some might be prettier than others, but at the end of the day its still a painting.
All my work runs on arrays as outlined above. So easy to dump or add pairs. Can have 1000 lines of code I simply add the pair to the array and even better, on my API I simply added an array of account numbers. So if I trade 1 account or 1000, 1 pair or 100, makes almost no difference.
會員從May 02, 2012開始
15帖子
會員從May 02, 2012開始
15帖子
Sep 23, 2015 at 09:55
會員從May 02, 2012開始
15帖子
Hi guys,
I need to bug you all again for another help, hope you guys don't mind 😁,
My intention is to get the bpat or spat >=2 but somehow, it's still executing trade even with 1. I noticed that the previous programmer is not utilizing the "lastbardpt", is this the reason?
if(UsePatternCheck)
{
bpatternM5=false;
spatternM5=false;
find=0;
bpat=0;
spat=0;
lastbardpt=0;
for(d=1;d<=100;d++)
{
if(CheckLongM5(pair,5,d))
{
bpat++;
find++;
}
if(CheckShortM5(pair,5,d))
{
spat++;
find++;
}
if(find==2) break;
}
if(bpat>=2) bpatternM5=true;
if(spat>=2) spatternM5=true;
}
Thanking you in advance for your time and kind assistance.
Warmest regards.
I need to bug you all again for another help, hope you guys don't mind 😁,
My intention is to get the bpat or spat >=2 but somehow, it's still executing trade even with 1. I noticed that the previous programmer is not utilizing the "lastbardpt", is this the reason?
if(UsePatternCheck)
{
bpatternM5=false;
spatternM5=false;
find=0;
bpat=0;
spat=0;
lastbardpt=0;
for(d=1;d<=100;d++)
{
if(CheckLongM5(pair,5,d))
{
bpat++;
find++;
}
if(CheckShortM5(pair,5,d))
{
spat++;
find++;
}
if(find==2) break;
}
if(bpat>=2) bpatternM5=true;
if(spat>=2) spatternM5=true;
}
Thanking you in advance for your time and kind assistance.
Warmest regards.
Sep 23, 2015 at 10:54
會員從Sep 20, 2014開始
342帖子
I think you're missing "else"...
if(CheckLongM5(pair,5,d))
{
bpat++;
find++;
} else {
if(CheckShortM5(pair,5,d))
{
spat++;
find++;
}
The way you have it both conditions can be true at the same time. With the else you can have only one condition true at a time.
Print your values everywhere. See what they return after each action.
if(CheckLongM5(pair,5,d))
{
bpat++;
find++;
} else {
if(CheckShortM5(pair,5,d))
{
spat++;
find++;
}
The way you have it both conditions can be true at the same time. With the else you can have only one condition true at a time.
Print your values everywhere. See what they return after each action.

*商業用途和垃圾郵件將不被容忍,並可能導致帳戶終止。
提示:發佈圖片/YouTube網址會自動嵌入到您的帖子中!
提示:鍵入@符號,自動完成參與此討論的用戶名。