Aiuto per la codifica - pagina 139

 

C'è un modo per postare correttamente un codice? La barra spaziatrice non funziona, non so perché.

 
RyuShin:
C'è un modo per postare correttamente un codice? La barra spaziatrice non funziona, non so perché.

Puoi fare come mostrato nell'immagine (incolla semplicemente il codice nella casella php)

oppure puoi allegare il codice usando il normale allegato

File:
 
mladen:
Puoi fare come mostrato nell'immagine (semplicemente incollare il codice nella casella php) o puoi allegare il codice usando il normale allegato

Il problema è che non vedo la scatola. Non ho idea del perché. Ho usato Firefox e internet explorer ma non hanno mostrato il box :/ Comunque userò un altro computer e riproverò.

 

Ok, ecco il codice per gli indicatori.

Settimanale

#property indicator_chart_window

//+------------------------------------------------------------------+

//| Custom indicator initialization function |

//+------------------------------------------------------------------+

int init()

{

//---- indicators

//----

return(0);

}

//+------------------------------------------------------------------+

//| Custom indicator deinitialization function |

//+------------------------------------------------------------------+

int deinit()

{

//----

ObjectDelete("WS1");

ObjectDelete("WS2");

ObjectDelete("WS3");

ObjectDelete("WR1");

ObjectDelete("WR2");

ObjectDelete("WR3");

ObjectDelete("WEEKLY PIVOT");

ObjectDelete("Weekly Support 1");

ObjectDelete("Weekly 2");

ObjectDelete("Weekly 3");

ObjectDelete("Weekly Pivot level");

ObjectDelete("Weekly Resistance 1");

ObjectDelete("Weekly Resistance 2");

ObjectDelete("Weekly Resistance 3");

Comment(" ");

//----

return(0);

}

//+------------------------------------------------------------------+

//| Custom indicator iteration function |

//+------------------------------------------------------------------+

int start()

{

//----

double rates[1][6],weekly_close,weekly_high,weekly_low;

ArrayCopyRates(rates, Symbol(), PERIOD_W1);

if(DayOfWeek() == 1)

{

if(TimeDayOfWeek(iTime(Symbol(),PERIOD_W1,1)) == 5)

{

weekly_close = rates[1][4];

weekly_high = rates[1][3];

weekly_low = rates[1][2];

}

else

{

for(int d = 5;d>=0;d--)

{

if(TimeDayOfWeek(iTime(Symbol(),PERIOD_W1,d)) == 5)

{

weekly_close = rates[d][4];

weekly_high = rates[d][3];

weekly_low = rates[d][2];

}

}

}

}

else

{

weekly_close = rates[1][4];

weekly_high = rates[1][3];

weekly_low = rates[1][2];

}

//---- Calculate Pivots

Comment("\nWeekly quotations:\nH ",weekly_high,"\nL ",weekly_low, "\nC ",weekly_close);

double R = weekly_high - weekly_low;//range

double wp = (weekly_high + weekly_low + weekly_close)/3;// Standard Pivot

double wr3 = wp + (R * 1.000);

double wr2 = wp + (R * 0.618);

double wr1 = wp + (R * 0.382);

double ws1 = wp - (R * 0.382);

double ws2 = wp - (R * 0.618);

double ws3 = wp - (R * 1.000);

drawLine(wr3,"WR3", LimeGreen,0);

drawLabel(" WR 3",wr3,LimeGreen);

drawLine(wr2,"WR2", LimeGreen,0);

drawLabel(" WR 2",wr2,LimeGreen);

drawLine(wr1,"WR1", LimeGreen,0);

drawLabel(" WR 1",wr1,LimeGreen);

drawLine(wp,"WEEKLY PIVOT",Black,1);

drawLabel(" WP",wp,Black);

drawLine(ws1,"WS1",Crimson,0);

drawLabel(" WS 1",ws1,Crimson);

drawLine(ws2,"WS2",Crimson,0);

drawLabel(" WS 2",ws2,Crimson);

drawLine(ws3,"WS3",Crimson,0);

drawLabel(" WS 3",ws3,Crimson);

//----

return(0);

}

//+------------------------------------------------------------------+

void drawLabel(string name,double lvl,color Color)

{

if(ObjectFind(name) != 0)

{

ObjectCreate(name, OBJ_TEXT, 0, Time[10], lvl);

ObjectSetText(name, name, 8, "Arial", EMPTY);

ObjectSet(name, OBJPROP_COLOR, Color);

}

else

{

ObjectMove(name, 0, Time[10], lvl);

}

}

void drawLine(double lvl,string name, color Col,int type)

