1) I tried to signal my buy trades with RSI < 30 but looks like it executes buy trades even when RSI is higher than 30... what could be possibly wrong?
2) It doesn't execute any Sell trades! I pretty much modified one of the sample codes in the Libraries, and the sample codes executed sell trades okay, but why not with mine, when I just changed the buy/sell conditions?
3) Is there a way to remove "close at stop"? looks like there's a quite huge loss always at the Close at Stop. Also, when we actually use the codes with actual trading, will this Close at Stop happen?
-
Play videoPlease edit your post.
For large amounts of code, attach it - We have no idea what the variable RSI is or it's value. Post all relevant code. Print out your variables, and find out why.
- Same answer as #2
- No idea what you mean by "Close at Stop" all stops when hit close the ticket. If you mean the Stop Loss, set it to zero and trade with infinite risk! It's your OrderSend code, change it to what you want.
Hi,
I'm totally new to MQL4. After hours of Googling and fixing but to no avail, was wondering if anyone can help me with this:
1) I tried to signal my buy trades with RSI < 30 but looks like it executes buy trades even when RSI is higher than 30... what could be possibly wrong?
2) It doesn't execute any Sell trades! I pretty much modified one of the sample codes in the Libraries, and the sample codes executed sell trades okay, but why not with mine, when I just changed the buy/sell conditions?
3) Is there a way to remove "close at stop"? looks like there's a quite huge loss always at the Close at Stop. Also, when we actually use the codes with actual trading, will this Close at Stop happen?
Here are the codes:
if ((RSI < 31));
{
Print("RSI at Buy", RSI);
ticket=OrderSend(Symbol(), OP_BUY ,Lots,Ask,10,moving_avg - 100 ,Ask + TakeProfit*Point,"buy",0,0,Green);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
Print("BUY order opened : ",OrderOpenPrice());
}
else
Print("Error opening BUY order : ",GetLastError());
return;
}
//--- check for short position (SELL) possibility
if ((RSI > 69));
{
Print("RSI at Sell", RSI);
ticket=OrderSend(Symbol(),OP_SELL ,Lots,Bid,3,moving_avg + 100,Bid-TakeProfit*Point,"Sell",0,0,Red);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
Print("SELL order opened : ",OrderOpenPrice());
}
else
Print("Error opening SELL order : ",GetLastError());
}
return;
you should use SRC button when posting code. That said, how are you defining RSI variable? is it iRSI(....)?
- docs.mql4.com
sorry...and thank you for your help. here's my RSI code, just simple iRSI.
And yes, next time will do SRC button :)
double RSI = iRSI(NULL, 0, 20, PRICE_MEDIAN,1);
-
Please edit your post.
For large amounts of code, attach it - We have no idea what the variable RSI is or it's value. Post all relevant code. Print out your variables, and find out why.
- Same answer as #2
- No idea what you mean by "Close at Stop" all stops when hit close the ticket. If you mean the Stop Loss, set it to zero and trade with infinite risk! It's your OrderSend code, change it to what you want.
total= OrdersTotal();
if(total<1)
{
//--- no opened orders identified
if(AccountFreeMargin()<(1000*Lots))
{
Print("We have no money. Free Margin = ",AccountFreeMargin());
return;
}
//--- check for long position (BUY) possibility
if ((RSI < 31));
{
Print("RSI at Buy", RSI);
ticket=OrderSend(Symbol(), OP_BUY ,Lots,Ask,10,moving_avg - 100 ,Ask + TakeProfit*Point,"buy",0,0,Green);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
Print("BUY order opened : ",OrderOpenPrice());
}
else
Print("Error opening BUY order : ",GetLastError());
return;
}
//--- check for short position (SELL) possibility
if ((RSI > 69));
{
Print("RSI at Sell", RSI);
ticket=OrderSend(Symbol(),OP_SELL ,Lots,Bid,3,moving_avg + 100,Bid-TakeProfit*Point,"Sell",0,0,Red);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
Print("SELL order opened : ",OrderOpenPrice());
}
else
Print("Error opening SELL order : ",GetLastError());
}
//--- exit from the "no opened orders" block
return;
}
Can you please provide a screen shot showing the "Data Window" with the chart of where the trade executed.
There might be mismatch between the values you are seeing in the "Data Window" and what your RSI signal/out gets.
pw2232: the end of a back-test always "close at stop" and this is what I'd like to remove. | When the tester ends and you still have an open order, it closes it. Change your end date to before the last opened order. |
- 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,
I'm totally new to MQL4. After hours of Googling and fixing but to no avail, was wondering if anyone can help me with this:
1) I tried to signal my buy trades with RSI < 30 but looks like it executes buy trades even when RSI is higher than 30... what could be possibly wrong?
2) It doesn't execute any Sell trades! I pretty much modified one of the sample codes in the Libraries, and the sample codes executed sell trades okay, but why not with mine, when I just changed the buy/sell conditions?
3) Is there a way to remove "close at stop"? looks like there's a quite huge loss always at the Close at Stop. Also, when we actually use the codes with actual trading, will this Close at Stop happen?
Here are the codes:
{
Print("RSI at Buy", RSI);
ticket=OrderSend(Symbol(), OP_BUY ,Lots,Ask,10,moving_avg - 100 ,Ask + TakeProfit*Point,"buy",0,0,Green);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
Print("BUY order opened : ",OrderOpenPrice());
}
else
Print("Error opening BUY order : ",GetLastError());
return;
}
//--- check for short position (SELL) possibility
if ((RSI > 69));
{
Print("RSI at Sell", RSI);
ticket=OrderSend(Symbol(),OP_SELL ,Lots,Bid,3,moving_avg + 100,Bid-TakeProfit*Point,"Sell",0,0,Red);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
Print("SELL order opened : ",OrderOpenPrice());
}
else
Print("Error opening SELL order : ",GetLastError());
}
return;