adidasanlal: order send is not firing but i am getting next line alert at every tick
-
Play videoPlease edit your post.
For large amounts of code, attach it. -
OrderSend(Symbol(),OP_BUY,LotSize,Ask,0,0,0,"Buy Order",MagicNumber,0,Green);Check your return codes and find out why. What are Function return values ? How do I use them ? - MQL4 forum and Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
- if (Stochasticvalue < 20 )You are checking a level, an alert per tick is expected. Check for a change in signal.static double Stochasticvalue=50;Function returns a double not a long. iStochastic - Technical Indicators - MQL4 Reference
double prevStoch = Stochasticvalue;
Stochasticvalue = iStochastic(NULL, 1, 100, 50, 1, MODE_SMA, 0, MODE_MAIN, 0);
if (Stochasticvalue < 20 && prevStoch >= 20)
adidasanlal:
Dear Friends,
I'm writing my first EA. Order send is not firing but i am getting next line alert at every tick. Could you please clarify why this is happening?
...
Forum on trading, automated trading systems and testing trading strategies
How to Start with Metatrader 5
Simon Gniadkowski, 2013.07.24 10:18
How to post code on this forum . . .
whroeder1:
Thank you so much for your valuable time. It is really helpful.
-
Play videoPlease edit your post.
For large amounts of code, attach it. -
OrderSend(Symbol(),OP_BUY,LotSize,Ask,0,0,0,"Buy Order",MagicNumber,0,Green);Check your return codes and find out why. What are Function return values ? How do I use them ? - MQL4 forum and Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
- if (Stochasticvalue < 20 )You are checking a level, an alert per tick is expected. Check for a change in signal.static double Stochasticvalue=50;Function returns a double not a long. iStochastic - Technical Indicators - MQL4 Reference
double prevStoch = Stochasticvalue;
Stochasticvalue = iStochastic(NULL, 1, 100, 50, 1, MODE_SMA, 0, MODE_MAIN, 0);
if (Stochasticvalue < 20 && prevStoch >= 20)
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
Dear Friends,
I'm writing my first EA. Order send is not firing but i am getting next line alert at every tick. Could you please clarify why this is happening?
//| Lal-First EA.mq4 |
//| Copyright 2016, MetaQuotes Software Corp. |
//| https://book.mql4.com/ |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016, MetaQuotes Software Corp."
#property link "https://book.mql4.com/"
#property version "1.00"
#property strict
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
Alert("EA Initiated");
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
long Stochasticvalue;
int LotSize;
long MagicNumber;
LotSize = 1;
Stochasticvalue = iStochastic(NULL, 1, 100, 50, 1, MODE_SMA, 0, MODE_MAIN, 0);
if (Stochasticvalue < 20 )
{
OrderSend(Symbol(),OP_BUY,LotSize,Ask,0,0,0,"Buy Order",MagicNumber,0,Green);
Alert ("Buy Placed;" " Stochastic = ",Stochasticvalue);
}
if (Stochasticvalue > 80)
{
OrderSend(Symbol(),OP_SELL,LotSize,Bid,0,0,0,"Sell Order",MagicNumber,0,Red);
Alert ("Sell Placed;" " Stochastic = ",Stochasticvalue);
}
}
//+------------------------------------------------------------------+