Download MetaTrader 5
To add comments, please log in or register
Do you wonder how to use widgets? Read the article!
ken
35
ken 2014.04.15 07:59 
Hi all,

My EA is use for analyse previous M30 candle, then to trade the pair that has highest difference, buy order on highest (Close-Open), sell order on lowest (Open -close)
I try that on demo account, but i encounter EA even executive buy order on a losing candle, which is against to my whole calculation algorithm.
I totally no idea what is happening, is that possible that may be the variable still storing previous memory and has to use Refreshrates()?? Since the EA has many argument to calculate....

double eurusdOpen= iOpen("EURUSD", PERIOD_M30, 1); 
double gbpusdOpen= iOpen("GBPUSD", PERIOD_M30, 1); 
double usdjpyOpen= iOpen("USDJPY", PERIOD_M30, 1); 
double usdchfOpen= iOpen("USDCHF", PERIOD_M30, 1); 
double usdcadOpen= iOpen("USDCAD", PERIOD_M30, 1); 
double audusdOpen=iOpen("AUDUSD", PERIOD_M30, 1); 
double nzdusdOpen=iOpen("NZDUSD", PERIOD_M30, 1); 
double eurjpyOpen=iOpen("EURJPY", PERIOD_M30, 1); 
double eurchfOpen=iOpen("EURCHF", PERIOD_M30, 1); 
double eurgbpOpen=iOpen("EURGBP", PERIOD_M30, 1); 
double audcadOpen=iOpen("AUDCAD", PERIOD_M30, 1); 
double audchfOpen=iOpen("AUDCHF", PERIOD_M30, 1); 
double audjpyOpen=iOpen("AUDJPY", PERIOD_M30, 1); 
double cadchfOpen=iOpen("CADCHF", PERIOD_M30, 1); 
double cadjpyOpen=iOpen("CADJPY", PERIOD_M30, 1); 
double chfjpyOpen=iOpen("CHFJPY", PERIOD_M30, 1); 
double nzdcadOpen=iOpen("NZDCAD", PERIOD_M30, 1); 
double nzdchfOpen=iOpen("NZDCHF", PERIOD_M30, 1); 
double nzdjpyOpen=iOpen("NZDJPY", PERIOD_M30, 1); 
double euraudOpen=iOpen("EURAUD", PERIOD_M30, 1); 
double gbpchfOpen=iOpen("GBPCHF", PERIOD_M30, 1); 
double gbpjpyOpen=iOpen("GBPJPY", PERIOD_M30, 1); 
double audnzdOpen=iOpen("AUDNZD", PERIOD_M30, 1); 
double eurcadOpen=iOpen("EURCAD", PERIOD_M30, 1); 
double eurnzdOpen=iOpen("EURNZD", PERIOD_M30, 1); 
double gbpaudOpen=iOpen("GBPAUD", PERIOD_M30, 1); 
double gbpcadOpen=iOpen("GBPCAD", PERIOD_M30, 1); 
double gbpnzdOpen=iOpen("GBPNZD", PERIOD_M30, 1); 
double eurusdClose = iClose("EURUSD", PERIOD_M30, 1); 
double gbpusdClose = iClose("GBPUSD", PERIOD_M30, 1); 
double usdjpyClose = iClose("USDJPY", PERIOD_M30, 1); 
double usdchfClose = iClose("USDCHF", PERIOD_M30, 1); 
double usdcadClose = iClose("USDCAD", PERIOD_M30, 1); 
double audusdClose = iClose("AUDUSD", PERIOD_M30, 1); 
double nzdusdClose = iClose("NZDUSD", PERIOD_M30, 1); 
double eurjpyClose = iClose("EURJPY", PERIOD_M30, 1); 
double eurchfClose = iClose("EURCHF", PERIOD_M30, 1); 
double eurgbpClose = iClose("EURGBP", PERIOD_M30, 1); 
double audcadClose = iClose("AUDCAD", PERIOD_M30, 1); 
double audchfClose = iClose("AUDCHF", PERIOD_M30, 1); 
double audjpyClose = iClose("AUDJPY", PERIOD_M30, 1); 
double cadchfClose = iClose("CADCHF", PERIOD_M30, 1); 
double cadjpyClose = iClose("CADJPY", PERIOD_M30, 1); 
double chfjpyClose = iClose("CHFJPY", PERIOD_M30, 1); 
double nzdcadClose = iClose("NZDCAD", PERIOD_M30, 1); 
double nzdchfClose = iClose("NZDCHF", PERIOD_M30, 1); 
double nzdjpyClose = iClose("NZDJPY", PERIOD_M30, 1); 
double euraudClose = iClose("EURAUD", PERIOD_M30, 1); 
double gbpchfClose = iClose("GBPCHF", PERIOD_M30, 1); 
double gbpjpyClose = iClose("GBPJPY", PERIOD_M30, 1); 
double audnzdClose = iClose("AUDNZD", PERIOD_M30, 1); 
double eurcadClose = iClose("EURCAD", PERIOD_M30, 1); 
double eurnzdClose = iClose("EURNZD", PERIOD_M30, 1); 
double gbpaudClose = iClose("GBPAUD", PERIOD_M30, 1); 
double gbpcadClose = iClose("GBPCAD", PERIOD_M30, 1); 
double gbpnzdClose = iClose("GBPNZD", PERIOD_M30, 1);
double GainUSDeurusd=(eurusdOpen-eurusdClose)*10000;
double GainUSDgbpusd=(gbpusdOpen-gbpusdClose)*10000;
double GainUSDusdjpy=(usdjpyClose-usdjpyOpen)*100;
double GainUSDusdchf=(usdchfClose-usdchfOpen)*10000;
double GainUSDusdcad=(usdcadClose-usdcadOpen)*10000;
double GainUSDaudusd=(audusdOpen-audusdClose)*10000;
double GainUSDnzdusd=(nzdusdOpen-nzdusdClose)*10000;
double GainEUReurusd=(eurusdClose-eurusdOpen)*10000;
double GainEUReurjpy=(eurjpyClose-eurjpyOpen)*100;
double GainEUReurchf=(eurchfClose-eurchfOpen)*10000;
double GainEUReurgbp=(eurgbpClose-eurgbpOpen)*10000;
double GainEUReuraud=(euraudClose-euraudOpen)*10000;
double GainEUReurcad=(eurcadClose-eurcadOpen)*10000;
double GainEUReurnzd=(eurnzdClose-eurnzdOpen)*10000;
double GainGBPgbpusd=(gbpusdClose-gbpusdOpen)*10000;
double GainGBPeurgbp=(eurgbpOpen-eurgbpClose)*10000;
double GainGBPgbpchf=(gbpchfClose-gbpchfOpen)*10000;
double GainGBPgbpjpy=(gbpjpyClose-gbpjpyOpen)*100;
double GainGBPgbpaud=(gbpaudClose-gbpaudOpen)*10000;
double GainGBPgbpcad=(gbpcadClose-gbpcadOpen)*10000;
double GainGBPgbpnzd=(gbpnzdClose-gbpnzdOpen)*10000;
double GainCHFusdchf=(usdchfOpen-usdchfClose)*10000;
double GainCHFeurchf=(eurchfOpen-eurchfClose)*10000;
double GainCHFaudchf=(audchfOpen-audchfClose)*10000;
double GainCHFcadchf=(cadchfOpen-cadchfClose)*10000;
double GainCHFchfjpy=(chfjpyClose-chfjpyOpen)*100;
double GainCHFnzdchf=(nzdchfOpen-nzdchfClose)*10000;
double GainCHFgbpchf=(gbpchfOpen-gbpchfClose)*10000;
double GainCADusdcad=(usdcadOpen-usdcadClose)*10000;
double GainCADaudcad=(audcadOpen-audcadClose)*10000;
double GainCADcadchf=(cadchfClose-cadchfOpen)*10000;
double GainCADcadjpy=(cadjpyClose-cadjpyOpen)*100;
double GainCADnzdcad=(nzdcadOpen-nzdcadClose)*10000;
double GainCADeurcad=(eurcadOpen-eurcadClose)*10000;
double GainCADgbpcad=(gbpcadOpen-gbpcadClose)*10000;
double GainAUDaudusd=(audusdClose-audusdOpen)*10000;
double GainAUDaudcad=(audcadClose-audcadOpen)*10000;
double GainAUDaudchf=(audchfClose-audchfOpen)*10000;
double GainAUDaudjpy=(audjpyClose-audjpyOpen)*100;
double GainAUDeuraud=(euraudOpen-euraudClose)*10000;
double GainAUDaudnzd=(audnzdClose-audnzdOpen)*10000;
double GainAUDgbpaud=(gbpaudOpen-gbpaudClose)*10000;
double GainJPYusdjpy=(usdjpyOpen-usdjpyClose)*100;
double GainJPYeurjpy=(eurjpyOpen-eurjpyClose)*100;
double GainJPYaudjpy=(audjpyOpen-audjpyClose)*100;
double GainJPYcadjpy=(cadjpyOpen-cadjpyClose)*100;
double GainJPYchfjpy=(chfjpyOpen-chfjpyClose)*100;
double GainJPYnzdjpy=(nzdjpyOpen-nzdjpyClose)*100;
double GainJPYgbpjpy=(gbpjpyOpen-gbpjpyClose)*100;
double GainNZDnzdusd=(nzdusdClose-nzdusdOpen)*10000;
double GainNZDnzdcad=(nzdcadClose-nzdcadOpen)*10000;
double GainNZDnzdchf=(nzdchfClose-nzdchfOpen)*10000;
double GainNZDnzdjpy=(nzdjpyClose-nzdjpyOpen)*100;
double GainNZDaudnzd=(audnzdOpen-audnzdClose)*10000;
double GainNZDeurnzd=(eurnzdOpen-eurnzdClose)*10000;
double GainNZDgbpnzd=(gbpnzdOpen-gbpnzdClose)*10000;
Sergey Golubev
Moderator
52147
Sergey Golubev 2014.04.15 08:09  

