- घर
- कम्युनिटी
- प्रोग्रामिंग
- Need some coding advise
Edit Your Comment
Need some coding advise
तबसे मेंबर है May 02, 2012
14 पोस्टों
Aug 24, 2015 at 17:04
तबसे मेंबर है May 02, 2012
14 पोस्टों
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
1718 पोस्टों
Aug 25, 2015 at 09:16
तबसे मेंबर है Nov 21, 2011
1718 पोस्टों
If you want to store values, you simply create global variables.
तबसे मेंबर है Sep 06, 2011
31 पोस्टों
Aug 25, 2015 at 09:30
तबसे मेंबर है Sep 06, 2011
31 पोस्टों
I agree with CrazyTrader. use a global variable.
forex_trader_25447
तबसे मेंबर है Dec 21, 2010
131 पोस्टों
Aug 25, 2015 at 10:02
तबसे मेंबर है Dec 21, 2010
131 पोस्टों
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
131 पोस्टों
Aug 25, 2015 at 10:08
(एडिट हो रहा है Aug 25, 2015 at 10:09)
तबसे मेंबर है Dec 21, 2010
131 पोस्टों
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)
तबसे मेंबर है Sep 20, 2014
365 पोस्टों
Aug 26, 2015 at 22:13
तबसे मेंबर है Sep 20, 2014
365 पोस्टों
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
1718 पोस्टों
Aug 26, 2015 at 22:30
तबसे मेंबर है Nov 21, 2011
1718 पोस्टों
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...
तबसे मेंबर है Sep 20, 2014
365 पोस्टों
Aug 27, 2015 at 06:16
(एडिट हो रहा है Aug 27, 2015 at 06:41)
तबसे मेंबर है Sep 20, 2014
365 पोस्टों
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
14 पोस्टों
Aug 28, 2015 at 12:12
तबसे मेंबर है May 02, 2012
14 पोस्टों
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.
तबसे मेंबर है May 02, 2012
14 पोस्टों
Sep 23, 2015 at 09:55
तबसे मेंबर है May 02, 2012
14 पोस्टों
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 20, 2014
365 पोस्टों
Sep 23, 2015 at 10:54
तबसे मेंबर है Sep 20, 2014
365 पोस्टों
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.
*व्यवसायिक इस्तेमाल और स्पैम को ब्रदाश नहीं किया जाएगा, और इसका परिणाम खाता को बन्द करना भी हो सकता है.
टिप: किसी चित्र या यूट्यूब या URL को पोस्ट करने से वे अपने आप आपके पोस्ट में आजाएगा!
टिप: @ चिन्ह को टाइप करें उपभोगता के नाम को अपने आप करने के लिए जो इस चर्चा में भाग ले रहा है.