Aiuto per la codifica - pagina 439

 
neverbeast:
Ciao di nuovo.

Così ho fatto un semplice indicatore con le frecce. Sfortunatamente non le disegna come volevo. Il mio obiettivo era mostrare una freccia quando le condizioni sono soddisfatte, ma quando le condizioni non sono più soddisfatte dovrebbe cancellare quella freccia. Per esempio: In 15 secondi della candela corrente le condizioni sono soddisfatte e disegna una freccia poi ha cambiato direzione e le condizioni non sono più soddisfatte quindi dovrebbe cancellare quella freccia prima della chiusura della candela corrente. Attualmente disegna le frecce quando le condizioni sono soddisfatte e non ridisegna affatto, in più ci sono frecce di scadenza che mostrano se è andato ITM o OTM/ATM che non disegnano affatto fino al refresh. Qualcuno può dare un'occhiata e aiutarmi a risolvere il problema, per favore?

6s.mq4

Non hai affatto un controllo per i primi 15 secondi nel codice. Perché non aggiungi anche questo controllo?

 
mladen:
Non hai affatto un controllo per i primi 15 secondi nel codice. Perché non aggiungi anche questo controllo

Colpa mia. Era un'altra versione dell'indicatore che stavo descrivendo qui. Comunque sono un principiante nella codifica di mql4 e non ho idea di come farlo. Puoi scrivere quel pezzo di codice con un piccolo tutorial su come funziona?

 
neverbeast:
Colpa mia. Era un'altra versione dell'indicatore che stavo descrivendo qui. Comunque sono un novellino nel codificare mql4 e non ho idea di come fare. Potresti scrivere quel pezzo di codice con un piccolo tutorial su come funziona?

Potete fare così:

se (TimeCurrent()-Time[0])>15) return(0);

Mettetelo all'inizio della procedura start() (come prima linea in essa) e impedirà al resto del codice di essere eseguito se il numero di secondi passati dall'inizio della candela corrente è maggiore di 15

 

Ho il codice per un EA ma le mie competenze sono .....none. Ho provato a compilarlo, a togliere i bug ma senza fortuna.

Qualcuno può aiutarmi?

//|$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // Price Action V1 // hodhabi@gmail.com //|$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ #define NL "\n" extern double Lots = 1; extern double TP = 100; extern int TradeType = 0; // 0 per seguire il trend, 1 per comprare forzatamente, 2 per vendere extern int leverage = 5; extern double MaximumLossinMoney = 1000; extern int MagicNumber = 250346; extern bool UseAlerts = false; //+-------------+ //| Custom init | //|-------------+ int init() { } //+----------------+ //| Custom DE-init | //+----------------+ int deinit() { } void sendEmail() { if (UseAlerts==true) SendMail("YTF Alert", "Nuovo ordine aggiunto "+OrdersTotal()+" Balance = " +AccountBalance() + " Equity = "+AccountEquity() +" Current Price: " + Close[0]); return; } void DrawHorizentalLine() { ObjectCreate("TProfit", OBJ_HLINE, 0, Time[1], Close[0]+500*Point); ObjectSet("Tprofit", OBJPROP_STYLE, STYLE_SOLID); ObjectSet("Tprofit", OBJPROP_COLOR, MediumSeaGreen); } //+------------------------------------------------------------------------+ //| Chiude tutto //+------------------------------------------------------------------------+ void CloseAll() { for(int i=OrdersTotal()-1;i>=0;i--) { OrderSelect(i, SELECT_BY_POS); bool result = false; if ( OrderType() == OP_BUY && OrderMagicNumber()== MagicNumber) result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, Red ); if ( OrderType() == OP_SELL && OrderMagicNumber()==MagicNumber) result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 5, Red ); if (UseAlerts) PlaySound("alert.wav"); } return; } void CloseAllBuy() { for(int i=OrdersTotal()-1;i>=0;i--) { OrderSelect(i, SELECT_BY_POS); bool result = false; if ( OrderType() == OP_BUY && OrderMagicNumber()==MagicNumber) result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, Red ); if (UseAlerts) PlaySound("alert.wav"); } return; } void CloseAllSell() { for(int i=OrdersTotal()-1;i>=0;i--) { OrderSelect(i, SELECT_BY_POS); bool result = false; if ( OrderType() == OP_SELL && OrderMagicNumber()==MagicNumber) result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 5, Red ); if (UseAlerts) PlaySound("alert.wav"); } return; } //+------------------------------------------------------------------------+ //| annulla tutti gli ordini che sono in profitto //+------------------------------------------------------------------------+ //+------------------------------------------------------------------------+ //| annulla tutti gli ordini in sospeso //+------------------------------------------------------------------------+ //+-----------+ //| Main | //+-----------+ int start() { int OrdersBUY, ticket; int OrdersSELL; double BuyLots, SellLots, BuyProfit, SellProfit; //+------------------------------------------------------------------+ // Determinare l'ultimo prezzo dell'ordine | //-------------------------------------------------------------------+ if(OrdersTotal()==0 && TradeType ==1 ) { ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-TP*Point,Ask+leverage*TP*Point, "MLTrendETF",MagicNumber,0,Green); TradeType=2; if(ticket>0) { if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) sendEmail(); } else Print("Error opening BUY order : ",GetLastError()); return(0); } if(OrdersTotal()==0 && TradeType ==2) { ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Bid+TP*Point,Bid-TP*leverage*Point, "MLTrendETF",MagicNumber,0,Green); TradeType = 1; if(ticket>0) { if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) sendEmail(); } else Print("Error opening BUY order : ",GetLastError()); return(0); } } // start()

 

