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
Date un'occhiata al codice dell' EA della media mobile sulla vostra metatrader Station e vedete come si fa lì ....
bene
In questo momento dovete controllare se c'è già un'operazione aperta
prima di aprire una compravendita devi sapere se c'è una compravendita aperta
ancora non vedo che hai fatto il conteggio dei trade
.
Dai un'occhiata al codice dell' EA Moving Average sulla tua metatrader Station e vedi come viene fatto lì ....
Ho letto molti esempi e imitato il loro stile di codifica.
Questo è il mio ultimo codice. sfortunatamente, il suo profitto è ancora negativo, cosa che non dovrebbe essere.
//+------------------------------------------------------------------+ //| RSI_strategy_cyxstudio.mq4 | //| Copyright 2013, Tjipke de Vries | //| https://forum.mql4.com/53695/ | //+------------------------------------------------------------------+ #property copyright "Copyright 2013, MetaQuotes Software Corp." #property link "http://www.metaquotes.net" #include <stderror.mqh> #include <stdlib.mqh> extern int RSIPeriod = 2; //number of periods for RSI extern double UpperBound = 95; //set upper bound value for RSI extern double LowerBound = 5; //set lower bound value for RSI extern double Lots = 0.1; extern double StopLoss = 60; //Set the stop loss level extern double TakeProfit = 120; //Set the take profit level extern double TrailingStop = 40; //extra settings for OrderSend extern int MagicNumber = 54333; extern string CommentEA = "RSI strategy"; extern int Slippage.Pips = 10; //--- //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { //---- Alert(OrdersTotal()); //---- return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { //---- RefreshRates(); int Ticket1; int Ticket2; bool Ticket3; bool Ticket4; double SL,TP; int Total; double MagicNo; double Slippage; int cnt; double pAsk = MarketInfo(Symbol(), MODE_ASK); double pBid = MarketInfo(Symbol(), MODE_BID); double pAskPrev = iClose(Symbol(),0,1); double pBidPrev = iClose(Symbol(),0,1); double pAskLast = iClose(Symbol(),0,2); double pBidLast = iClose(Symbol(),0,2); double MA200 = iMA(NULL, 1440, 200, 0,MODE_SMA,PRICE_CLOSE, 0); //200 day Moving Average double MA5 = iMA(NULL, 1440, 5, 0,MODE_SMA,PRICE_CLOSE, 0); // 5 day Moving Average double CurrentRSI = iRSI (NULL, 0, RSIPeriod,PRICE_CLOSE ,0); double PrevRSI = iRSI (NULL, 0, RSIPeriod,PRICE_CLOSE ,1); double LastRSI = iRSI (NULL, 0, RSIPeriod,PRICE_CLOSE ,2); if(Bars<100) { Print("bars less than 100"); return(0); } if(AccountFreeMargin()<(1000*Lots)) { Print("We have no money. Free Margin = ", AccountFreeMargin()); return(0); } //Check for open orders if there are none then check for conditions to open one if ((OrdersTotal() ==0) && (LastRSI > PrevRSI) && (PrevRSI > CurrentRSI) && (CurrentRSI < LowerBound) && (pAsk > MA200) && (pAsk < pAskPrev) && (pAskPrev < pAskLast)) { //Condition to execute buy entry Ticket1 = OrderSend(Symbol(), OP_BUY, Lots, pAsk, Slippage.Pips, pBid - ( StopLoss * Point ), pBid + ( TakeProfit * Point ), "Buy.", MagicNumber,0,Yellow); //execute buy order if(Ticket1>0) { if(OrderSelect(Ticket1,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice()); } if (Ticket1 < 0) { Print("Error opening BUY order : ",GetLastError()); return(0); } } if ((OrdersTotal() ==0) && (LastRSI < PrevRSI) && (PrevRSI < CurrentRSI) && (CurrentRSI > UpperBound) && (pBid < MA200)) { //Condition to execute sell entry Ticket2 = OrderSend(Symbol(), OP_SELL, Lots, pBid, Slippage.Pips, pAsk + ( StopLoss * Point ), pAsk - ( TakeProfit * Point ), "Sell.",MagicNumber, 0, Yellow) ; //execute sell order if(Ticket2>0) { if(OrderSelect(Ticket2,SELECT_BY_TICKET,MODE_TRADES)) Print("SELL order opened : ",OrderOpenPrice()); } if (Ticket2<0) { Print("Error opening SELL order : ",GetLastError()); return(0); } } int ticket=OrderTicket(); double lots=OrderLots(); for (int i = OrdersTotal() - 1; i >= 0; i--) { if (OrderSelect(i, SELECT_BY_POS)) { if ((OrderSymbol() == Symbol()) && (OrderMagicNumber() == MagicNumber) ) { if (OrderType() == OP_BUY && pBid > MA5 && (pBid > pBidPrev) && (pBidPrev > pBidLast)) { Ticket3 = OrderClose(ticket, lots, pBid, Slippage.Pips); if (Ticket3 == true ) { Print("BUY position closed", OrderClosePrice()); } if (Ticket3 == false) { Print("Error closing BUY position", ErrorDescription(GetLastError())); } } } } } for (int m = OrdersTotal() - 1; m >= 0; m--) { if (OrderSelect(m, SELECT_BY_POS)) { if ((OrderSymbol() == Symbol()) && (OrderMagicNumber() == MagicNumber)) { if (OrderType() == OP_SELL && pAsk < MA5) { Ticket4 = OrderClose(ticket, lots, pAsk, Slippage.Pips); if (Ticket4 == true ) { Print("SELL position closed", OrderClosePrice()); } if (Ticket4 == false) { Print("Error closing SELL position", ErrorDescription(GetLastError())); } } } } } return(0); }Puoi per favore dirmi direttamente quale parte è sbagliata?
Ho anche tentato questo
leggerei molti esempi e imiterei il loro stile di codifica.
Questo è il mio ultimo codice. sfortunatamente, il suo profitto è ancora negativo, cosa che non dovrebbe essere.
Potete dirmi direttamente quale parte è sbagliata?
Ho detto cosa c'è di sbagliato, non sono stato abbastanza chiaro?
Hai fatto delle modifiche al codice che ti ho dato
le tue modifiche a quella parte sono tutte sbagliate e ho scritto prima dove era sbagliato...
C'è di più all'interno del ciclo che do più tardi
Dopo il ciclo fai la parte per aprire le compravendite...
// MAKE PART FOR OPENING BUY TRADEdeve funzionare per i broker a 4/5 cifre e deve funzionare per i conti ECN
.
.
.
.
Mi piace vedere
cambiare questo codice originale che avevi
deve funzionare per i broker a 4/5 cifre e deve funzionare per i conti ECN