Aiuto per la codifica - pagina 507

 
tristantsh:
Grazie mntiwana e malden. ma perché devo comprare di nuovo? Puoi inviare questi indicatori in messaggi

Invia l'email originale con il link che hai ricevuto quando hai comprato quell'indicatore a support@for ex-tsd.com e, se tutto è corretto, riceverai una versione aggiornata.

 

Ok mlanden. ma l'indicatore prima di nmc sembra interessante che dopo nmc. È solo la mia sensazione?

 
tristantsh:
Ok mlanden. ma l'indicatore prima di nmc sembra interessante che dopo nmc. E 'solo le mie sensazioni?

I risultati della versione "nmc" non sono affatto cambiati rispetto alla versione "pre-nmc". "nmc" sta per "new metatrader compatible"

tutto il meglio

 

Perché?

Mladen,

Per favore puoi darmi il motivo per cui questo ea non funziona.

//----------------------- PARAMETRO EA

stringa esterna

Expert_Name = "---------- Pending Order EA v1",

Expert_Name2 = "---------- Per il prezzo corrente impostare EntryLevel = 0";

extern double

EntryLevel = 1.8600,

Distance = 100,

StopLoss = 50,

TakeProfit = 50,

TrailingStop = 50;

stringa esterna

Order_Setting = "---------- Impostazione ordine";

extern int

NumberOfTries = 5,

Slippage = 5,

MagicNumber = 1234;

extern string

MM_Parameters = "---------- Money Management";

extern double

Lotti =0.01;

extern bool

MM = false, //Usa o no il Money Management

AccountIsMicro = true; //Utilizzare o meno il Micro-Account

extern int

Risk = 0; //10%

extern string

Testing_Parameters= "---------- Back Test Parameter";

extern bool

Show_Settings = true;

//----------------------- VARIABILE GLOBALE

int statico

TimeFrame = 0;

string

TicketComment = "PendingOrderEA v2",

LastTrade;

bool

TradeAllow = true,

EntryAllow = true;

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

//| funzione di inizializzazione dell'esperto |

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

int init()

{

//----------------------- GENERA IL NUMERO MAGICO E IL COMMENTO DEL BIGLIETTO

//----------------------- FONTE: PENGIE

MagicNumber = subGenerateMagicNumber(MagicNumber, Symbol(), Period());

TicketComment = StringConcatenate(TicketComment, "-", Symbol(), "-", Period());

//----------------------- MOSTRA LE IMPOSTAZIONI DI EA SUL GRAFICO

//----------------------- FONTE: CODERSGURU

if(Show_Settings) subPrintDetails();

else Comment("");

return(0);

}

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

//| funzione di deinizializzazione esperto |

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

int deinit()

{

//----------------------- PREVIENE IL RICONTEGGIO MENTRE L'UTENTE CAMBIA L'INTERVALLO DI TEMPO

//----------------------- FONTE: CODERSGURU

TimeFrame=Periodo();

return(0);

}

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

//| |

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

int start()

{

double

// BuyLevel,

SellLevel;

int

cnt,

ticket,

totale;

//----------------------- imposta il prezzo di acquisto e di vendita

if(EntryLevel==0) EntryLevel = Bid;

// BuyLevel = EntryLevel + Distance*Point;

SellLevel = EntryLevel - Distance*Point;

// if((BuyLevel-Ask)<10*Point || (Bid-SellLevel)<10*Point)

// {

// Comment("Invalid Entry Price or Distance");

// return(0);

// }

//----------------------- REGOLARE I LOTTI SE SI USA IL MONEY MANAGEMENT

if(MM) Lots = subLotSize();

//----------------------- ENTRY

//----------------------- ORDINE TOTALE IN BASE A MAGICNUMBER E SIMBOLO

total = subTotalTrade();

//----------------------- IMPOSTARE L'ORDINE SOLO 1 VOLTA

if(TradeAllow)

{

//----------------------- SE NESSUNA TRATTATIVA

if(total<1 && EntryAllow)

{

ticket = OrderSend(Symbol(),OP_SELLSTOP,Lotti,SellLevel,Slippage,SellLevel+StopLoss*Point,SellLevel-TakeProfit*Point,TicketComment,MagicNumber,0,Red);

// ticket = OrderSend(Symbol(),OP_BUYSTOP,Lots,BuyLevel,Slippage,BuyLevel-StopLoss*Point,BuyLevel+TakeProfit*Point,TicketComment,MagicNumber,0,Green);

EntryAllow = false;

return(0);

}

se(totale==1)

{

subDeleteOrder();

TradeAllow = false;

}

}

//----------------------- SEZIONE TRAILING STOP

if(TrailingStop>0 && subTotalTrade()>0)

{

totale = OrdiniTotali();

for(cnt=0;cnt<totale;cnt++)

{

OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);

if(OrderType()<=OP_SELL &&

OrderSymbol()==Symbol() &&

OrderMagicNumber()==MagicNumber)

{

subTrailingStop(OrderType());

return(0);

}

}

}