use SRC :


ken
35
ken 2014.04.15 11:37  

newdigital...done insert code..

anybody can help on my problem...i am scratching my head now....

whroeder1
13637
whroeder1 2014.04.15 12:18  
razordota: I totally no idea what is happening, is that possible that may be the variable still storing previous memory and has to use Refreshrates()??
  1. Refreshrates won't do anything for any other pair
  2. There's no way for us to know either since you haven't posted any code that does anything.
  3. Add print statements, dump your variable values, your entries into and out of your if statements and tract it down.
SYED NAUFAL GADDAFI
1401
SYED NAUFAL GADDAFI 2014.04.15 12:27  

razordota


If you want help, show us your code and we will help you if it is not too much of help.

ken
35
ken 2014.04.15 12:53  

Hi WHRoeder & deysmacro

i'm shy as a newbie in EA, i compiled it into 2000 overlines... May be some function really useless, and i should use user-defined function to shorten the code, but i have no idea... coz i'm still in learning curve...haha

Pls refer attachment for my code. As stated, i found the EA has false calculation, and i find the martingale option doesn't work as well.

Pls help and thanks in advance... Thank you!!!

Files:
whroeder1
13637
whroeder1 2014.04.15 13:18  
  1. Humans cant read ex4's. We can only read CODE.
  2. Market values from our broker won't match your broker.
  3. #3
ken
35
ken 2014.04.15 13:24  
WHRoeder:
  1. Humans cant read ex4's. We can only read CODE.
  2. Market values from our broker won't match your broker.
  3. #3


Hi WHRoeder,

Sorry, i thought i should attach the file since my EA has thousands line.

SRC not allow me to post my code here since the text is too long....

SYED NAUFAL GADDAFI
1401
SYED NAUFAL GADDAFI 2014.04.15 13:49  
Attach mq4. No more harder than to attach ex4 right?
ken
35
ken 2014.04.15 13:53  
deysmacro:
Attach mq4. No more harder than to attach ex4 right?

Hi deysmacro,

Here u go, sorry...i'm totally newbie

Files:
SYED NAUFAL GADDAFI
1401
SYED NAUFAL GADDAFI 2014.04.15 16:29  
Now you just need to wait for someone with spare time to look at your code and help if possible and not too much of help.
/
To add comments, please log in or register