//+------------------------------------------------------------------+
//| Piplite v2.1 |
搜狗网页导航//| jeff hubbard |
//+------------------------------------------------------------------+
#property copyright "J Talon Associates ?2009 "
#property link ""
#include <stdlib.mqh>
#include <stderror.mqh>
#define NL "\n"
// Regular variables
extern string InitialAccountSet = "Enter Account Balance";
吉梗extern int InitialAccount = 2500;
extern string TradeComment = "Pip lite";
extern string NumberPortionSet = "Portion of Account to trade (1-10)";
extern int Portion = 1; // Portion of account you want to trade on this pair
extern bool UEquityProtection = true; // Clo all orders when negative Float is excessive.
extern double FloatPercent = 50; // Percent of portion for max Float level.
extern bool UPowerOutSL = fal;
extern string AccountTypeSet = "1 = standard, 10 = micro account";
extern int Accounttype = 1; // 1 = standard, 10 = micro
extern bool MoneyMangement = true; // will autocalculate lot size, lot increment and profit target
extern double MaximumRisk = 4.0; // equals 4% or .04 of account balance for ba lot
extern string ManuallotSet = "Lots ud if MM is off";
etd
extern double LotSize = 0.01;
extern string LotIncrementSet = "Lot Inc ud if MM is off (.01-.05)";
extern double LotIncrement = 0.01; // must be t to .01 or greater
extern int Slippage = 5; // Tolerance for opening and closing of orders
extern string ProfitTargetSet = "Set desired Profit; autot with MM on!";
extern double ProfitTarget = 1; // All orders clod when this profit target amount (in dollars) is reached
extern string ProfitSkewSet = "Multiplier for Profit Target if MM on!";
extern string ProfitSkewSet2 = "Inop with MM off";
extern double ProfitSkew = 8; // Increa/decrea ProfitTarget when MoneyMangement=true
extern string ProfitTakeSet = "1-mixed, 2-global, 3-split, 1 is best!";
extern int ProfitMode = 1; // 1= mixed mode, 2= global mode, 3= split mode, 1 is best
extern string ProfitTrailSet = "Tries to grow profit past Profit Target if true";
extern bool ProfitTrailing = true; // Will try to allow profit grow beyond ProfitTarget
extern string ProfitRetraceSet = "Max % decrea in Profit before";
extern string ProfitRetraceSet2 = "closing orders";
extern double MaxRetrace = 2; // Maximum percent of MaxPr
ofit allowed to decrea before clo all orders
extern string TradeDirectionSet = "Piplite trades best when t to true!";
extern bool ReverDirection = true; // true = will trade long when price is low and short and price is high. fal = will trade long when price is high and short when price is low
extern string RSIIndicatorSet = "Period and Bars for aRSI";
extern string RSIIndicatorSet2 = "Set ARSI_trigger = 0 for auto ATR entry";
extern bool UARSI = true; // Adaptive RSI For Trade Entry
extern int RSI_period = 60; // TF for ARSI
extern int RSI_bars = 10; // length of ARSI
extern double ARSI_trigger = 0.01; // level to trigger trade. Set to 0 for ATR to trigger entry
extern string MARSICrossSet = "Further checks trades in Trend";
extern bool U_MARSI_Cross = fal; // Helps to prevent multiple trades in Trending Market
extern double RSIMA_MA_Period = 10; // Best Period
extern double RSIMA_RSI_Period = 14; // Best Period
extern string TrendProtectSet = "True=enable RSI trade window";
extern bool TrendProtect = fal;
extern double Window = 40.0; // Window to define ranging market
extern string TradeEntryDelaySet = "Prevent multiple entries within a certain time frame in conds";
extern bool U_Entry_Delay = fal; // Helps reduce draw down by stopping new entries if number of conds not pasd
extern double Minimum_Entry_Delay = 1200; // Number of conds to wait before re-entries
extern string OrderSpaceSet = "Autots additional order spacing if true";
extern string OrderSpaceSet2 = "Trend/spacing ud if fal";
extern bool AutoSpacing = true; // Spacing will be calculated using StDev
extern int StDevTF = 60; // TF for StDev
extern int StDevPer = 10; // lenght of StDev
extern int StDevMode = 1; // mode of StDev - 0=SMA, 1=EMA, 2=SMMA, 3=LWMA
树濑
extern int Spacing = 10; // Minimum distance of orders placed against the trend of the initial order, In effect only if AutoSpacing=fal
extern int TrendSpacing = 1000; // Minimum distance of orders placed with the trend of the initial order (t to 1000 to disable )
extern string TradeWindowSet = "Trade Session Hours in rver time";
extern bool UTradeTime = true;
extern int StartSession1 = 21;
extern int EndSession1 = 9;
extern bool Sunday = true;
extern bool Monday = true;
extern bool Tuesday = true;
extern bool Wednesday = true;
extern bool Thursday = true;
extern bool Friday
= true;
extern bool NFP_Friday = fal;
//+------------------------------------------------------------------+
//| Internal Parameters Set |
//+------------------------------------------------------------------+
string EA_name = "Piplite ?2009, J Talon LLC";
double stoploss = 0;
int slip = 0;
int Error = 0;
int Order = 0;
int Reference = 0;
double TickPrice = 0;
bool TradeShort = true; //Allow place ll ordes
bool TradeLong = true; //Allow place buy orders
int OpenOnTick = 0;
int MaxBuys = 0;
int MaxSells = 0;
double MaxProfit = 0;
bool Auditing = fal;
string Filename;
double initialBalance;
int lotPrecision;
double POSL;
int count;
bool TradeAllowed = true;
double PortionBalance, PortionEquity;社保卡一卡通
int BrokerDecimal = 1;
string Session = "Not Trading Time";
string POSL_On = "No";
double buysl, llsl;
// Previously t external parameters now internalized for
bool RightSideLabel = fal;
int MaximumBuyOrders = 100;
int MaximumSellOrders = 100;
int ForcedStart = 0; // 1 = New cycle will start if signal is for long, 2 = New cycle will start if signal is for short, 0 = disabled
int CloDelay = 91; // Minimum clo time for IBFX to not be considered scalping
double SL = 0; // Performs better with no initial stoploss.
//+------------------------------------------------------------------+
//| Internal Initialization |
//+------------------------------------------------------------------+
int init()
{
if (Symbol() == "AUDCADm" || Symbol() == "AUDCAD") Reference = 801001;
if (Symbol() == "AUDJPYm" || Symbol() == "AUDJPY") Reference = 801002;
if (Symbol() == "AUDNZDm" || Symbol() == "AUDNZD") Reference = 801003;
if (Symbol() == "AUDUSDm" || Symbol() == "AUDUSD") Reference = 801004;
if (Symbol() == "CHFJPYm" || Symbol() == "CHFJPY") Reference = 801005;
if (Symbol() == "EURAUDm" || Symbol() == "EURAUD") Reference = 801006;
if (Symbol() == "EURCADm" || Symbol() == "EURCAD") Reference = 801007;
if (Symbol() == "EURCHFm" || Symbol() == "EURCHF") Reference = 801008;
if (Symbol() == "EURGBPm" || Symbol() == "EURGBP") Reference = 801009;
if (Symbol() == "EURJPYm" || Symbol() == "EURJPY") Reference = 801010;
if (Symbol() == "EURUSDm" || Symbol() == "EURUSD") Reference = 801011;
英文名字女生
if (Symbol() =
= "GBPCHFm" || Symbol() == "GBPCHF") Reference = 801012;
if (Symbol() == "GBPJPYm" || Symbol() == "GBPJPY") Reference = 801013;
if (Symbol() == "GBPUSDm" || Symbol() == "GBPUSD") Reference = 801014;
if (Symbol() == "NZDJPYm" || Symbol() == "NZDJPY") Reference = 801015;
if (Symbol() == "NZDUSDm" || Symbol() == "NZDUSD") Reference = 801016;
if (Symbol() == "USDCHFm" || Symbol() == "USDCHF") Reference = 801017;
if (Symbol() == "USDJPYm" || Symbol() == "USDJPY") Reference = 801018;
if (Symbol() == "USDCADm" || Symbol() == "USDCAD") Reference = 801019;
if (Reference == 0) Reference = 801999;
initialBalance= AccountBalance();
Filename = StringConcatenate(EA_name+"_",Symbol(),"_",Period(),"_M",".txt");
CalculateLotPrecision();
return(0);
}
int deinit()
//+------------------------------------------------------------------+
//| External Functions |
//+------------------------------------------------------------------+
{
if(ObjectFind("MidPoint")==0){
ObjectDelete("MidPoint");
}
if(ObjectFind("MarginPercent")==0){
ObjectDelete("MarginPercent");
}
if(ObjectFind("LowMarginPercent")==0){
ObjectDelete("LowMarginPercent");
}
Comment("");
return(0);
}
void CalculateLotPrecision(){
double lotstep=MarketInfo(Symbol(),MODE_LOTSTEP);
if(lotstep==1) lotPrecision=0;
if(lotstep==0.1) lotPrecision=1;
if(lotstep==0.01) lotPrecision=2;
if(lotstep==0.001) lotPrecision=3;
}
//+------------------------------------------------------------------+
//| Money Management and Lot size coding |
//+------------------------------------------------------------------+
double AutoLot()
{
double lot;
lot=NormalizeDouble(Accounttype*((AccountBalance()/10000)*(MaximumRisk/100))/Portion,lotPrecision);
//Determine Lot size boundries from minimum to maximum
//Number bad on max lots at the 16 total order Point
//This allows for continued trading with large amounts
//Will keep from getting ordernd error 131 on large accounts
//Standard 100/17 = 5.88
//Micro 50/17 = 2.94
if(lot<0.01) lot=0.01;
乡村的英文if(lot < MarketInfo(Symbol(),MODE_MINLOT)) lot = MarketInfo(Symbol(),MODE_MINLOT);
if(lot>5.88 && Accounttype == 1) lot=5.88;
if(lot>2.94 && Accounttype == 10) lot=2.94;
return(lot);
}
void PlaceBuyOrder()
{
double BuyOrders, Lots;
double LowestBuy = 1000, HighestBuy;
TickPrice = 0;
RefreshRates();
for (Order = OrdersTotal() - 1; Order >= 0; Order--)
{
if (OrderSelect(Order, SELECT_BY_POS, MODE_TRADES))
{
if (OrderSymbol() == Symbol() && OrderMagicNumber() == Reference && OrderType() == OP_BUY)
{
if (OrderOpenPrice() < LowestBuy) LowestBuy = OrderOpenP
rice();
if (OrderOpenPrice() > HighestBuy) HighestBuy = OrderOpenPrice();
BuyOrders++;
}
}
}
if(MoneyMangement){
LotSize=AutoLot();
if(LotIncrement>0) LotIncrement=LotSize;
}
Lots = NormalizeDouble(LotSize + (LotIncrement * BuyOrders), lotPrecision);
if(BuyOrders==0) Lots = NormalizeDouble(LotSize, lotPrecision);
if (Lots == 0) Lots = NormalizeDouble(LotSize, lotPrecision);
if(IsTradeAllowed()==true && (BuyOrders < MaximumBuyOrders))
{
if (SL == 0) stoploss = 0;
el stoploss = Ask - ((SL*BrokerDecimal) * Point);
slip=Slippage*BrokerDecimal;
OrderSend(Symbol(), OP_BUY, Lots, Ask, slip, stoploss, 0, TradeComment, Reference, 0, Green);
}
Error = GetLastError();
if (Error != 0)
Write("Error opening BUY order: " + ErrorDescription(Error) + " (C" + Error + ") Ask:" + Ask + " Slippage:" + Slippage);
el
{
TickPrice = Clo[0];
}
}
void PlaceSellOrder()
{
double SellOrders, Lots;
double HighestSell, LowestSell = 1000;
TickPrice = 0;
RefreshRates();
for (Order = OrdersTotal() - 1; Order >= 0; Order--)
{
if (OrderSelect(Order, SELECT_BY_POS, MODE_TRADES))
{
if (OrderSymbol() == Symbol() && OrderMagicNumber() == Reference && OrderType() == OP_SELL)
{
if (OrderOpenPrice() > HighestSell) HighestSell = OrderOpenPrice();
if (OrderOpenPrice() < LowestSell) LowestSell = OrderOpenPrice();
SellOrders++;
}
}
}
if(MoneyMangement){
LotSize=AutoLot();
if(LotIncrement>0) LotIncrement=LotSize;
}
Lots = NormalizeDouble(LotSize + (LotIncrement * SellOrders), lotPrecision);
if(SellOrders==0) Lots = NormalizeDouble(LotSize, lotPrecision);
if (Lots == 0) Lots = NormalizeDouble(LotSize, lotPrecision);
if(IsTradeAllowed()==true && (SellOrders < MaximumSellOrders))
{
if (SL == 0) stoploss = 0;
el stoploss = Bid + ((SL*BrokerDecimal) * Point);
slip=Slippage*BrokerDecimal;
OrderSend(Symbol(), OP_SELL, Lots, Bid, slip, stoploss, 0, TradeComment, Reference, 0, Red);
}
Error = GetLastError();
if (Error != 0)
Write("Error opening SELL order: " + ErrorDescription(Error) + " (D" + Error + ") Bid:" + Bid + " Slippage:" + Slippage);
大桥下面电影
el
{
TickPrice = Clo[0];
}
}
void CloAllBuyProfit()
{
int spread=MarketInfo(Symbol(),MODE_SPREAD);
for(int i = OrdersTotal()-1; i >=0; i--)
{
OrderSelect(i, SELECT_BY_POS);
bool result = fal;
if (OrderSymbol()==Symbol() && OrderMagicNumber() == Reference && OrderType() == OP_BUY)
{
slip=Slippage*BrokerDecimal;
if (TimeCurrent()-