[ARCHIVE!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Can't go anywhere without you - 4. - page 450
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
When debugging the indicator, you need to print out an array of price and time values from certain bars on the shifft.
I get all this inside the operator, of course:
Then, I transfer the price and time values to arrays in order to work with them further:
I try to print out what I already have immediately afterwards:
This is what is printed in the Expert Log:
Here we can clearly see that price values of both varsTime1[i] andvarsTime2[i] and just prices from time1 andtime2 are always 0. What's wrong?
i_maTF == Period()??????,
i_maPeriod takes a reasonable value???
Well maybe there is something wrong with i_maShiftByPrice???
It's hard to be more precise.
I understand that I don't want to speculate, but can you at least give me a hint if the problem is clear to you?
Give me all the code
No, it only means that the data matched a piece of history.
You could have entered it manually, for example. Or written from a text file. Or you could have gotten it from a calculation.
Because even by entering some conditional data "1.25 1.16 1.73 1.35" we may get the history for some currency many years ago. But that doesn't mean that we've set up an array timeseries
Tweaked the original script a bit:
1. I copied to the custom array only 5 latest opening prices.
2. Calculated the obtained custom array by all 5 copied opening prices.
Here is what I have got:
As you can see from the figure, the open prices are indexed in reverse order (as evidenced by the NUMBER of bar open prices (goes in ascending order) and TIME of bar open prices (goes in descending order)), i.e. the array is organized as an array-timeseries.
But the ArrayGetAsSeries function nevertheless returns 0 (false), which means: the user array is NOT organized as an array-timeseries.
Very kindly ask for clarity
Question: how can this be explained?
P.S. Thank you for answering my questions
Tweaked the original script a bit:
1. I copied only the last 5 opening prices into a custom array.
2. Rasprocessed the resulting custom array by all 5 copied opening prices.
Here is what I have got:
As you can see from the figure, the open prices are indexed in reverse order (as evidenced by the NUMBER of bar open prices (goes in ascending order) and TIME of bar open prices (goes in descending order)), i.e. the array is organized as an array-timeseries.
But the ArrayGetAsSeries function nevertheless returns 0 (false), which means: the user array is NOT organized as an array-timeseries.
Please clarify
Question: how to explain it?
P.S. Thank you for answering my questions.
Have you tried to use the
Have you tried the functions
i_maTF == Period() ??????
i_maPeriod takes a reasonable value???
Well maybe there is something wrong with i_maShiftByPrice???
It's hard to be more precise.
The information it outputs is not correct. Here's the full code:
The Expert Advisor's log shows this:
As you can see, the i_maTF, i_maPeriod and i_maPrice variables are not what I initialized. What's wrong?
Outputs the wrong information. Here's the full code:
The Expert log shows this:
As you can see, the variables i_maTF, i_maPeriod and i_maPrice are not the same as I initialized. What's wrong?
I wonder how you managed to get something in the log if the code you've submitted doesn't compile?
Ah, if you compile it, there won't be any weirdness.
I wonder how you managed to get anything into the log if the code you presented doesn't compile?
Ah, if you compile it, you won't get any weirdness.
I always compile normally.
I've cleaned the code of extra printers and variables so as not to confuse anyone. But I didn't remove them below, so it didn't compile. Here's the full code that compiles:
Please help! How to make an EA close an old order when opening a new one? In the Strategy Tester it works fine, but on the real account for some reason when I open a new one, the old one leaves???????? I am a total zero in programming(((
//ooooooooooooooooooooooooooooooooooooooooooooooooo
extern bool In_BUY=true;
extern int SL_buy=62; //---входные параметры по лонгам
extern int Risk_buy=0;
//ooooooooooooooooooooooooooooooooooooooooooooooooo
extern bool In_SELL=true;
extern int SL_sell=62; //---входные параметры по шортам
extern int Risk_sell=0;
//ooooooooooooooooooooooooooooooooooooooooooooooooo
//---- other parameters
static int prevtime=0;
int ticket=0;
int x=1;
//----------------------------------------------
int Magic_BUY =123;
int Magic_SELL =321;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
if(Digits == 5) x=10;
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//oooooooooooooooooooooooooooooooooooooooooooooooooooo
if (Time[0] == prevtime) return(0);
prevtime = Time[0];
if (!IsTradeAllowed()) {
prevtime=Time[1]; MathSrand(TimeCurrent());Sleep(30000 + MathRand()); //--- формировка бара---
}
//ooooooooooooooooooooooooooooooooooooooooooooooooooooOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
Trade( Magic_BUY, In_BUY,Ask,0,2, SL_buy, Risk_buy); //---торговля по лонгам
Trade(Magic_SELL,In_SELL,Bid,2,0, SL_sell,Risk_sell); //---торговля по шортам
//ooooooooooooooooooooooooooooooooooooooooooooooooooooOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
return(0);//-----------выход из стартовой функции------------
}
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
void Trade(int mn,bool flag,double price,int period_1,int period_2,int sl,int Risk) {
int total=OrdersTotal();
for (int i = 0; i < total; i++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES);//---проход по ордерам--
if (OrderSymbol() == Symbol() && OrderMagicNumber() == mn) {
if(Open[period_2]>Open[period_1]) { //----условие закрытия ордера---------
OrderClose(OrderTicket(),OrderLots(),price,5*x); RefreshRates();
}
return(0);
}
}
//ooooooooooooooooooooooooooooooooooooooooooooooooooo
ticket = -1;
if ( flag &&
Open[period_1]>Open[period_2] && //----вход в рынок по условию---
OrdersTotal()<2 && //-----ограничения чемпионата------
AccountEquity()>200 &&
IsTradeAllowed()) {
if (mn<200) {
ticket= OrderSend(Symbol(), OP_BUY,lot(Risk_buy),Ask,5,Bid-x*sl*Point,0,DoubleToStr(mn,0),mn,0,Blue);
}
else {
ticket= OrderSend(Symbol(),OP_SELL,lot(Risk_sell),Bid,5,Ask+x*sl*Point,0,DoubleToStr(mn,0),mn,0, Red);
}
RefreshRates();
if ( ticket < 0) { Sleep(30000); prevtime = Time[1]; }
} //-- Exit ---
return(0); }
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
double lot(int R) { if (R<0)R=0; if (R>80)R=80; //------корректность ввода -------
double minlot = MarketInfo(Symbol(), MODE_MINLOT);
int o = MathAbs(MathLog(minlot) *0.4343) + 0.5;
double lot = minlot;
//ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
lot = NormalizeDouble(AccountFreeMargin() * 0.00001*R, o);//---
if (AccountFreeMargin() < lot * MarketInfo(Symbol(), MODE_MARGINREQUIRED)) {
lot = NormalizeDouble(AccountFreeMargin() / MarketInfo(Symbol(), MODE_MARGINREQUIRED), o);
}
//ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
if(lot < minlot) lot = minlot;
double maxlot =MarketInfo(Symbol(), MODE_MAXLOT);
if(lot > maxlot) lot = maxlot;
return(lot); }
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx_end_film_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Or maybe write another EA which would work on the principle of 1 has opened, 2 has opened-1 has closed, 3Opened-2 has closed, etc.. Help really, really need it!!!
Please help! How to make an EA close an old order when opening a new one? In the Strategy Tester it works fine, but on the real account for some reason when I open a new one, the old one leaves???????? I have no idea whatsoever about programming((!
//ooooooooooooooooooooooooooooooooooooooooooooooooo
extern bool In_BUY=true;
extern int SL_buy=62; //---входные параметры по лонгам
extern int Risk_buy=0;
Replace
to