John James Holmes: so i accidentally uploaded this to mql5, hopefully i can get a bit luckier here. Any help as to why no trades are being placed (
-
Don't double post! You already had another thread open.
General rules and best pratices of the Forum. - General - MQL5 programming forum (2017) -
Your other post has already been moved here.
- Your other post has already been answered.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
so i accidentally uploaded this to mql5, hopefully i can get a bit luckier here. Any help as to why no trades are being placed (no matter how low the time frame) would be appreciated.
#property version "1.00"
#property strict
#property show_inputs
#include <customfunctions01.mqh>
int rsiPeriod = 7;
input double riskPerTrade = 0.01;
input int rsiLowerLevel = 20;
input int rsiUpperLevel = 80;
input int stoplosspips = 100;
input int takeprofitpips = 500;
input int breakeven = 40;
input int SlowMA = 200;
input int FastMA = 50;
input int StoUpperlevel = 80;
input int StoLowerLevel = 20;
input int ticket = 0;
int openOrderID;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
Alert("");
Alert("Starting Strategy johnstrategy");
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
Alert("Stopping johnstrategy");
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
double FastMA = iMA(NULL,0,50,0,MODE_SMA,PRICE_CLOSE,0);
double SlowMA= iMA(NULL,0,200,0,MODE_SMA,PRICE_CLOSE,1);
double rsiValue = iRSI(NULL,0,rsiPeriod,PRICE_CLOSE,0);
double currentRSI = iRSI(NULL,0,7,0,0);
double previousRSI = iRSI(NULL,0,7,0,5);
double Stovalue = iStochastic(NULL, 0, 14 , 3, 3, MODE_SMA, MODE_MAIN, 0, 0);
double currentStovalue = iStochastic(NULL, 0, 14 , 3, 3, MODE_SMA, MODE_MAIN, 0, 0);
double previousStovalue = iStochastic (NULL, 0, 14 , 3, 3, MODE_SMA, MODE_MAIN, 0, 1);
double MACD = iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,0);
//if(!checkifopenordersbymagicnb(magicNB))&&//if no open orders try to enter new position
if (isnewcandle())
{
if (rsiValue<20 && FastMA>SlowMA&& currentStovalue< 20 && Bid<SlowMA) //buying
{
Print("MA's show a bullish market and rsiValue is lower than " + rsiLowerLevel+ " , Sending buy order");
double stopLossPrice = Bid - stoplosspips * getpipvalue();
double takeProfitPrice = Bid + takeprofitpips * getpipvalue();
Print("Entry Price = " + Bid);
Print("Stop Loss Price = " + stopLossPrice);
Print("Take Profit Price = " + takeProfitPrice);
double lotSize = optimallotsize(riskPerTrade,Bid,stopLossPrice);
openOrderID = OrderSend(NULL,OP_BUY,lotSize,Bid,10,stopLossPrice,takeProfitPrice,NULL,magicNB);
if(openOrderID < 0) Alert("order rejected. Order error: " + GetLastError());
}
else if(rsiValue > 80 && SlowMA>FastMA&& currentStovalue>80 && Ask>SlowMA )//shorting
{
Print("MA's show a bearish market and rsiValue is above " + rsiUpperLevel+ " , Sending short order");
double stopLossPrice = Ask + stoplosspips * getpipvalue();
double takeProfitPrice = Ask - takeprofitpips * getpipvalue();
Print("Entry Price = " + Ask);
Print("Stop Loss Price = " + stopLossPrice);
Print("Take Profit Price = " + takeProfitPrice);
double lotSize = optimallotsize(riskPerTrade,Ask,stopLossPrice);
openOrderID = OrderSend(NULL,OP_SELL,lotSize,Ask,10,stopLossPrice,takeProfitPrice,NULL,magicNB);
if(openOrderID < 0) Alert("order rejected. Order error: " + GetLastError());
}
}
}