Errors, bugs, questions - page 1141
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello all !
Such a problem.
I successfully get the value of Bands and MA indicators.
Bands_handle=iBands(NULL,0,BP_var_s,0,BDev_var_s,PRICE_CLOSE);CopyBuffer(Bands_handle,0,0,1,Base);
CopyBuffer(Bands_handle,1,0,1,Upper);
CopyBuffer(Bands_handle,2,0,1,Lower);
B_med_s=Base[0];
B_up_s=Upper[0];
B_low_s=Lower[0];
MA_handle=iMA(NULL,0,MA_var_b,0,MODE_SMA,PRICE_TYPICAL);
CopyBuffer(MA_handle,0,0,1,MAv);
M_av_s=MAv[0];
Then print: B_up_s = 1.264249475876921 M_av_s = 1.2595
Then I try to perform a matrix operation B_up_s-M_av_s and get the result 0.00000000.
What is the miracle?
Hello all !
Such a problem.
I successfully get the value of Bands and MA indicators.
CopyBuffer(Bands_handle,0,0,1,Base);
CopyBuffer(Bands_handle,1,0,1,Upper);
CopyBuffer(Bands_handle,2,0,1,Lower);
B_med_s=Base[0];
B_up_s=Upper[0];
B_low_s=Lower[0];
MA_handle=iMA(NULL,0,MA_var_b,0,MODE_SMA,PRICE_TYPICAL);
CopyBuffer(MA_handle,0,0,1,MAv);
M_av_s=MAv[0];
Then print: B_up_s = 1.264249475876921 M_av_s = 1.2595
Then I try to perform a B_up_s-M_av_s mate operation and get 0.00000000 as a result.
What's so strange?
1) How to insert the code.
2) In what type variable do you store the result of the operation? Or better yet, please give me the part of the code where the output is produced.
1) How do you insert the code.
2) What type of variable do you store the result of the operation in? Better yet, give the part of the code where the output is produced.
All variables are of type double.
I do not understand why Bands has many digits while MA has only 4 decimal places. There should not be a zero result at all. This is why the algorithm does not work.
Everything was so simple in MQL4. Now you need higher optimization speed and multicurrency checking. I have to transfer everything to MQL5 (screw it)).
All variables are of type double.
It is not clear why Bands has many digits and MA only 4 decimal places. And zero result should not be there at all. This is the reason why the algorithm does not work.
Everything was so simple in MQL4. Now you need higher optimization speed and multicurrency checking. Now I have to transfer everything to MQL5 (screw it)).
It should work. Below is a script based on your code and its result:
All variables are of type double.
It is not clear why Bands has many digits and MA only 4 decimal places. The result of zero should not be there at all. This is why the algorithm does not work.
Everything was so simple in MQL4. Now you need higher optimization speed and multicurrency checking. I have to transfer everything to MQL5 (screw it)).
It should work. Below is the script according to your code and its result:
Yes, the script works.
Even the EA with this example works.
My EA, on the other hand, is giving out zero stubbornly. Let's look for an error ......
Hi all!
Question, how to make a variable value to be updated on each tick in a minute, and then this sum is written to a separate value, when the next minute closes, the value of the sum is replaced by the new one?
int t = TimeSeconds();
while (t !=0)
double b - the variable, which is updated during every minute on every tick.
double b1 - value of variable b on the previous tick.
double s - amount on all ticks within one minute.
double s1 - amount on all ticks within the previous minute.
b1=b;
s=b1+b;
if (t=0) s1=s;
How to make data summarize on every tick and how to write it all correctly in general?
Yes, the script works.
Even the EA with this example works.
But my Expert Advisor gives zero. Let's look for error ......
Here is what has been detected.
If you just run the EA, it works fine but in the Strategy Tester it produces zeros at the very beginning. But in the next line zeros magically become a normal indicator data. I don't understand what's going on.....
Below is the code.
This is what the tester reports.
CJ 0 19:40:47.022 Core 1 EURUSD,M15 (Alpari-Ltd-Demo): OHLC bar states generating. OnTick execution on the bar begin only
IJ 0 19:40:47.022 Core 1 EURUSD,M15: testing of experts\tmp.ex5 from 2004.01.07 00:00 to 2004.02.02 00:00 started
LK 0 19:40:47.022 Core 1 2004.01.07 00:00:00 B_up_s=0.0 M_av_s=0.0
IM 0 19:40:47.022 Core 1 2004.01.07 00:00:00 sbl_top=true B_up_s=0.0 M_av_s=0.0 B_up_s-M_av_s=0.00000000
OQ 0 19:40:47.022 Core 1 2004.01.07 00:15:00 B_up_s=1.279208140152992 M_av_s=1.2718
OI 0 19:40:47.022 Core 1 2004.01.07 00:15:00 sel=true B_up_s=1.279208140152992 M_av_s=1.2718 B_up_s-M_av_s=0.00740814
CJ 0 19:40:47.022 Core 1 2004.01.07 00:30:00 B_up_s=1.279239651523307 M_av_s=1.2721
LN 0 19:40:47.022 Core 1 2004.01.07 00:45:00 B_up_s=1.279382808470771 M_av_s=1.2714
DS 0 19:40:47.022 Core 1 2004.01.07 01:00:00 B_up_s=1.279407737043184 M_av_s=1.2719
OD 0 19:40:47.022 Core 1 2004.01.07 01:15:00 B_up_s=1.279398917431485 M_av_s=1.2727
NI 0 19:40:47.022 Core 1 2004.01.07 01:30:00 B_up_s=1.279380702214008 M_av_s=1.2731
IM 0 19:40:47.022 Core 1 2004.01.07 01:45:00 B_up_s=1.279440208228416 M_av_s=1.2723
LE 0 19:40:47.022 Core 1 2004.01.07 02:00:00 B_up_s=1.279473515350084 M_av_s=1.272
DK 0 19:40:47.022 Core 1 2004.01.07 02:15:00 B_up_s=1.279515146590278 M_av_s=1.2715
FL 0 19:40:47.022 Core 1 2004.01.07 02:30:00 B_up_s=1.279601656250741 M_av_s=1.2709
IQ 0 19:40:47.022 Core 1 2004.01.07 02:45:00 B_up_s=1.279656914787522 M_av_s=1.2709
CE 0 19:40:47.022 Core 1 2004.01.07 03:00:00 B_up_s=1.279579626541548 M_av_s=1.2707
Here's what has been discovered.
1) Do not create indicators on every tick!
2) Check whether the indicator was created or not, before accessing its values.
3) Check if the requested values are copied from the indicator.
4) Always delete the calculation part of the indicator after the completion of the expert, otherwise it may at some point run out of RAM.
The problem was because you tried to copy the values from the indicator which hasn't been created yet. Make it a rule - check the result of the functions you call.
Please advise where the error is.
Ekpert is running on demo, 3 pairs. Here is the Log:
Here is the code.
Expert tries to execute OrderDelete(), gives error, SendTradeRequest() is in while loop, ekspert accordingly loops. Maybe the price has changed when I submitted the order? Do I need RefreshRates() and how to deal with it correctly? I searched in forum but found no example...
Thank you all in advance