stoch close ea
Posted: Sun Jun 11, 2017 2:50 am
Can someone help out with these warnings as to what I should change them to?
Will it still work as warnings as long as its not errors?
Thanks
Will it still work as warnings as long as its not errors?
Thanks
Code: Select all
//+------------------------------------------------------------------+
//| StochX.mq4 |
//| EaglePip |
//| ApacheSoft Copyright © 2011 |
//| www.Apache Soft Works PL |
//| This EA Created in response to request by fxozgirl on FF. |
//| It is designed to close any open orders on cross of Stoch(8,3,3) |
//| USE AT YOUR OWN RISK. Verify On Demo First. |
//| Ver.1 24.4.2011 |
//| Verify On Demo First. | |
//+------------------------------------------------------------------+
#property copyright "ApacheSoft Copyright © 2010"
#property link "www.Apache Soft Works PL"
#define IDENT "StochX"
#define MAGEEK 240411
#define NOTYET 0
#define CLOSEBUY 1
#define CLOSESELL 2
extern string Remark1 = "== Standard Settings ==";
extern int Stochk=8;
extern int Stochd=3;
extern int Stochslo=3;
extern int Slippage = 5;
extern int MAmethod=0; //0=SMA,1=EMA,2=SMMA,3=LWMA
extern int Price=0; //0=Close,1=High,2=Low,3=Median,4=Open.5=Typical,6=Weighted
extern int Lookback=1;
extern string Remark2 = "== SL & TP Options ==";
extern bool UseStopLoss = False;
extern int StopLoss = 100;
extern bool UseTakeProfit = False;
extern int TakeProfit = 60;
extern bool UseTrailingStop = False;
extern int TrailingStop = 30;
extern bool EachTickMode = true;//false= end of bar
bool SendAlert = False;//1=True, 0=False
bool TickCheck = False;
int Current;
int BarCount;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
BarCount = Bars;
if (EachTickMode) Current = 0; else Current = 1;
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
int IndicX = NOTYET;
int Total, Ticket;
if (EachTickMode && Bars != BarCount) TickCheck = False;
Total = OrdersTotal();
IndicX = NOTYET;
//+------------------------------------------------------------------+
//| Indicators |
//+------------------------------------------------------------------+
double StochM = iStochastic(NULL,0,Stochk,Stochd,Stochslo,MAmethod,Price,MODE_MAIN,Current + 0);
double StochSig = iStochastic(NULL,0,Stochk,Stochd,Stochslo,MAmethod,Price,MODE_SIGNAL,Current + 0);
double SignalPre = iStochastic(NULL,0,Stochk,Stochd,Stochslo,MAmethod,Price,MODE_SIGNAL,Current + Lookback);
//+------------------------------------------------------------------+
//Check for Open Orders |
//+------------------------------------------------------------------+
bool IsTrade = False;
for (int i = 0; i < Total; i ++)
{
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if(OrderType() <= OP_SELL && OrderSymbol() == Symbol())
{
IsTrade = True;
if(OrderType() == OP_BUY)
//Close
//+------------------------------------------------------------------+
//| Stoch Cross Signal (Down) |
//+------------------------------------------------------------------+
{
if (SignalPre < StochM&& StochSig > StochM) IndicX = CLOSEBUY;
//+------------------------------------------------------------------+
//| Stoch Cross (Close Buy Order) |
//+------------------------------------------------------------------+
if (IndicX == CLOSEBUY && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount))))
{
OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, MediumSeaGreen);
if (SendAlert) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Bid, Digits) + " Close Buy");
if (!EachTickMode) BarCount = Bars;
IsTrade = False;
continue;
}
//Trailing stop
if(UseTrailingStop && TrailingStop > 0)
{
if(Bid - OrderOpenPrice() > Point * TrailingStop)
{
if(OrderStopLoss() < Bid - Point * TrailingStop)
{
OrderModify(OrderTicket(), OrderOpenPrice(), Bid - Point * TrailingStop, OrderTakeProfit(), 0, MediumSeaGreen);
if (!EachTickMode) BarCount = Bars;
continue;
}
}
}//Trailing stop
} // Stoch Cross Signal (Down)
else
///+------------------------------------------------------------------+
//| Stoch Cross Signal (Up) |
//+-------------------------------------------------------------------+
{
if ( SignalPre > StochM && StochSig < StochM) IndicX = CLOSESELL;
//+------------------------------------------------------------------+
//| Stoch Cross (Close Sell Order) |
//+------------------------------------------------------------------+
if (IndicX == CLOSESELL && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount))))
{
OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, DarkOrange);
if (SendAlert) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Ask, Digits) + " Close Sell");
if (!EachTickMode) BarCount = Bars;
IsTrade = False;
continue;
}
if(UseTrailingStop && TrailingStop > 0)
{
if((OrderOpenPrice() - Ask) > (Point * TrailingStop))
{
if((OrderStopLoss() > (Ask + Point * TrailingStop)) || (OrderStopLoss() == 0))
{
OrderModify(OrderTicket(), OrderOpenPrice(), Ask + Point * TrailingStop, OrderTakeProfit(), 0, DarkOrange);
if (!EachTickMode) BarCount = Bars;
continue;
}
}
}//Trailing stop
}// Stoch Cross Signal (Up)
}//IsTrade = True;
}//for (int i = 0; i < Total; i ++)
return(0);
}//| expert start function