return(0);

}

//----------------------- FINE PROGRAMMA

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

//|DEFINIZIONI DI FUNZIONI

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

//----------------------- FUNZIONE DI GESTIONE DEL DENARO

//----------------------- FONTE: CODERSGURU

doppio subLotSize()

{

double lotMM = MathCeil(AccountFreeMargin() * Risk / 1000) / 100;

if(AccountIsMicro==false) //conto normale

{

if(lotMM < 0,1) lotMM = Lotti;

if((lotMM > 0.5) && (lotMM < 1)) lotMM = 0.5;

se(lotMM > 1.0) lotMM = MathCeil(lotMM);

se(lotMM > 100) lotMM = 100;

}

else //micro conto

{

se(lotMM < 0,01) lotMM = Lotti;

se(lotMM > 1,0) lotMM = MathCeil(lotMM);

se(lotMM > 100) lotMM = 100;

}

return (lotMM);

}

//----------------------- NUMERO DI ORDINI IN BASE AL SIMBOLO E ALLA FUNZIONE MAGICNUMBER

int subTotalTrade()

{

int

cnt,

totale = 0;

for(cnt=0;cnt<OrdiniTotali();cnt++)

{

OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);

if(OrderType()<=OP_SELL &&

OrderSymbol()==Symbol() &&

OrderMagicNumber()==MagicNumber) total++;

}

return(totale);

}

//----------------------- FUNZIONE CANCELLA ORDINE

void subDeleteOrder()

{

int

cnt,

totale = 0;

totale = OrdiniTotali();

for(cnt=totale-1;cnt>=0;cnt--)

{

OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);

if(OrderSymbol()==Symbol() &&

OrderMagicNumber()==MagicNumber)

{

switch(OrderType())

{

// caso OP_BUYLIMIT :

// caso OP_BUYSTOP :

caso OP_SELLLIMIT:

caso OP_SELLSTOP :

OrderDelete(OrderTicket());

}

}

}

}

//----------------------- FUNZIONE TRAILING STOP

//----------------------- FONTE: CODERSGURU

//----------------------- MODIFICATO : FIREDAVE

void subTrailingStop(int Type)

{

if(Type==OP_BUY) // la posizione buy è aperta

{

if(Bid-OrderOpenPrice()>Point*TrailingStop &&

OrderStopLoss()<Bid-Point*TrailingStop)

{

OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green);

return(0);

}

}

if(Type==OP_SELL) // la posizione di vendita è aperta

{

if(OrderOpenPrice()-Ask>Point*TrailingStop)

{

if(OrderStopLoss()>Ask+Point*TrailingStop || OrderStopLoss()==0)

{

OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red);

return(0);

}

}

}

}

//----------------------- GENERA IL NUMERO MAGICO IN BASE AL SIMBOLO E ALLA FUNZIONE TIME FRAME

//----------------------- FONTE: PENGIE

//----------------------- MODIFICATO : FIREDAVE

int subGenerateMagicNumber(int MagicNumber, string symbol, int timeFrame)