Scusate, qui non è tutto confuso

//|$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // Price Action V1 // hodhabi@gmail.com //|$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ #define NL "\n" extern double Lots = 1; extern double TP = 100; extern int TradeType = 0; // 0 per seguire il trend, 1 per comprare forzatamente, 2 per vendere extern int leverage = 5; extern double MaximumLossinMoney = 1000; extern int MagicNumber = 250346; extern bool UseAlerts = false; //+-------------+ //| Custom init | //|-------------+ int init() { } //+----------------+ //| Custom DE-init | //+----------------+ int deinit() { } void sendEmail() { if (UseAlerts==true) SendMail("YTF Alert", "Nuovo ordine aggiunto "+OrdersTotal()+" Balance = " +AccountBalance() + " Equity = "+AccountEquity() +" Current Price: " + Close[0]); return; } void DrawHorizentalLine() { ObjectCreate("TProfit", OBJ_HLINE, 0, Time[1], Close[0]+500*Point); ObjectSet("Tprofit", OBJPROP_STYLE, STYLE_SOLID); ObjectSet("Tprofit", OBJPROP_COLOR, MediumSeaGreen); } //+------------------------------------------------------------------------+ //| Chiude tutto //+------------------------------------------------------------------------+ void CloseAll() { for(int i=OrdersTotal()-1;i>=0;i--) { OrderSelect(i, SELECT_BY_POS); bool result = false; if ( OrderType() == OP_BUY && OrderMagicNumber()== MagicNumber) result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, Red ); if ( OrderType() == OP_SELL && OrderMagicNumber()==MagicNumber) result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 5, Red ); if (UseAlerts) PlaySound("alert.wav"); } return; } void CloseAllBuy() { for(int i=OrdersTotal()-1;i>=0;i--) { OrderSelect(i, SELECT_BY_POS); bool result = false; if ( OrderType() == OP_BUY && OrderMagicNumber()==MagicNumber) result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, Red ); if (UseAlerts) PlaySound("alert.wav"); } return; } void CloseAllSell() { for(int i=OrdersTotal()-1;i>=0;i--) { OrderSelect(i, SELECT_BY_POS); bool result = false; if ( OrderType() == OP_SELL && OrderMagicNumber()==MagicNumber) result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 5, Red ); if (UseAlerts) PlaySound("alert.wav"); } return; } //+------------------------------------------------------------------------+ //| annulla tutti gli ordini che sono in profitto //+------------------------------------------------------------------------+ //+------------------------------------------------------------------------+ //| annulla tutti gli ordini in sospeso //+------------------------------------------------------------------------+ //+-----------+ //| Main | //+-----------+ int start() { int OrdersBUY, ticket; int OrdersSELL; double BuyLots, SellLots, BuyProfit, SellProfit; //+------------------------------------------------------------------+ // Determinare l'ultimo prezzo dell'ordine | //-------------------------------------------------------------------+ if(OrdersTotal()==0 && TradeType ==1 ) { ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-TP*Point,Ask+leverage*TP*Point, "MLTrendETF",MagicNumber,0,Green); TradeType=2; if(ticket>0) { if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) sendEmail(); } else Print("Error opening BUY order : ",GetLastError()); return(0); } if(OrdersTotal()==0 && TradeType ==2) { ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Bid+TP*Point,Bid-TP*leverage*Point, "MLTrendETF",MagicNumber,0,Green); TradeType = 1; if(ticket>0) { if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) sendEmail(); } else Print("Error opening BUY order : ",GetLastError()); return(0); } } // start()

 
godrich:
Scusa, qui non è tutto confuso //|$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // Price Action V1 // hodhabi@gmail.com //|$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ #define NL "\n" extern double Lots = 1; extern double TP = 100; extern int TradeType = 0; // 0 per seguire il trend, 1 per forzare l'acquisto, 2 per forzare la vendita extern int leverage = 5; extern double MaximumLossinMoney = 1000; extern int MagicNumber = 250346; extern bool UseAlerts = false; //+-------------+ //| Custom init | //|-------------+ int init() { } //+----------------+ //| Custom DE-init | //+----------------+ int deinit() { } void sendEmail() { if (UseAlerts==true) SendMail("YTF Alert", "Nuovo ordine aggiunto "+OrdersTotal()+" Balance = " +AccountBalance() + " Equity = "+AccountEquity() +" Current Price: " + Close[0]); return; } void DrawHorizentalLine() { ObjectCreate("TProfit", OBJ_HLINE, 0, Time[1], Close[0]+500*Point); ObjectSet("Tprofit", OBJPROP_STYLE, STYLE_SOLID); ObjectSet("Tprofit", OBJPROP_COLOR, MediumSeaGreen); } //+------------------------------------------------------------------------+ //| Chiude tutto //+------------------------------------------------------------------------+ void CloseAll() { for(int i=OrdersTotal()-1;i>=0;i--) { OrderSelect(i, SELECT_BY_POS); bool result = false; if ( OrderType() == OP_BUY && OrderMagicNumber()== MagicNumber) result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, Red ); if ( OrderType() == OP_SELL && OrderMagicNumber()==MagicNumber) result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 5, Red ); if (UseAlerts) PlaySound("alert.wav"); } return; } void CloseAllBuy() { for(int i=OrdersTotal()-1;i>=0;i--) { OrderSelect(i, SELECT_BY_POS); bool result = false; if ( OrderType() == OP_BUY && OrderMagicNumber()==MagicNumber) result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, Red ); if (UseAlerts) PlaySound("alert.wav"); } return; } void CloseAllSell() { for(int i=OrdersTotal()-1;i>=0;i--) { OrderSelect(i, SELECT_BY_POS); bool result = false; if ( OrderType() == OP_SELL && OrderMagicNumber()==MagicNumber) result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 5, Red ); if (UseAlerts) PlaySound("alert.wav"); } return; } //+------------------------------------------------------------------------+ //| annulla tutti gli ordini che sono in profitto //+------------------------------------------------------------------------+ //+------------------------------------------------------------------------+ //| annulla tutti gli ordini in sospeso //+------------------------------------------------------------------------+ //+-----------+ //| Main | //+-----------+ int start() { int OrdersBUY, ticket; int OrdersSELL; double BuyLots, SellLots, BuyProfit, SellProfit; //+------------------------------------------------------------------+ // Determinare l'ultimo prezzo dell'ordine | //-------------------------------------------------------------------+ if(OrdersTotal()==0 && TradeType ==1 ) { ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-TP*Point,Ask+leverage*TP*Point, "MLTrendETF",MagicNumber,0,Green); TradeType=2; if(ticket>0) { if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) sendEmail(); } else Print("Error opening BUY order : ",GetLastError()); return(0); } if(OrdersTotal()==0 && TradeType ==2) { ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Bid+TP*Point,Bid-TP*leverage*Point, "MLTrendETF",MagicNumber,0,Green); TradeType = 1; if(ticket>0) { if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) sendEmail(); } else Print("Error opening BUY order : ",GetLastError()); return(0); } } // start()

