- Sākumlapa
- Kopiena
- Programmēšana
- Need some coding advise
Edit Your Comment
Need some coding advise
Biedrs kopš
14 ieraksti
Aug 24, 2015 at 17:04
Biedrs kopš
14 ieraksti
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.
Biedrs kopš
1718 ieraksti
Aug 25, 2015 at 09:16
Biedrs kopš
1718 ieraksti
If you want to store values, you simply create global variables.
Biedrs kopš
31 ieraksti
Aug 25, 2015 at 09:30
Biedrs kopš
31 ieraksti
I agree with CrazyTrader. use a global variable.
forex_trader_25447
Biedrs kopš
131 ieraksti
Aug 25, 2015 at 10:02
Biedrs kopš
131 ieraksti
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
Biedrs kopš
131 ieraksti
Aug 25, 2015 at 10:08
(labots Aug 25, 2015 at 10:09)
Biedrs kopš
131 ieraksti
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)
Biedrs kopš
365 ieraksti
Aug 26, 2015 at 22:13
Biedrs kopš
365 ieraksti
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....
Biedrs kopš
1718 ieraksti
Aug 26, 2015 at 22:30
Biedrs kopš
1718 ieraksti
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...
Biedrs kopš
365 ieraksti
Aug 27, 2015 at 06:16
(labots Aug 27, 2015 at 06:41)
Biedrs kopš
365 ieraksti
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.
Biedrs kopš
14 ieraksti
Aug 28, 2015 at 12:12
Biedrs kopš
14 ieraksti
Wow amazing, after reading all of the above replies and coding samples I'm getting the idea of how to do it.
Thanks Ivan & theHand for the draft samples of coding and not forgetting CrazyTrader & Crazy Coder too.
Have a nice day guys.
Warmest regards.
Thanks Ivan & theHand for the draft samples of coding and not forgetting CrazyTrader & Crazy Coder too.
Have a nice day guys.
Warmest regards.
Biedrs kopš
14 ieraksti
Sep 23, 2015 at 09:55
Biedrs kopš
14 ieraksti
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.
Biedrs kopš
365 ieraksti
Sep 23, 2015 at 10:54
Biedrs kopš
365 ieraksti
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.
*Spams netiks pieļauts, un tā rezultātā var slēgt kontu.
Tip: Posting an image/youtube url will automatically embed it in your post!
Tip: Type the @ sign to auto complete a username participating in this discussion.