{

int isymbol = 0;

if (symbol == "EURUSD") isymbol = 1;

else if (symbol == "GBPUSD") isymbol = 2

else if (symbol == "USDJPY") isymbol = 3

else if (symbol == "AUDCAD") isymbol = 4

else if (symbol == "AUDUSD") isymbol = 5

else if (symbol == "USDCAD") isymbol = 6

else if (symbol == "EURGBP") isymbol = 7

else if (symbol == "EURJPY") isymbol = 8

else if (symbol == "EURCHF") isymbol = 9

else if (symbol == "EURAUD") isymbol = 10

else if (symbol == "EURCAD") isymbol = 11

else if (symbol == "GBPUSD") isymbol = 12

else if (symbol == "GBPJPY") isymbol = 13

else if (symbol == "GBPCHF") isymbol = 14

else if (symbol == "GBPAUD") isymbol = 15

else if (symbol == "GBPCAD") isymbol = 16;

altrimenti isymbol = 17;

if(isymbol<10) MagicNumber = MagicNumber * 10;

return (StrToInteger(StringConcatenate(MagicNumber, isymbol, timeFrame));

}

//----------------------- STAMPARE LA FUNZIONE DI COMMENTO

//----------------------- FONTE: CODERSGURU

void subPrintDetails()

{

stringa sCommento = "";

stringa sp = "----------------------------------------\n";

stringa NL = "\n";

sCommento = sp;

sComment = sComment + "TakeProfit=" + DoubleToStr(TakeProfit,0) + " | ";

sComment = sComment + "TrailingStop=" + DoubleToStr(TrailingStop,0) + " | ";

sComment = sComment + "StopLoss=" + DoubleToStr(StopLoss,0) + NL;

sComment = sComment + sp;

sComment = sComment + "Lots=" + DoubleToStr(Lots,2) + " | ";

sComment = sComment + "MM=" + subBoolToStr(MM) + " | ";

sComment = sComment + "Risk=" + DoubleToStr(Risk,0) + "%" + NL;

sComment = sComment + sp;

Commento(sCommento);

}

//----------------------- FUNZIONE DA VARIABILE BOOLEN A STRINGA

//----------------------- FONTE: CODERSGURU

stringa subBoolToStr ( bool value)

{

if(value) return ("True");

else return ("Falso");

}

//----------------------- FINE FUNZIONE

Grazie in anticipo.

Jo

 

mladen,

spero che tu stia bene. il seguente ha due errori sulla compilazione. gentilmente assistere

File:
 
candyman752:
mladen, spero che tu stia bene. il seguente ha due errori durante la compilazione.

candyman752

Prova ora: rstochalert-4tf_1.mq4

File:
 

Carissimo MLADEN,

(le mie domande sono sempre di aiuto nella riparazione più che di aiuto nella codifica)

Ho una richiesta per capire.....vedi le 2 immagini che ho aggiunto, la prima è con 1 errore e 2 avvertimenti riguardanti le linee 70 e 72....come puoi vedere nella seconda immagine, ho sostituito e 1 errore e 1 avvertimento rimossi......la mia domanda è...è giusto fare in questo modo....e la seconda domanda sul secondo avvertimento che è ancora indietro alla linea 80...se lasciato com'è, nessun problema di funzionamento?

saluti

mntiwana

 
mntiwana:
Carissimo MLADEN,

(le mie domande sono sempre di aiuto alla riparazione più che di aiuto alla codifica)

Ho una richiesta per capire.....vedi le 2 immagini che ho aggiunto, la prima è con 1 errore e 2 avvertimenti riguardanti le linee 70 e 72....come puoi vedere nella seconda immagine, ho sostituito e rimosso 1 errore e 1 avvertimento......la mia domanda è...è giusto fare in questo modo....e la seconda domanda riguarda il secondo avvertimento che è ancora indietro alla linea 80...se lasciato com'è, nessun problema di funzionamento?

saluti

mntiwana

mntiwana

in questo modo tutto è OK. hai fatto le modifiche OK

 
mladen:
mntiwana in questo modo tutto è OK. hai fatto le modifiche OK

così tanto grazie grande capo per incoraggiare uno studente curioso.

i miei migliori saluti

 
Jovager:
Mladen,

Per favore potete darmi la ragione per cui questo ea non funziona.

//----------------------- PARAMETRO EA

stringa esterna

Expert_Name = "---------- Pending Order EA v1",

Expert_Name2 = "---------- Per il prezzo corrente impostare EntryLevel = 0";

extern double

EntryLevel = 1.8600,

Distance = 100,

StopLoss = 50,

TakeProfit = 50,

TrailingStop = 50;

stringa esterna

Order_Setting = "---------- Impostazione ordine";

extern int

NumberOfTries = 5,

Slippage = 5,

MagicNumber = 1234;

extern string

MM_Parameters = "---------- Money Management";

extern double

Lotti =0.01;

extern bool

MM = false, //Usa o no il Money Management

AccountIsMicro = true; //Utilizzare o meno il Micro-Account

extern int

Risk = 0; //10%

extern string

Testing_Parameters= "---------- Back Test Parameter";

extern bool

Show_Settings = true;

//----------------------- VARIABILE GLOBALE

int statico

TimeFrame = 0;

string

TicketComment = "PendingOrderEA v2",

LastTrade;

bool

TradeAllow = true,

EntryAllow = true;

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

//| funzione di inizializzazione dell'esperto |

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

int init()

{

//----------------------- GENERA IL NUMERO MAGICO E IL COMMENTO DEL BIGLIETTO

//----------------------- FONTE: PENGIE

MagicNumber = subGenerateMagicNumber(MagicNumber, Symbol(), Period());

TicketComment = StringConcatenate(TicketComment, "-", Symbol(), "-", Period());

//----------------------- MOSTRA LE IMPOSTAZIONI DI EA SUL GRAFICO

//----------------------- FONTE: CODERSGURU

if(Show_Settings) subPrintDetails();

else Comment("");

return(0);

}

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

//| funzione di deinizializzazione esperto |

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

int deinit()

{

//----------------------- PREVIENE IL RICONTEGGIO MENTRE L'UTENTE CAMBIA L'INTERVALLO DI TEMPO

//----------------------- FONTE: CODERSGURU

TimeFrame=Periodo();

return(0);

}

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

//| |

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

int start()

{

double

// BuyLevel,

SellLevel;

int

cnt,

ticket,

totale;

//----------------------- imposta il prezzo di acquisto e di vendita

if(EntryLevel==0) EntryLevel = Bid;

// BuyLevel = EntryLevel + Distance*Point;

SellLevel = EntryLevel - Distance*Point;

// if((BuyLevel-Ask)<10*Point || (Bid-SellLevel)<10*Point)

// {

// Comment("Invalid Entry Price or Distance");

// return(0);

// }

//----------------------- REGOLARE I LOTTI SE SI USA IL MONEY MANAGEMENT

if(MM) Lots = subLotSize();

//----------------------- ENTRY

//----------------------- ORDINE TOTALE IN BASE A MAGICNUMBER E SIMBOLO

total = subTotalTrade();

//----------------------- IMPOSTARE L'ORDINE SOLO 1 VOLTA

if(TradeAllow)

{

//----------------------- SE NESSUNA TRATTATIVA

if(total<1 && EntryAllow)

{

ticket = OrderSend(Symbol(),OP_SELLSTOP,Lotti,SellLevel,Slippage,SellLevel+StopLoss*Point,SellLevel-TakeProfit*Point,TicketComment,MagicNumber,0,Red);

// ticket = OrderSend(Symbol(),OP_BUYSTOP,Lots,BuyLevel,Slippage,BuyLevel-StopLoss*Point,BuyLevel+TakeProfit*Point,TicketComment,MagicNumber,0,Green);

EntryAllow = false;

return(0);

}

se(totale==1)

{

subDeleteOrder();

TradeAllow = false;

}

}

//----------------------- SEZIONE TRAILING STOP

if(TrailingStop>0 && subTotalTrade()>0)

{

totale = OrdiniTotali();

for(cnt=0;cnt<totale;cnt++)

{

OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);

if(OrderType()<=OP_SELL &&

OrderSymbol()==Symbol() &&

OrderMagicNumber()==MagicNumber)

{

subTrailingStop(OrderType());

return(0);

}

}

}

return(0);

}