{

if(ObjectFind(name) != 0)

{

ObjectCreate(name, OBJ_HLINE, 0, Time[0], lvl,Time[0],lvl);

if(type == 1)

ObjectSet(name, OBJPROP_STYLE, STYLE_SOLID);

else

ObjectSet(name, OBJPROP_STYLE, STYLE_DOT);

ObjectSet(name, OBJPROP_COLOR, Col);

ObjectSet(name,OBJPROP_WIDTH,1);

}

else

{

ObjectDelete(name);

ObjectCreate(name, OBJ_HLINE, 0, Time[0], lvl,Time[0],lvl);

if(type == 1)

ObjectSet(name, OBJPROP_STYLE, STYLE_SOLID);

else

ObjectSet(name, OBJPROP_STYLE, STYLE_DOT);

ObjectSet(name, OBJPROP_COLOR, Col);

ObjectSet(name,OBJPROP_WIDTH,1);

}

}[/PHP]

Monthly

[PHP]//+------------------------------------------------------------------+

#property indicator_chart_window

//+------------------------------------------------------------------+

//| Custom indicator initialization function |

//+------------------------------------------------------------------+

int init()

{

//---- indicators

//----

return(0);

}

//+------------------------------------------------------------------+

//| Custom indicator deinitialization function |

//+------------------------------------------------------------------+

int deinit()

{

//----

ObjectDelete("MS1");

ObjectDelete("MS2");

ObjectDelete("MS3");

ObjectDelete("MR1");

ObjectDelete("MR2");

ObjectDelete("MR3");

ObjectDelete("MONTHLY PIVOT");

ObjectDelete("Monthly Support 1");

ObjectDelete("Monthly 2");

ObjectDelete("Monthly 3");

ObjectDelete("Monthly Pivot level");

ObjectDelete("Monthly Resistance 1");

ObjectDelete("Monthly Resistance 2");

ObjectDelete("Monthly Resistance 3");

Comment(" ");

//----

return(0);

}

//+------------------------------------------------------------------+

//| Custom indicator iteration function |

//+------------------------------------------------------------------+

int start()

{

//----

double rates[1][6],monthly_close,monthly_high,monthly_low;

ArrayCopyRates(rates, Symbol(), PERIOD_MN1);

if(DayOfWeek() == 1)

{

if(TimeDayOfWeek(iTime(Symbol(),PERIOD_MN1,1)) == 5)

{

monthly_close = rates[1][4];

monthly_high = rates[1][3];

monthly_low = rates[1][2];

}

else

{

for(int d = 5;d>=0;d--)

{

if(TimeDayOfWeek(iTime(Symbol(),PERIOD_MN1,d)) == 5)

{

monthly_close = rates[d][4];

monthly_high = rates[d][3];

monthly_low = rates[d][2];

}

}

}

}

else

{

monthly_close = rates[1][4];

monthly_high = rates[1][3];

monthly_low = rates[1][2];

}

//---- Calculate Pivots

Comment("\nMonthly quotations:\nH ",monthly_high,"\nL ",monthly_low, "\nC ",monthly_close);

double R = monthly_high - monthly_low;//range

double mp = (monthly_high + monthly_low + monthly_close)/3;// Standard Pivot

double mr3 = mp + (R * 1.000);

double mr2 = mp + (R * 0.618);

double mr1 = mp + (R * 0.382);

double ms1 = mp - (R * 0.382);

double ms2 = mp - (R * 0.618);

double ms3 = mp - (R * 1.000);

drawLine(mr3,"MR3", Lime,0);

drawLabel(" MR 3",mr3,Lime);

drawLine(mr2,"MR2", Lime,0);

drawLabel(" MR 2",mr2,Lime);

drawLine(mr1,"MR1", Lime,0);

drawLabel(" MR 1",mr1,Lime);

drawLine(mp,"MONTHLY PIVOT",Black,1);

drawLabel(" MP",mp,Black);

drawLine(ms1,"MS1",Red,0);

drawLabel(" MS 1",ms1,Red);

drawLine(ms2,"MS2",Red,0);

drawLabel(" MS 2",ms2,Red);

drawLine(ms3,"MS3",Red,0);

drawLabel(" MS 3",ms3,Red);

//----

return(0);

}

//+------------------------------------------------------------------+

void drawLabel(string name,double lvl,color Color)

{

if(ObjectFind(name) != 0)

{

ObjectCreate(name, OBJ_TEXT, 0, Time[10], lvl);

ObjectSetText(name, name, 8, "Arial", EMPTY);

ObjectSet(name, OBJPROP_COLOR, Color);

}

else

{

ObjectMove(name, 0, Time[10], lvl);

}

}

void drawLine(double lvl,string name, color Col,int type)