godrich

puoi allegare il file mq4

In questo modo sarà inutilizzabile se incollato in metaeditor

 

Non sono sicuro che questo abbia funzionato ma...

File:
pac.mq4  5 kb
 

Ciao, ho appena trovato l'indicatore PetD che disegna una linea rossa o verde sopra la mia candela.

Ho appena trovato l'indicatore PetD che disegna una linea rossa o verde sulla mia candela. Quello che mi chiedo è se è possibile fare invece una striscia di istogramma colorato.

Così posso avere una finestra separata con una barra verde o rossa.

Grazie

pet-d_full_option.mq4

File:
 
NWFstudent:
Ciao.

Ho appena trovato l'indicatore PetD che disegna una linea rossa o verde sulla mia candela. Quello che mi chiedo è se è possibile fare invece una striscia di istogramma colorato.

Così posso avere una finestra separata con una barra verde o rossa.

Grazie

pet-d_full_option.mq4

NWFstudent

Ecco anche questo tipo: pet-d_full_option_-_separate.mq4

 
makototokyo:
Ciao,

Questo indicatore non sembra fare bene l'allarme. Mi sembra che faccia l'allarme solo una volta dopo l'avvio di mt4 e dopo il primo allarme non fa il suono. Mi sono anche reso conto che fa il suono solo quando la barra è "climax"... ma io voglio che faccia il suono quando la barra è "crescente".

Qualcuno potrebbe sistemare questo codice per l'indicatore di volume?

Se avete tempo di fare lo stesso per questo indicatore di candela lo apprezzo, ma non voglio rubarvi troppo tempo.

Grazie in anticipo.

Makototokyo, ho cambiato gli avvisi nella versione a finestra separata per usare gli avvisi "toro che sale e orso che sale", e dovrebbero funzionare correttamente in questa versione.