//----------------------- FINE PROGRAMMA

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

//|DEFINIZIONI DI FUNZIONE

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

//----------------------- FUNZIONE DI GESTIONE DEL DENARO

//----------------------- FONTE: CODERSGURU

doppio subLotSize()

{

double lotMM = MathCeil(AccountFreeMargin() * Risk / 1000) / 100;

if(AccountIsMicro==false) //conto normale

{

if(lotMM < 0,1) lotMM = Lotti;

if((lotMM > 0.5) && (lotMM < 1)) lotMM = 0.5;

se(lotMM > 1.0) lotMM = MathCeil(lotMM);

se(lotMM > 100) lotMM = 100;

}

else //micro conto

{

se(lotMM < 0,01) lotMM = Lotti;

se(lotMM > 1,0) lotMM = MathCeil(lotMM);

se(lotMM > 100) lotMM = 100;

}

return (lotMM);

}

//----------------------- NUMERO DI ORDINI IN BASE AL SIMBOLO E ALLA FUNZIONE MAGICNUMBER

int subTotalTrade()

{

int

cnt,

totale = 0;

for(cnt=0;cnt<OrdiniTotali();cnt++)

{

OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);

if(OrderType()<=OP_SELL &&

OrderSymbol()==Symbol() &&

OrderMagicNumber()==MagicNumber) total++;

}