{

if(ObjectFind(name) != 0)

{

ObjectCreate(name, OBJ_HLINE, 0, Time[0], lvl,Time[0],lvl);

if(type == 1)

ObjectSet(name, OBJPROP_STYLE, STYLE_SOLID);

else

ObjectSet(name, OBJPROP_STYLE, STYLE_DOT);

ObjectSet(name, OBJPROP_COLOR, Col);

ObjectSet(name,OBJPROP_WIDTH,1);

}

else

{

ObjectDelete(name);

ObjectCreate(name, OBJ_HLINE, 0, Time[0], lvl,Time[0],lvl);

if(type == 1)

ObjectSet(name, OBJPROP_STYLE, STYLE_SOLID);

else

ObjectSet(name, OBJPROP_STYLE, STYLE_DOT);

ObjectSet(name, OBJPROP_COLOR, Col);

ObjectSet(name,OBJPROP_WIDTH,1);

}

}
 
RyuShin:
Il problema è che non vedo la scatola. Non ho idea del perché. Ho usato Firefox e internet explorer ma non hanno mostrato il box :/ Comunque userò un altro computer e riproverò.

RyuShin

Non vedrai una scatola, vedrai qualcosa come questo:

e il risultato sarà questo:

paste your code here
File:
code_2.gif  35 kb
 

Ciao ragazzi,

Potete dare un'occhiata al mio codice, per favore? È molto semplice, ma non ho idea del perché non funziona come vorrei. Fondamentalmente voglio controllare se due valori consecutivi di un indicatore. Se sono uguali, disegna una freccia sulla chiusura della candela.

now=iCustom(NULL,0,"Stoch",period,5,i+1);

previous=iCustom(NULL,0,"Stoch",period,5,i+2);

if ( (now==previous))

{

CrossUp=previous;

}

[/CODE]

The code above is not showing any arrows when it should (I checked in data window)

The parameters, indicators name is all working fine because with the following code, it is showing arrows

[CODE]

now=iCustom(NULL,0,"Stoch",period,5,i+1);

previous=iCustom(NULL,0,"Stoch",period,5,i+1);

if ( (now==previous))

{

CrossUp=previous;

}

Qualcuno può aiutare perché la prima serie di codice non è la stessa?

Il valore nella finestra dei dati è lo stesso!

Grazie in anticipo!

 
yuhu:
Ciao ragazzi,

Potete dare un'occhiata al mio codice, per favore? È molto semplice, ma non ho idea del perché non funziona come vorrei. Fondamentalmente voglio controllare se due valori consecutivi di un indicatore. Se sono uguali, disegna una freccia sulla chiusura della candela.

now=iCustom(NULL,0,"Stoch",period,5,i+1);

previous=iCustom(NULL,0,"Stoch",period,5,i+2);

if ( (now==previous))

{

CrossUp=previous;

}

[/CODE]

The code above is not showing any arrows when it should (I checked in data window)

The parameters, indicators name is all working fine because with the following code, it is showing arrows

[CODE]

now=iCustom(NULL,0,"Stoch",period,5,i+1);

previous=iCustom(NULL,0,"Stoch",period,5,i+1);

if ( (now==previous))

{

CrossUp=previous;

}

Qualcuno può aiutare perché la prima serie di codice non è la stessa?

Il valore nella finestra dei dati è lo stesso!

Grazie in anticipo!

yuhu

I dati degli indicatori nella finestra dei dati vengono visualizzati solo con una precisione di 4 cifre se non definiti diversamente con la funzione IndicatorDigits(). Ciò che non viene visualizzato è la causa del fatto che non si ottiene una condizione uguale. Usa NormalizeDouble() e allora dovrebbe accadere più spesso

Usa qualcosa come questo:

if ( (NormalizeDouble(now,4)==NormalizeDouble(previous,4)))

O usa qualche altro numero invece di 4 a cui vuoi che i valori siano arrotondati

 

Misura oggettiva CSM

Ciao

Qualcuno potrebbe aiutarmi a codificare quanto segue:

Fornire un avviso quando

1 - una valuta (esempio EUR nel grafico sotto) ha valori costantemente alti su diversi timeframe, e

2 - una seconda valuta (esempio JPY nel grafico) ha valori costantemente bassi negli stessi timeframe.

Per esempio, l'allarme verrebbe mostrato se, specificando M15, M30, H1 e H4 (timeframes selezionati dall'utente),

1 - l'EUR ha tutte e quattro le letture di HiScore (una variabile, default 70) o superiore, e

2 - lo JPY ha tutte e quattro le letture di LowScore (una variabile, default 35) o meno.

(I file "hanover --- extensible functions.mgh" e "hanover --- function header.mgh" devono essere messi nella cartella experts/include per vedere il grafico correttamente. Penso che abbia anche bisogno del font "PLCC___" installato in windows, ma non ho avuto successo nel caricare quel font qui).

Grazie!

 

Grazie mille Mladen. sei un eroe

Abbi cura di te!

 

mladen, dopo che la mia metatrader ha superato le ore 0, gli indicatori pivot settimanali e mensili hanno ripreso a funzionare. Non so perché non funzionano il lunedì:/ Grazie comunque per la tua attenzione.

Motivazione: