ءر¹ Error حآèز§¹صé ¤أر؛
2014.08.26 21:18:09.109 test_GBPUSD GBPUSDm,M5: Error: 0
2014.08.26 21:14:53.875 test_GBPUSD GBPUSDm,M5: trade operations not allowed by settings
µراâ»أل،أء¹ذ¤أر؛
#property copyright "SAFE"
#property link "ima,ist"
double Stoploss = 200.0;
double TrailStart = 10.0;
double TrailStop = 10.0;
//ييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييي
extern double LotExponent = 1.00; // µرا¤ظ³ ;
extern double slip = 3.0;
extern double Lots = 0.01;
extern int lotdecimal = 2;
extern double TakeProfit = 100.0;
extern double Pipstep = 200.0;
extern double PipStepExponent = 1.3;
extern string Quant = " TRUE ي";
extern bool QuantumStep = true;
extern string StartStepExpSrting = "GBPUSD";
extern int StartStepExp = 5;
extern double RsiMinimum = 30.0;
extern double RsiMaximum = 70.0;
extern int MagicNumber = 6789;
extern int oder = 0;
extern int Ans = 0;
extern int Tic = 0;
//يييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييي
extern int MaxTrades = 1;
bool UseEquityStop = FALSE;
double TotalEquityRisk = 20.0;
bool UseTrailingStop = FALSE;
bool UseTimeOut = FALSE;
double MaxTradeOpenHours = 48.0;
//يييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييي
double PriceTarget, StartEquity, BuyTarget, SellTarget;
double AveragePrice, SellLimit, BuyLimit;
double LastBuyPrice, LastSellPrice, Spread;
bool flag;
string EAName="Chart G/U";
int timeprev = 0, expiration;
int NumOfTrades = 0;
double iLots;
double PipStepE;
int cnt = 0, total;
double Stopper = 0.0;
bool TradeNow = FALSE, LongTrade = FALSE, ShortTrade = FALSE;
int ticket;
bool NewOrdersPlaced = FALSE;
double AccountEquityHighAmt, PrevEquity;
//يييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييي
int init() {
Spread = MarketInfo(Symbol(), MODE_SPREAD) * Point;
return (0);
}
int deinit() {
return (0);
}
//يييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييي
int start() {
double space=((Ask-Bid)*100000);
int mg=AccountMargin();
int fmg=AccountFreeMargin();
double PrevCl;
double CurrCl;
double Price=0;
int ist1=100;
int icc=100;
int mfi=14;
double y1=iMA(NULL,PERIOD_H4,5,8,MODE_SMMA,PRICE_MEDIAN,0);
double y2=iMA(NULL,PERIOD_H4,7,8,MODE_SMMA,PRICE_MEDIAN,0);
double y3=iMA(NULL,PERIOD_H4,10,8,MODE_SMMA,PRICE_MEDIAN,0);
double y4=iMA(NULL,PERIOD_H4,14,8,MODE_SMMA,PRICE_MEDIAN,0);
double z1=iMA(NULL,PERIOD_H4,5,8,MODE_SMMA,PRICE_MEDIAN,2);
double z2=iMA(NULL,PERIOD_H4,5,8,MODE_SMMA,PRICE_MEDIAN,1);
double z3=iMA(NULL,PERIOD_H4,5,8,MODE_SMMA,PRICE_MEDIAN,0);
Price=iClose(Symbol(), 0, 2)-iClose(Symbol(), 0, 1);
int rsi= iRSI(NULL, PERIOD_H1, 14, PRICE_CLOSE, 1);
Comment("s",space," ",Pipstep,"_",TakeProfit,"X",LotExponent," R",rsi," P",Price," A ",Ans," T ",total," Y ",y1,"-",y2,"-",y3,"-",y4," mg ",mg,"/",fmg);
if(total>0){ TakeProfit = 1.0;}
Ans=0;
// -1 buy 1 sell ;
if(y1<y2) { if(y2<y3) {if(y3<y4) { if(z1>z2) {if(z2>z3){ Ans=1; }}}}}//sell;
if(y1>y2) { if(y2>y3) {if(y3>y4) { if(z1<z2) {if(z2<z3){ Ans=-1; }}}}}// buy;
int mm=Tic;
//tic =1 buy > close buy;
//tic = -1 sell > close sell;
if( total>0) {
if(Tic==1){
if(y1<y2) { Sleep(2000);Comment(" close buy U/J");
Closebuy();
}}
if(Tic==-1){
if(y1>y2) { Sleep(2000);Comment(" close sell U/J");
Closesell();
}}
}
if(mg*1>fmg*1)
{
Comment(" margin it Dander
"," margin= ",mg," freemagin= ",fmg," RSI= ",iRSI(NULL, PERIOD_H1, 14, PRICE_CLOSE, 1));
Sleep(5000);
return (0);
}
if(space>25)
{
Comment(" space over 25 now= ",space);
Sleep(5000);
return (0);
}
int PipStepE = NormalizeDouble(Pipstep*MathPow(PipStepExp(NumOfTrades),TradeStepExp(NumOfTrades)),0);
//PipStep = NormalizeDouble(Pipstep * MathPow(PipStepExponent, NumOfTrades), 0);
if (UseTrailingStop) TrailingAlls(TrailStart, TrailStop, AveragePrice);
if (UseTimeOut) {
if (TimeCurrent() >= expiration) {
CloseThisSymbolAll();
Print("Closed All due to TimeOut");
}
}
if (timeprev == Time[0]) return (0);
timeprev = Time[0];
double CurrentPairProfit = CalculateProfit();
if (UseEquityStop) {
if (CurrentPairProfit < 0.0 && MathAbs(CurrentPairProfit) > TotalEquityRisk / 100.0 * AccountEquityHigh()) {
CloseThisSymbolAll();
Print("Closed All due to Stop Out");
NewOrdersPlaced = FALSE;
}
}
total = CountTrades();
if (total == 0) flag = FALSE;
for (cnt = OrdersTotal() - 1; cnt >= 0; cnt--) {
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) {
if (OrderType() == OP_BUY) {
LongTrade = TRUE;
ShortTrade = FALSE;
break;
}
}
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) {
if (OrderType() == OP_SELL) {
LongTrade = FALSE;
ShortTrade = TRUE;
break;
}
}
}
if (total > 0 && total <= MaxTrades) {
RefreshRates();
LastBuyPrice = FindLastBuyPrice();
LastSellPrice = FindLastSellPrice();
// if (LongTrade && LastBuyPrice - Ask >= PipStepE * Point) TradeNow = TRUE;
// if (ShortTrade && Bid - LastSellPrice >= PipStepE * Point) TradeNow = TRUE;
if (ShortTrade && Bid - LastSellPrice >= PipStepE * Point) TradeNow = TRUE;
if (LongTrade && LastBuyPrice - Ask >= PipStepE * Point) TradeNow = TRUE;
}
if (total < 1) {
ShortTrade = FALSE;
LongTrade = FALSE;
TradeNow = TRUE;
StartEquity = AccountEquity();
}
if (TradeNow) {
LastBuyPrice = FindLastBuyPrice();
LastSellPrice = FindLastSellPrice();
if (ShortTrade) {
NumOfTrades = total;
iLots = NormalizeDouble(Lots * MathPow(LotExponent, NumOfTrades), lotdecimal);
RefreshRates();
ticket = OpenPendingOrder(1, iLots, Bid, slip, Ask, 0, 0, EAName + "-" + NumOfTrades, MagicNumber, 0, HotPink);
if (ticket < 0) {
Print("Error: ", GetLastError());
return (0);
}
LastSellPrice = FindLastSellPrice();
TradeNow = FALSE;
NewOrdersPlaced = TRUE;
} else {
if (LongTrade) {
NumOfTrades = total;
iLots = NormalizeDouble(Lots * MathPow(LotExponent, NumOfTrades), lotdecimal);
ticket = OpenPendingOrder(0, iLots, Ask, slip, Bid, 0, 0, EAName + "-" + NumOfTrades, MagicNumber, 0, Lime);
if (ticket < 0) {
Print("Error: ", GetLastError());
return (0);
}
LastBuyPrice = FindLastBuyPrice();
TradeNow = FALSE;
NewOrdersPlaced = TRUE;
}
}
}
if (TradeNow && total < 1) {
PrevCl = iClose(Symbol(), 0, 2);
CurrCl = iClose(Symbol(), 0, 1);
TakeProfit = 150.0;
SellLimit = Bid;
BuyLimit = Ask;
if (!ShortTrade && !LongTrade) {
NumOfTrades = total;
iLots = NormalizeDouble(Lots * MathPow(LotExponent, NumOfTrades), lotdecimal);
if (PrevCl > CurrCl) { if(Ans>0){
if (iRSI(NULL, PERIOD_H1, 14, PRICE_CLOSE, 1) > RsiMinimum) {
ticket = OpenPendingOrder(1, iLots, SellLimit, slip, SellLimit, 0, 0, EAName + "-" + NumOfTrades, MagicNumber, 0, HotPink);
if (ticket < 0) {
Print("Error: ", GetLastError());
return (0);
}
LastBuyPrice = FindLastBuyPrice();
NewOrdersPlaced = TRUE;
}}
} else { if(Ans<0){
if (iRSI(NULL, PERIOD_H1, 14, PRICE_CLOSE, 1) < RsiMaximum) {
ticket = OpenPendingOrder(0, iLots, BuyLimit, slip, BuyLimit, 0, 0, EAName + "-" + NumOfTrades, MagicNumber, 0, Lime);
if (ticket < 0) {
Print("Error: ", GetLastError());
return (0);
}
LastSellPrice = FindLastSellPrice();
NewOrdersPlaced = TRUE;
}}
}
if (ticket > 0) expiration = TimeCurrent() + 60.0 * (60.0 * MaxTradeOpenHours);
TradeNow = FALSE;
}
}
total = CountTrades();
oder=total;
AveragePrice = 0;
double Count = 0;
for (cnt = OrdersTotal() - 1; cnt >= 0; cnt--) {
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) {
if (OrderType() == OP_BUY || OrderType() == OP_SELL) {
AveragePrice += OrderOpenPrice() * OrderLots();
Count += OrderLots();
}
}
}
if (total > 0) AveragePrice = NormalizeDouble(AveragePrice / Count, Digits);
if (NewOrdersPlaced) {
for (cnt = OrdersTotal() - 1; cnt >= 0; cnt--) {
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) {
if (OrderType() == OP_BUY) {
PriceTarget = AveragePrice + TakeProfit * Point;
BuyTarget = PriceTarget;
Stopper = AveragePrice - Stoploss * Point;
flag = TRUE;
}
}
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) {
if (OrderType() == OP_SELL) {
PriceTarget = AveragePrice - TakeProfit * Point;
SellTarget = PriceTarget;
Stopper = AveragePrice + Stoploss * Point;
flag = TRUE;
}
}
}
}
if (NewOrdersPlaced) {
if (flag == TRUE) {
for (cnt = OrdersTotal() - 1; cnt >= 0; cnt--) {
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) OrderModify(OrderTicket(), AveragePrice, OrderStopLoss(), PriceTarget, 0, Yellow);
NewOrdersPlaced = FALSE;
}
}
}
return (0);
}
//ييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييي
int CountTrades() {
int count = 0;
for (int trade = OrdersTotal() - 1; trade >= 0; trade--) {
OrderSelect(trade, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber)
if (OrderType() == OP_SELL || OrderType() == OP_BUY) count++;
if (OrderType() == OP_SELL) Tic=-1;
if (OrderType() == OP_BUY) Tic=1;
}
return (count);
}
//يييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييي
void CloseThisSymbolAll() {
for (int trade = OrdersTotal() - 1; trade >= 0; trade--) {
OrderSelect(trade, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() == Symbol()) {
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) {
if (OrderType() == OP_BUY) OrderClose(OrderTicket(), OrderLots(), Bid, slip, Blue);
if (OrderType() == OP_SELL) OrderClose(OrderTicket(), OrderLots(), Ask, slip, Red);
}
Sleep(1000);
}
}
}
//يييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييي
int OpenPendingOrder(int pType, double pLots, double pLevel, int sp, double pr, int sl, int tp, string pComment, int pMagic, int pDatetime, color pColor) {
int ticket = 0;
int err = 0;
int c = 0;
int NumberOfTries = 100;
switch (pType) {
case 2:
for (c = 0; c < NumberOfTries; c++) {
ticket = OrderSend(Symbol(), OP_BUYLIMIT, pLots, pLevel, sp, StopLong(pr, sl), TakeLong(pLevel, tp), pComment, pMagic, pDatetime, pColor);
err = GetLastError();
if (err == 0/* NO_ERROR */) break;
if (!(err == 4/* SERVER_BUSY */ || err == 137/* BROKER_BUSY */ || err == 146/* TRADE_CONTEXT_BUSY */ || err == 136/* OFF_QUOTES */)) break;
Sleep(1000);
}
break;
case 4:
for (c = 0; c < NumberOfTries; c++) {
ticket = OrderSend(Symbol(), OP_BUYSTOP, pLots, pLevel, sp, StopLong(pr, sl), TakeLong(pLevel, tp), pComment, pMagic, pDatetime, pColor);
err = GetLastError();
if (err == 0/* NO_ERROR */) break;
if (!(err == 4/* SERVER_BUSY */ || err == 137/* BROKER_BUSY */ || err == 146/* TRADE_CONTEXT_BUSY */ || err == 136/* OFF_QUOTES */)) break;
Sleep(5000);
}
break;
case 0:
for (c = 0; c < NumberOfTries; c++) {
RefreshRates();
ticket = OrderSend(Symbol(), OP_BUY, pLots, Ask, sp, StopLong(Bid, sl), TakeLong(Ask, tp), pComment, pMagic, pDatetime, pColor);
err = GetLastError();
if (err == 0/* NO_ERROR */) break;
if (!(err == 4/* SERVER_BUSY */ || err == 137/* BROKER_BUSY */ || err == 146/* TRADE_CONTEXT_BUSY */ || err == 136/* OFF_QUOTES */)) break;
Sleep(5000);
}
break;
case 3:
for (c = 0; c < NumberOfTries; c++) {
ticket = OrderSend(Symbol(), OP_SELLLIMIT, pLots, pLevel, sp, StopShort(pr, sl), TakeShort(pLevel, tp), pComment, pMagic, pDatetime, pColor);
err = GetLastError();
if (err == 0/* NO_ERROR */) break;
if (!(err == 4/* SERVER_BUSY */ || err == 137/* BROKER_BUSY */ || err == 146/* TRADE_CONTEXT_BUSY */ || err == 136/* OFF_QUOTES */)) break;
Sleep(5000);
}
break;
case 5:
for (c = 0; c < NumberOfTries; c++) {
ticket = OrderSend(Symbol(), OP_SELLSTOP, pLots, pLevel, sp, StopShort(pr, sl), TakeShort(pLevel, tp), pComment, pMagic, pDatetime, pColor);
err = GetLastError();
if (err == 0/* NO_ERROR */) break;
if (!(err == 4/* SERVER_BUSY */ || err == 137/* BROKER_BUSY */ || err == 146/* TRADE_CONTEXT_BUSY */ || err == 136/* OFF_QUOTES */)) break;
Sleep(5000);
}
break;
case 1:
for (c = 0; c < NumberOfTries; c++) {
ticket = OrderSend(Symbol(), OP_SELL, pLots, Bid, sp, StopShort(Ask, sl), TakeShort(Bid, tp), pComment, pMagic, pDatetime, pColor);
err = GetLastError();
if (err == 0/* NO_ERROR */) break;
if (!(err == 4/* SERVER_BUSY */ || err == 137/* BROKER_BUSY */ || err == 146/* TRADE_CONTEXT_BUSY */ || err == 136/* OFF_QUOTES */)) break;
Sleep(5000);
}
}
return (ticket);
}
//يييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييي
double StopLong(double price, int stop) {
if (stop == 0) return (0);
else return (price - stop * Point);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
double StopShort(double price, int stop) {
if (stop == 0) return (0);
else return (price + stop * Point);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
double TakeLong(double price, int stop) {
if (stop == 0) return (0);
else return (price + stop * Point);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
double TakeShort(double price, int stop) {
if (stop == 0) return (0);
else return (price - stop * Point);
}
//يييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييي
double CalculateProfit() {
double Profit = 0;
for (cnt = OrdersTotal() - 1; cnt >= 0; cnt--) {
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber)
if (OrderType() == OP_BUY || OrderType() == OP_SELL) Profit += OrderProfit();
}
return (Profit);
}
//يييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييي
void TrailingAlls(int pType, int stop, double AvgPrice) {
int profit;
double stoptrade;
double stopcal;
if (stop != 0) {
for (int trade = OrdersTotal() - 1; trade >= 0; trade--) {
if (OrderSelect(trade, SELECT_BY_POS, MODE_TRADES)) {
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber) continue;
if (OrderSymbol() == Symbol() || OrderMagicNumber() == MagicNumber) {
if (OrderType() == OP_BUY) {
profit = NormalizeDouble((Bid - AvgPrice) / Point, 0);
if (profit < pType) continue;
stoptrade = OrderStopLoss();
stopcal = Bid - stop * Point;
if (stoptrade == 0.0 || (stoptrade != 0.0 && stopcal > stoptrade)) OrderModify(OrderTicket(), AvgPrice, stopcal, OrderTakeProfit(), 0, Aqua);
}
if (OrderType() == OP_SELL) {
profit = NormalizeDouble((AvgPrice - Ask) / Point, 0);
if (profit < pType) continue;
stoptrade = OrderStopLoss();
stopcal = Ask + stop * Point;
if (stoptrade == 0.0 || (stoptrade != 0.0 && stopcal < stoptrade)) OrderModify(OrderTicket(), AvgPrice, stopcal, OrderTakeProfit(), 0, Red);
}
}
Sleep(1000);
}
}
}
}
//يييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييي
double AccountEquityHigh() {
if (CountTrades() == 0) AccountEquityHighAmt = AccountEquity();
if (AccountEquityHighAmt < PrevEquity) AccountEquityHighAmt = PrevEquity;
else AccountEquityHighAmt = AccountEquity();
PrevEquity = AccountEquity();
return (AccountEquityHighAmt);
}
//يييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييي
double FindLastBuyPrice() {
double oldorderopenprice;
int oldticketnumber;
double unused = 0;
int ticketnumber = 0;
for (int cnt = OrdersTotal() - 1; cnt >= 0; cnt--) {
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber && OrderType() == OP_BUY) {
oldticketnumber = OrderTicket();
if (oldticketnumber > ticketnumber) {
oldorderopenprice = OrderOpenPrice();
unused = oldorderopenprice;
ticketnumber = oldticketnumber;
}
}
}
return (oldorderopenprice);
}
double FindLastSellPrice() {
double oldorderopenprice;
int oldticketnumber;
double unused = 0;
int ticketnumber = 0;
for (int cnt = OrdersTotal() - 1; cnt >= 0; cnt--) {
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber && OrderType() == OP_SELL) {
oldticketnumber = OrderTicket();
if (oldticketnumber > ticketnumber) {
oldorderopenprice = OrderOpenPrice();
unused = oldorderopenprice;
ticketnumber = oldticketnumber;
}
}
}
return (oldorderopenprice);
}
//ييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييييي
//--------------------حà÷èيàهى ًàٌٍèٍü ّàم ٌïٌٍَے StartStepExp êîëهي-------------------------------
double PipStepExp(int Step)
{
double QStepEx = 0;
if(QuantumStep == true && Step >= StartStepExp)
QStepEx = PipStepExponent;
else
QStepEx = 1;
return (QStepEx);
}
//==================== ر÷èٍàهى êîëهيè ============================
int TradeStepExp(int Trades)
{
double TradeStep = 0;
if(QuantumStep == true && Trades >= StartStepExp)
TradeStep = Trades - StartStepExp + 1;
else
TradeStep = Trades;
return (TradeStep);
}
//=============================================;
void Closebuy() {
for (int trade = OrdersTotal() - 1; trade >= 0; trade--) {
OrderSelect(trade, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() == Symbol()) {
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) {
if (OrderType() == OP_BUY) OrderClose(OrderTicket(), OrderLots(), Bid, slip, Blue); Print(" close buy USDJPY ");
}
Sleep(500);
}
}
}
void Closesell() {
for (int trade = OrdersTotal() - 1; trade >= 0; trade--) {
OrderSelect(trade, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() == Symbol()) {
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) {
if (OrderType() == OP_SELL) OrderClose(OrderTicket(), OrderLots(), Ask, slip, Red); Print(" close sell USDJPY ");
}
Sleep(500);
}
}
}