return(totale);

}

//----------------------- FUNZIONE CANCELLA ORDINE

void subDeleteOrder()

{

int

cnt,

totale = 0;

totale = OrdiniTotali();

for(cnt=totale-1;cnt>=0;cnt--)

{

OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);

if(OrderSymbol()==Symbol() &&

OrderMagicNumber()==MagicNumber)

{

switch(OrderType())

{

// caso OP_BUYLIMIT :

// caso OP_BUYSTOP :

caso OP_SELLLIMIT:

caso OP_SELLSTOP :

OrderDelete(OrderTicket());

}

}

}

}

//----------------------- FUNZIONE TRAILING STOP

//----------------------- FONTE: CODERSGURU

//----------------------- MODIFICATO : FIREDAVE

void subTrailingStop(int Type)

{

if(Type==OP_BUY) // la posizione buy è aperta

{

if(Bid-OrderOpenPrice()>Point*TrailingStop &&

OrderStopLoss()<Bid-Point*TrailingStop)

{

OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green);

return(0);

}

}

if(Type==OP_SELL) // la posizione di vendita è aperta

{

if(OrderOpenPrice()-Ask>Point*TrailingStop)

{

if(OrderStopLoss()>Ask+Point*TrailingStop || OrderStopLoss()==0)

{

OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red);

return(0);

}

}

}

}

//----------------------- GENERA IL NUMERO MAGICO IN BASE AL SIMBOLO E ALLA FUNZIONE TIME FRAME

//----------------------- FONTE: PENGIE

//----------------------- MODIFICATO : FIREDAVE

int subGenerateMagicNumber(int MagicNumber, string symbol, int timeFrame)

{

int isymbol = 0;

if (symbol == "EURUSD") isymbol = 1;

else if (symbol == "GBPUSD") isymbol = 2

else if (symbol == "USDJPY") isymbol = 3

else if (symbol == "AUDCAD") isymbol = 4

else if (symbol == "AUDUSD") isymbol = 5

else if (symbol == "USDCAD") isymbol = 6

else if (symbol == "EURGBP") isymbol = 7

else if (symbol == "EURJPY") isymbol = 8

else if (symbol == "EURCHF") isymbol = 9

else if (symbol == "EURAUD") isymbol = 10

else if (symbol == "EURCAD") isymbol = 11

else if (symbol == "GBPUSD") isymbol = 12

else if (symbol == "GBPJPY") isymbol = 13

else if (symbol == "GBPCHF") isymbol = 14

else if (symbol == "GBPAUD") isymbol = 15

else if (symbol == "GBPCAD") isymbol = 16;

altrimenti isymbol = 17;

if(isymbol<10) MagicNumber = MagicNumber * 10;

return (StrToInteger(StringConcatenate(MagicNumber, isymbol, timeFrame));

}

//----------------------- STAMPARE LA FUNZIONE DI COMMENTO

//----------------------- FONTE: CODERSGURU

void subPrintDetails()

{

stringa sCommento = "";

stringa sp = "----------------------------------------\n";

stringa NL = "\n";

sCommento = sp;

sComment = sComment + "TakeProfit=" + DoubleToStr(TakeProfit,0) + " | ";

sComment = sComment + "TrailingStop=" + DoubleToStr(TrailingStop,0) + " | ";

sComment = sComment + "StopLoss=" + DoubleToStr(StopLoss,0) + NL;

sComment = sComment + sp;

sComment = sComment + "Lots=" + DoubleToStr(Lots,2) + " | ";

sComment = sComment + "MM=" + subBoolToStr(MM) + " | ";

sComment = sComment + "Risk=" + DoubleToStr(Risk,0) + "%" + NL;

sComment = sComment + sp;

Commento(sCommento);

}

//----------------------- FUNZIONE DA VARIABILE BOOLEN A STRINGA

//----------------------- FONTE: CODERSGURU

stringa subBoolToStr ( bool value)

{

if(value) return ("True");

else return ("Falso");

}

//----------------------- FINE FUNZIONE

Grazie in anticipo.

Jo

Jo,

Puoi per favore allegare il file mq4? Molto difficile da testare in questo modo

Motivazione: