[Qualsiasi domanda da principiante, per non ingombrare il forum. Professionisti, non passate oltre. Da nessuna parte senza di te - 4. - pagina 449
Ti stai perdendo delle opportunità di trading:
- App di trading gratuite
- Oltre 8.000 segnali per il copy trading
- Notizie economiche per esplorare i mercati finanziari
Registrazione
Accedi
Accetti la politica del sito e le condizioni d’uso
Se non hai un account, registrati
Capisco che non voglio speculare, ma puoi almeno darmi un suggerimento se il problema ti è chiaro?
Dammi tutto il codice
No, significa solo che i dati corrispondono a un pezzo di storia.
Avresti potuto inserirlo manualmente, per esempio. O scritto da un file di testo. O potrebbe averla ottenuta da un calcolo.
Perché anche inserendo alcuni dati condizionali "1,25 1,16 1,73 1,35" potremmo ottenere la storia di qualche valuta molti anni fa. Ma questo non significa che abbiamo impostato una serie temporale di array
Ho modificato un po' lo script originale:
1. Ho copiato solo 5 ultimi prezzi di apertura in un array personalizzato.
2. Calcolato l'array personalizzato ottenuto da tutti e 5 i prezzi di apertura copiati.
Ecco cosa ho ottenuto:
Come si può vedere dalla figura, i prezzi aperti sono indicizzati in ordine inverso (come evidenziato dal NUMERO dei prezzi aperti delle barre (va in ordine crescente) e dal TEMPO dei prezzi aperti delle barre (va in ordine decrescente)), cioè l'array è organizzato come un array-timeseries.
Ma la funzione ArrayGetAsSeries restituisce comunque 0 (falso), il che significa: l'array utente NON è organizzato come un array-tempi.
Chiedo molto gentilmente di fare chiarezza
Domanda: come si può spiegare questo?
P.S. Grazie per aver risposto alle mie domande
Ho modificato un po' lo script originale:
1. Ho copiato solo gli ultimi 5 prezzi di apertura in un array personalizzato.
2. Ras ha elaborato l'array personalizzato risultante per tutti e 5 i prezzi di apertura copiati.
Ecco cosa ho ottenuto:
Come si può vedere dalla figura, i prezzi aperti sono indicizzati in ordine inverso (come evidenziato dal NUMERO dei prezzi aperti delle barre (va in ordine crescente) e dal TEMPO dei prezzi aperti delle barre (va in ordine decrescente)), cioè l'array è organizzato come un array-timeseries.
Ma la funzione ArrayGetAsSeries restituisce comunque 0 (falso), il che significa: l'array utente NON è organizzato come un array-tempi.
Si prega di chiarire
Domanda: come spiegarlo?
P.S. Grazie per aver risposto alle mie domande.
Avete provato a usare il
Avete provato le funzioni
i_maTF == Periodo() ??????
i_maPeriod prende un valore ragionevole???
Beh, forse c'è qualcosa di sbagliato in i_maShiftByPrice?
È difficile essere più precisi.
Le informazioni che emette non sono corrette. Ecco il codice completo:
Il registro di Expert Advisor mostra questo:
Come potete vedere, le variabili i_maTF, i_maPeriod e i_maPrice non sono quelle che ho inizializzato. Cosa c'è che non va?
Emette un'informazione sbagliata. Ecco il codice completo:
Il registro di Expert mostra questo:
Come potete vedere, le variabili i_maTF, i_maPeriod e i_maPrice non sono le stesse che ho inizializzato. Cosa c'è che non va?
Mi chiedo come hai fatto ad avere qualcosa nel log se il codice che hai inviato non si compila?
Ah, se lo compili, non ci sarà nessuna stranezza.
Mi chiedo come hai fatto a mettere qualcosa nel log se il codice che hai presentato non si compila?
Ah, se lo compili, non avrai nessuna stranezza.
Compilo sempre normalmente.
Ho pulito il codice da stampanti e variabili extra per non confondere nessuno. Ma non li ho rimossi sotto, quindi non ha compilato. Ecco il codice completo che compila:
Per favore, aiutatemi! Come fare in modo che un EA chiuda un vecchio ordine quando ne apre uno nuovo? Nello Strategy Tester funziona bene, ma sul conto reale per qualche motivo quando ne apro uno nuovo, il vecchio se ne va???????? Sono uno zero totale nella programmazione(((
//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
O forse scrivere un altro EA che lavorerebbe sul principio di 1 ha aperto, 2 ha aperto-1 ha chiuso, 3 ha aperto-2 ha chiuso, ecc. Aiuto davvero, davvero bisogno!!!
Per favore, aiutatemi! Come fare in modo che un EA chiuda un vecchio ordine quando ne apre uno nuovo? Nello Strategy Tester funziona bene, ma sul conto reale per qualche motivo quando ne apro uno nuovo, il vecchio se ne va???????? Non ho nessuna idea di programmazione((!
//ooooooooooooooooooooooooooooooooooooooooooooooooo
extern bool In_BUY=true;
extern int SL_buy=62; //---входные параметры по лонгам
extern int Risk_buy=0;
Sostituire
a
Il mio obiettivo in questa fase è capire come funziona questa o quella funzione, e in questo caso particolare, come funziona la funzione ArrayGetAsSeries. Ho capito che si può usare la funzione ArraySetAsSeries con il parametro set=true, che imposta forzatamente l'indicizzazione, come in array-timeseries. Ma voglio capire perché nel mio caso la funzione ArrayGetAsSeries ha restituito 0, nonostante l'array sembri una serie temporale (cioè indicizzato come una serie temporale)
Proprio perché si spiega solo come una serie temporale.
Questa è solo la tua opinione personale. E se ci metti i numeri 1, 2, 1.2, 2.1, ti ritrovi con una serie temporale per il maiale dal 1927 (i numeri sono condizionati). Ma questo non rende l'array una serie temporale - è necessario specificarlo esplicitamente con la funzione