Questions from Beginners MQL5 MT5 MetaTrader 5 - page 967 1...960961962963964965966967968969970971972973974...1605 New comment ilvic 2018.12.21 12:12 #9661 How do I get the opening price of a bar right and if I fail to get the opening price to exit? Sketched out a few options. But maybe there is a better and more correct code? if(iOpen(Symbol(),Period(),0)==0) { return; } { if(iOpen(Symbol(),Period(),0)!=0) { double open=iOpen(Symbol(),Period(),0); } } if(iOpen(Symbol(),Period(),0)==0.0) { return; } { if(iOpen(Symbol(),Period(),0)!=0.0) { double open=iOpen(Symbol(),Period(),0); } } if(iOpen(Symbol(),Period(),0)==0 && iOpen(Symbol(),Period(),0)==0.0) { return; } { if(iOpen(Symbol(),Period(),0)!=0 && iOpen(Symbol(),Period(),0)!=0.0) { double open=iOpen(Symbol(),Period(),0); } } Vladimir Karputov 2018.12.21 12:23 #9662 ilvic: How do I get the opening price of a bar right and if I fail to get the opening price to exit? Sketched out a few options. But maybe there is a better and more correct code? The iXXXX functions only make sense if you are running a one-time request, without loops and without calling any other iXXXX functions. If you only need to get the opening price once, then seeiOpen's help: Return value*** 0 in case of error. So you need to query the price and check if it is zero: if it is not zero then the price is received, if it is zero then it is an error. double open=iOpen(Symbol(),Period(),0); if(open==0.0) retutn; Why this function takes Trying to wite a Any rookie question, so xxz 2018.12.21 12:30 #9663 Can you please tell me how to insert parameter 9 with a grid (#CL) so that the compiler won't generate an error?enum Symboll_ { AUDUSD=0, NZDUSD=1, USDCAD=2, USDCHF=3, USDJPY=4, EURJPY=5, EURUSD=6, GBPUSD=7, #CL =8 }; ilvic 2018.12.21 12:30 #9664 Vladimir Karputov: The iXXXX functions only make sense if you are running a one-time request, without cycles and without calling any other iXXXX functions. If you only need to get the opening price once, seeiOpen help: Return value*** 0 in case of error. So you need to query the price and check that it is zero: if it is not zero then the price is received, if it is zero then it is an error. Thank you. One more question. Should we use parentheses in this code or it makes no difference? double open=iOpen(Symbol(),Period(),0); if(open==0.0) { return; } Vladimir Karputov 2018.12.21 12:33 #9665 xxz: Can you please tell me how to insert the 9 parameter with a grid (#CL) so that the compiler doesn't generate an error?Like this: enum MySymbol { symbol_0=0,// AUDUSD symbol_1=1,// NZDUSD symbol_2=2,// USDCAD symbol_3=3,// USDCHF symbol_4=4,// USDJPY symbol_5=5,// EURJPY symbol_6=6,// EURUSD symbol_7=7,// GBPUSD symbol_8=8,// #CL }; Konstantin Nikitin 2018.12.21 12:39 #9666 ilvic: Thank you. One more question. Should brackets be used in this code or does it make no difference? double open=iOpen(Symbol(),Period(),0); if(open==0.0) return;It will do. Generally speaking, brackets are intended for a group of actions. If there is only one action, they are of no use. int n; double y; if(бла-бла-бла) n = бла-бла; else { n = бла-бла; y = бла; ) xxz 2018.12.21 12:39 #9667 Vladimir Karputov: There you go: Thank you very much! Because I tried it like this and it didn't work: enum Symboll_ { SIM_0, //AUDUSD SIM_1, //NZDUSD SIM_2, //USDCAD SIM_3, //USDCHF SIM_4, //USDJPY SIM_5, //EURJPY SIM_6, //EURUSD SIM_7 //#CL }; Vladimir Karputov 2018.12.21 12:40 #9668 xxz: Thank you very much! Because I tried it like this and it didn't work: Or like this: enum MySymbol { symbol_0=0,// AUDUSD symbol_1=1,// NZDUSD symbol_2=2,// USDCAD symbol_3=3,// USDCHF symbol_4=4,// USDJPY symbol_5=5,// EURJPY symbol_6=6,// EURUSD symbol_7=7,// GBPUSD symbol_8=8,// #CL }; string my_symbol[9]= { "AUDUSD", "NZDUSD", "USDCAD", "USDCHF", "USDJPY", "EURJPY", "EURUSD", "GBPUSD", "#CL" }; xxz 2018.12.21 12:51 #9669 Vladimir Karputov: or this: That's the one! In those variants it came out either just a serial number orSIM_1,...etc. [Deleted] 2018.12.21 14:28 #9670 When testing a multi-currency EA, there is a problem with the lot size. I have a fixed 0.03, but during the test the orders appear with the volume of 0.1. Immediately a failure appears on the chart. Is it just me? Does the Grail exist? iRSIOnArray Issues MT4 Strategy Tester 1...960961962963964965966967968969970971972973974...1605 New comment
How do I get the opening price of a bar right and if I fail to get the opening price to exit?
Sketched out a few options. But maybe there is a better and more correct code?
How do I get the opening price of a bar right and if I fail to get the opening price to exit?
Sketched out a few options. But maybe there is a better and more correct code?
The iXXXX functions only make sense if you are running a one-time request, without loops and without calling any other iXXXX functions.
If you only need to get the opening price once, then seeiOpen's help:
Return value
*** 0 in case of error.
So you need to query the price and check if it is zero: if it is not zero then the price is received, if it is zero then it is an error.
enum Symboll_ { AUDUSD=0, NZDUSD=1, USDCAD=2, USDCHF=3, USDJPY=4, EURJPY=5, EURUSD=6, GBPUSD=7, #CL =8 };The iXXXX functions only make sense if you are running a one-time request, without cycles and without calling any other iXXXX functions.
If you only need to get the opening price once, seeiOpen help:
Return value
*** 0 in case of error.
So you need to query the price and check that it is zero: if it is not zero then the price is received, if it is zero then it is an error.
Thank you. One more question. Should we use parentheses in this code or it makes no difference?
Can you please tell me how to insert the 9 parameter with a grid (#CL) so that the compiler doesn't generate an error?
Like this:
Thank you. One more question. Should brackets be used in this code or does it make no difference?
It will do. Generally speaking, brackets are intended for a group of actions. If there is only one action, they are of no use.
There you go:
Thank you very much!
Because I tried it like this and it didn't work:
enum Symboll_ { SIM_0, //AUDUSD SIM_1, //NZDUSD SIM_2, //USDCAD SIM_3, //USDCHF SIM_4, //USDJPY SIM_5, //EURJPY SIM_6, //EURUSD SIM_7 //#CL };Thank you very much!
Because I tried it like this and it didn't work:
Or like this:
or this:
That's the one!
In those variants it came out either just a serial number orSIM_1,...etc.