//+------------------------------------------------------------------+
//| SuperProfit.mq4 |
//| Copyright 2015, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2015, AM2"
#property link "http://www.forexsystems.biz"
#property description "Simple expert advisor"
//--- Inputs
extern double Lots = 0.1;
extern int StopLoss = 500;
extern int TakeProfit = 500;
extern int Count = 3;
extern int Slip = 30;
//----
extern int SPPeriod = 16;
extern int MA1Period = 50;
extern int MA2Period = 80;
extern int Magic = 26102015;
int t=0;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int CountTrades()
{
int count=0;
for(int i=OrdersTotal()-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
{
if(OrderType()==OP_BUY || OrderType()==OP_SELL)
count++;
}
}
}
return(count);
}
//+------------------------------------------------------------------+
//| OnTick function |
//+------------------------------------------------------------------+
void OnTick()
{
int r=0;
double SPGreen1=iCustom(Symbol(),0,"superprofit",SPPeriod,0,1);
double SPRed1=iCustom(Symbol(),0,"superprofit",SPPeriod,1,1);
double SPGreen2=iCustom(Symbol(),0,"superprofit",SPPeriod,0,2);
double SPRed2=iCustom(Symbol(),0,"superprofit",SPPeriod,1,2);
double ma1=iMA(NULL,0,MA1Period,0,MODE_EMA,PRICE_CLOSE,1);
double ma2=iMA(NULL,0,MA2Period,0,MODE_EMA,PRICE_CLOSE,1);
if(t!=Time[0] && CountTrades()<=Count)
{
//--- sell conditions
if((SPRed1<1000 && SPGreen2<1000) || (Close[1]<ma1 && Close[2]>ma1 && SPRed1<1000) || (Close[1]<ma2 && Close[2]>ma2 && SPRed1<1000))
{
r=OrderSend(Symbol(),OP_SELL,Lots,Bid,Slip,Bid+StopLoss*Point,Bid-TakeProfit*Point,"",Magic,0,Red);
t=Time[0];
return;
}
//--- buy conditions
if((SPGreen1<1000 && SPRed2<1000) || (Close[1]>ma1 && Close[2]<ma1 && SPGreen1<1000) || (Close[1]>ma2 && Close[2]<ma2 && SPGreen1<1000))
{
r=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slip,Ask-StopLoss*Point,Ask+TakeProfit*Point,"",Magic,0,Blue);
t=Time[0];
return;
}
}
Comment("\n SPGreen1: ",SPGreen1,
"\n SPRed1: ",SPRed1,
"\n SPGreen2: ",SPGreen2,
"\n SPRed2: ",SPRed2,
"\n Time[0]: ",Time[0],
"\n t: ",t);
//---
}
//+------------------------------------------------------------------+
if((SPRed1<1000 && SPGreen2<1000) || (Close[1]<ma1 && Close[2]>ma1 && (SPRed1<1000 && SPGreen2<1000)) || (Close[1]<ma2 && Close[2]>ma2 && (SPRed1<1000 && SPGreen2<1000)))
//+------------------------------------------------------------------+
//| SuperProfit.mq4 |
//| Copyright 2015, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2015, AM2"
#property link "http://www.forexsystems.biz"
#property description "Simple expert advisor"
//--- Inputs
extern double Lots = 0.1;
extern int StopLoss = 500;
extern int TakeProfit = 500;
extern int Count = 3;
extern int Slip = 30;
//----
extern int SPPeriod = 16;
extern int MA1Period = 50;
extern int MA2Period = 80;
extern int Magic = 26102015;
int t=0;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int CountTrades()
{
int count=0;
for(int i=OrdersTotal()-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
{
if(OrderType()==OP_BUY || OrderType()==OP_SELL)
count++;
}
}
}
return(count);
}
//+------------------------------------------------------------------+
//| OnTick function |
//+------------------------------------------------------------------+
void OnTick()
{
int r=0;
double SPGreen1=iCustom(Symbol(),0,"superprofit",SPPeriod,0,1);
double SPRed1=iCustom(Symbol(),0,"superprofit",SPPeriod,1,1);
double SPGreen2=iCustom(Symbol(),0,"superprofit",SPPeriod,0,2);
double SPRed2=iCustom(Symbol(),0,"superprofit",SPPeriod,1,2);
double ma1=iMA(NULL,0,MA1Period,0,MODE_EMA,PRICE_CLOSE,1);
double ma2=iMA(NULL,0,MA2Period,0,MODE_EMA,PRICE_CLOSE,1);
if(t!=Time[0] && CountTrades()<=Count)
{
//--- sell conditions
if((SPRed1<1000 && SPGreen2<1000) || (Close[1]<ma1 && Close[2]>ma1) || (Close[1]<ma2 && Close[2]>ma2))
{
r=OrderSend(Symbol(),OP_SELL,Lots,Bid,Slip,Bid+StopLoss*Point,Bid-TakeProfit*Point,"",Magic,0,Red);
t=Time[0];
return;
}
//--- buy conditions
if((SPGreen1<1000 && SPRed2<1000) || (Close[1]>ma1 && Close[2]<ma1) || (Close[1]>ma2 && Close[2]<ma2))
{
r=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slip,Ask-StopLoss*Point,Ask+TakeProfit*Point,"",Magic,0,Blue);
t=Time[0];
return;
}
}
Comment("\n SPGreen1: ",SPGreen1,
"\n SPRed1: ",SPRed1,
"\n SPGreen2: ",SPGreen2,
"\n SPRed2: ",SPRed2,
"\n Time[0]: ",Time[0],
"\n t: ",t);
//---
}
//+------------------------------------------------------------------+
AM2