can anyone help me??? iam confusing n dont understand about "magic number"
Using a Magic Number allows you to tell what placed an order, a manually placed trade won't have a Magic Number. You can tell the symbol an order was placed on using OrderSymbol(), you can tell the order type, Buy or Sell, using OrderType() . . . . but you can't tell what EA placed an order or on what timeframe the order was based on.
So I use my Magic Number to tell me those 2 pieces of information, the EA number and the timeframe . . .
this is the macd that i'd modified,..
bu its not working.... ???
Gekafx,
can anyone help me??? i am confusing n don't understand about "magic number"
i want to make macd sample use in multiple chart (few chart, diferrent
pair n 1 terminal) i need everyone help.... please....
RaptorUK:
Can you be more specific about what it isn't doing or what it is doing incorrectly ?Hi Gekafx,
As Raptor indicated...there is not much information on what the problem is...so the following is just a guess based on your questions.
The key to Magic Numbers is....they have to be DIFFERENT for each EA....
In order to make this EA do that...you need to change the following code to make the Magic Number a USER setting so you can change it for each EA you use.
Here is the code you need to change:
#define MAGICNUM 140179
Change to:
extern int MAGICNUM = 140179;
* The number is just for example. Use any integer numbers you want.
Recompile your code...then run the EA on different charts...and use a different MAGICNUM setting for each EA.
Hope this helps,
Robert
can anyone help me??? iam confusing n dont understand about "magic number" i want to make macd sample use in multiple chart (few chart, diferrent pair n 1 terminal) i need everyone help.... please master.... this is the macd that i'd modified,.. bu its not working.... ??? can anyone help me to fix my problem???
As cosmicbeing suggested about magicnumbers, but this would not solve the problem of using it on one chart if thats what your trying to do
If you want to use indicators data from a separate currency pair on this chart and this particular EA then you need to change your variables or ad additional variables to reflect which pair and timeframe you wish to use such as:
MacdCurrent=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,0); //NULL means current currency pair //If you want to add additional comparisons for another currency pair then you need to change this or create another variable to include another pair //for comparison //Such as: MacdCurrent_2=iMACD("EUROUSD",0,12,26,9,PRICE_CLOSE,MODE_MAIN,0) //check string symbols for your use if this is what your trying to do //Or some other string symbol
Hope this helps
can anyone help me??? iam confusing n dont understand about "magic number"
i want to make macd sample use in multiple chart (few chart, diferrent pair n 1 terminal) i need everyone help....
this is the macd that i'd modified,.. but its not working.... ???
can anyone help me to fix my problem???
In reviewing the Magic Number problem for your MACD Sample EA...it looks like there are a few additional concerns with the Magic Number in this EA...
Besides making the Magic Number an extern USER setting...
In sending your trades...you also have to replace the "hard coded" Magic Number (16384) and change it to the MAGICNUM variable :
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,Ask+TakeProfit*Point,"macd sample",16384,0,Green); ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,Bid-TakeProfit*Point,"macd sample",16384,0,Red);Replace the "16384" with your "MAGICNUM" variable...
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,Ask+TakeProfit*Point,"macd sample",MAGICNUM,0,Green); ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,Bid-TakeProfit*Point,"macd sample",MAGICNUM,0,0,Red);
And you need to search and select your trades by the Magic Number.
The OrderSelect code below does not match the Magic Number with your trades. Add your Magic Number to the OrderSelect function below:
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if(OrderType()<=OP_SELL && // check for opened position
OrderSymbol()==Symbol()) // check for symbol
In addition... I don't know what this code function below is for...
It may be trying to do what I just suggested above - to match trades with a Magic Number?
In any case....it seems the "MagicNumberToCheck" should be exactly the same variable as your "MAGICNUM" that you set in your USER settings?----------------------
int ActiveTradesForMagicNumber(string SymbolToCheck, int MagicNumberToCheck)
{
int icnt, itotal, retval;
retval=0;
itotal=OrdersTotal();
for(icnt=0;icnt<itotal;icnt++)
{
OrderSelect(icnt, SELECT_BY_POS, MODE_TRADES);
// check for opened position, symbol & MagicNumber
if(OrderType()<=OP_SELL && OrderSymbol()==SymbolToCheck && OrderMagicNumber()==MagicNumberToCheck)
{
---------------------------
Just some more ideas to check out...
Hope this helps,
Robert
Can you be more specific about what it isn't doing or what it is doing incorrectly ?
hai Raptor uk, nice to meet you,.. thanks for the answer..., actually i dont know why the EA wont work exaclly, because, there is no sign, buy or sell... fiuuuhhh iam bleeding...:(
Hi Gekafx,
As Raptor indicated...there is not much information on what the problem is...so the following is just a guess based on your questions.
The key to Magic Numbers is....they have to be DIFFERENT for each EA....
In order to make this EA do that...you need to change the following code to make the Magic Number a USER setting so you can change it for each EA you use.
Here is the code you need to change:
#define MAGICNUM 140179
Change to:
extern int MAGICNUM = 140179;
* The number is just for example. Use any integer numbers you want.
Recompile your code...then run the EA on different charts...and use a different MAGICNUM setting for each EA.
Hope this helps,
Robert
hai Raptor uk, nice to meet you,.. thanks for the answer..., actually i dont know why the EA wont work exaclly, because, there is no sign, buy or sell... fiuuuhhh iam bleeding...:(
Hi
As cosmicbeing suggested about magicnumbers, but this would not solve the problem of using it on one chart if thats what your trying to do
If you want to use indicators data from a separate currency pair on this chart and this particular EA then you need to change your variables or ad additional variables to reflect which pair and timeframe you wish to use such as:
Hope this helps
https://docs.mql4.com/indicators/iMACD
thankyou verry much for your help agent86... but i want make it separately, just 1 ea, but it cant load in any chart and any pair, so if iwant EURUSD, i just load it into EURUSD chart, but if i dont want to trade EURUSD, ijust not load it... i hope you understand my bad english... :)
Are you running this in the Strategy Tester or a Demo or Live account ?
in live account ...
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
can anyone help me??? iam confusing n dont understand about "magic number"
i want to make macd sample use in multiple chart (few chart, diferrent pair n 1 terminal) i need everyone help.... please master....
this is the macd that i'd modified,..
bu its not working.... ???
can anyone help me to fix my problem???