In my opinion, my script is good ( no warning and no error message ) but when i want to do some backtest, nothing is happening.
I didn't look into the details but off-hand I think u need to code the "void OnStart()" function... also, you mentioned script, so is it really supposed to be a script (as in run just once and end) or an expert (that runs repeated every tick)?
I didn't look into the details but off-hand I think u need to code the "void OnStart()" function... also, you mentioned script, so is it really supposed to be a script (as in run just once and end) or an expert (that runs repeated every tick)?
Thanks for the information.
I did the correction but it still not working.
I'm talking about Expert Advisors.
Hi guys,
I add a little update of my EA.
But it still launch no trade... Someone can help me please ??
Thanks in advance :)
extern int TakeProfit = 3500 ; extern int StopLoss = 1500 ; extern double LotSize = 1.00 ; extern int period_RSI = 14 ; extern int slipage = 500 ; extern int Magic = 1234 ; int start () { for (int i=OrdersTotal ()-1 ; i < OrdersTotal () ; i++) { if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) { break ; // exit the cycle } NumPos++ ; } return (0); } double RMA20B0 = iMA(Symbol(),0,20,0,MODE_SMA,PRICE_CLOSE,0); double RSI0 = iRSI (Symbol(),0,period_RSI,PRICE_CLOSE,0); double RSI1 = iRSI (Symbol(),0,period_RSI,PRICE_CLOSE,1); double SL = NormalizeDouble (Ask-StopLoss*Point,Digits) ; double TP = NormalizeDouble (Ask+TakeProfit*Point,Digits) ; bool NumPos=false ; // Number of position bool openbuy=false ; bool opensell=false ; // ---------------- Order Buy // if the candle 1 is lower than the candle 0 // if no other trader is opened // if the RSI [1] is lower than the RSI [0] and the RSI [0] is superior than 25 // if the Candlee [0] (Close) is superior than the Moving Average 20 void OPBUY () { if (!NumPos && Close [0] >= RMA20B0) { if ( Open [1] <= Open [0] && RSI1 <= RSI0 && RSI0 >= 25 ) { openbuy = OrderSend (Symbol(),OP_BUY,LotSize,Ask,slipage,SL,TP,"BUY",Magic,0,Green) ; } } } // ---------------------- Ordre Sell // if the Candle 1 is superior of the Candle 0 // if no other trade is opened // if the RSI [1] is superior than the RSI [0] and RSI [0] is lower than 65 // if the candle 0 is lower than the Moving Average 20 void OPSELL () { if (!NumPos && Close [0] <= RMA20B0) { if (Open [1] >= Open [0] && RSI1 >= RSI0 && RSI0 <= 65 { opensell = OrderSend (Symbol(),OP_SELL,LotSize,Bid,slipage,SL,TP,"SELL",Magic,0,Red); } } } // --------------- Order Buy Close // if the candle 0 (Close )is lower than the candle 2 (Close) // if the RSI [0] is lower than 48 void CloseBuy () { for (int i=OrdersTotal();i>=0;i--) { if (OrderSelect(OrderTicket(),SELECT_BY_TICKET,MODE_TRADES)==true) { if (OrdersTotal () >= 1 && OrderType () == OP_BUY && (Close [0] <= Close [2]|| RSI0 <= 48)) { int OrderBuyClose=OrderClose (OrderTicket(),LotSize,Ask,slipage,Red); } } } } // ------------------ Ordre Close Sell // if the candle 0 is superior than the candle 2 // if RSI [0] > 50 void CloseSell () { if (OrderSelect(OrderTicket(),SELECT_BY_TICKET)==true) { if (OrdersTotal () >= 1 && OrderType () == OP_SELL && (Close [0] >= Close [2]|| RSI0 >= 50)) { int OrderSellClose=OrderClose (OrderTicket(),LotSize,Bid,slipage,Red); } } }
Hi guys,
I add a little update of my EA.
But it still launch no trade... Someone can help me please ??
Thanks in advance :)
Well, I still don't see OnTick function, and even if I ignore that, I cannot even compile your code without error.
Did you check your Toolbox->Errors of your MetaEditor after compilation for errors?
- 2019.04.17
- www.mql5.com
Well, I still don't see OnTick function, and even if I ignore that, I cannot even compile your code without error.
Did you check your Toolbox->Errors of your MetaEditor after compilation for errors?
With this code, I didn't have any error of compilation.
But with the correction of Jean-Jacques Juille, the EA launch trade automatically.
And you are right, the correct code have OnTick function.
Thank you.
Good luck Jonathan
Thanks a lot Jean-Jacques Juille.
Your correction fix my problem. I have some OrderSend error 131, but I think is because of my level of SL.
Now, it's time for me to understand the modification and to do a lot of backtest with different settings.
Thanks again :)
Hi again,
I have test the new code but I see differents problems which I don't understand.
First of all, I have only buy trade and no sell trade, but when I check on the graphe, sell trade have to be taken by the EA...
An other thing is the stop of the buy trade. For exemple, as you can see on the screenshot, their are no reason to close this following trade.
Trade #1
// the Candle 0 cross the Moving Average
// RSI is upper than 25
// candle 0 is upper than Candle 0
A few candle later, the trade closed but nothing justified that.
// RSI is upper than 48
// candle is more and more high
Trade #2 - Trade just after the closing of the #1
Trade closed one candle later with no reason.
Some trade are also opened and closed in the same candle.
Someone can help me please ?
Thanks in advance :)
This is false
for (i = OrdersTotal() - 1; i < OrdersTotal(); i++) { if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES) == false) { break; // exit the cycle } NumPos++; }
should be :
for (i = 0; i < OrdersTotal(); i++)
And a "continue" instead of a "break"
double SL_Buy = NormalizeDouble(Bid- StopLoss * Point, Digits); double TP_Buy = NormalizeDouble(Bid+ TakeProfit * Point, Digits); double SL_Sell = NormalizeDouble(Ask + StopLoss * Point, Digits); double TP_Sell = NormalizeDouble(Ask - TakeProfit * Point, Digits);
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi everyone,
I'm creating this post in order to fix my unsolvable problem.
In my opinion, my script is good ( no warning and no error message ) but when i want to do some backtest, nothing is happening.
For information and to help the comprehension of this script, I just want 1 trade by 1.
In the beginning, I wanted to add trailling stop but it seems like impossible, because I can't fix the main part of the script.
Someone could help me please ?
Thanks in advance.
I will really appreciate some help.
Thanks again in advance.