Orders Execution
0
Views
0
Downloads
0
Favorites
Profitability Reports
AUD/USD
Oct 2024 - Jan 2025
0.00 %
Total Trades
0
Won Trades
0
Lost trades
0
Win Rate
0.0 %
Expected payoff
0.00
Gross Profit
0.00
Gross Loss
0.00
Total Net Profit
0.00
-100%
-50%
0%
50%
100%
NZD/USD
Oct 2024 - Jan 2025
0.00 %
Total Trades
5
Won Trades
0
Lost trades
5
Win Rate
0.00 %
Expected payoff
-850.56
Gross Profit
0.00
Gross Loss
-4252.80
Total Net Profit
-4252.80
-100%
-50%
0%
50%
100%
Emily_v1
//| Copyright 2007, Cibber |
//| http://www.algunaweb.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2007, Cibber"
#property link "http://www.algunaweb.com"
extern int MaxTrades = 20;
extern int Pips = 20;
extern double TakeProfit = 240;
extern double TrailingStop = 220;
extern double InitialStop = 810;
extern string Note1 = "TF H4";
extern int MACDTimeFrame = 0;
int SecureProfit = 27;
int AccountProtection = 1;
int OrdersToProtect = 19;
int ReverseCondition = 0;
double FirstOrderLots=0.1;
int OrdersOpened = 0;
int cnt = 0;
double lots = 0.1;
int slippage = 5;
double stoploss = 0;
double takeprofit = 0;
double bprice = 0;
double sprice = 0;
double lotsi = 0;
int type = 0;
int state = 0;
bool EnableTrading = true;
double openprice = 0;
int PreviousOrders = 0;
double Profit = 0;
int LastTicket = 0;
int LastType = 0;
double LastClosePrice = 0;
double LastLots = 0;
double PipValue = 0;
string text2 = "";
string text = "";
double lotstmp;
double rel;
double trade;
int trendtype;
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
int init()
{
return(0);
}
//+------------------------------------------------------------------+
int deinit()
{
return(0);
}
//+------------------------------------------------------------------+
int start()
{
Check_trade();
FirstOrderLots = AccountBalance()/4000;
lotsi = FirstOrderLots;
if (lotsi > 100.0) lotsi = 100;
if (lotsi<0.01) lotsi=0.1;
OrdersOpened = 0;
for (cnt = 0; cnt < OrdersTotal(); cnt++)
{
OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
if (OrderSymbol() == Symbol()) OrdersOpened++;
}
PipValue=MarketInfo(Symbol(),MODE_TICKVALUE);
if (PipValue == 0.0) PipValue = 5;
if (PreviousOrders > OrdersOpened)
{
for (cnt = OrdersTotal(); cnt >= 0; cnt--)
{
OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
type = OrderType();
if (OrderSymbol() == Symbol())
{
if (type == OP_BUY) OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),slippage,Blue);
if (type == OP_SELL) OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),slippage,Red);
//return(0);
}
}
}
PreviousOrders = OrdersOpened;
if (OrdersOpened >= MaxTrades) EnableTrading = false; else EnableTrading = true;
if (openprice == 0.0)
{
for (cnt = 0; cnt < OrdersTotal(); cnt++)
{
OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
type = OrderType();
if (OrderSymbol() == Symbol())
{
openprice = OrderOpenPrice();
if (type == OP_BUY) state = 2;
if (type == OP_SELL) state = 1;
}
}
}
if (OrdersOpened < 1)
{
state = 3;
if (trendtype == 2) state = 2;
if (trendtype == 1) state = 1;
if (ReverseCondition == 1)
{
if (state == 1)
{
state = 2;
}
else
{
if (state == 2)
{
state = 1;
}
}
}
}
for (cnt = OrdersTotal(); cnt >= 0; cnt--)
{
OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
if (OrderSymbol() == Symbol())
{
if (OrderType() == OP_SELL)
{
if (TrailingStop > 0.0)
{
if (OrderOpenPrice() - Ask >= (TrailingStop + Pips) * Point)
{
if (OrderStopLoss() > Ask + Point * TrailingStop)
{
OrderModify(OrderTicket(),OrderOpenPrice(),Ask + Point * TrailingStop,OrderClosePrice() - TakeProfit * Point - TrailingStop * Point,800,Purple);
return(0);
}
}
}
}
if (OrderType() == OP_BUY)
{
if (TrailingStop > 0.0)
{
if (Bid - OrderOpenPrice() >= (TrailingStop + Pips) * Point)
{
if (OrderStopLoss() < Bid - Point * TrailingStop)
{
OrderModify(OrderTicket(),OrderOpenPrice(),Bid - Point * TrailingStop,OrderClosePrice() + TakeProfit * Point + TrailingStop * Point,800,Yellow);
return(0);
}
}
}
}
}
}
Profit = 0;
LastTicket = 0;
LastType = 0;
LastClosePrice = 0;
LastLots = 0;
for (cnt = 0; cnt < OrdersTotal(); cnt++)
{
OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
if (OrderSymbol() == Symbol())
{
LastTicket = OrderTicket();
if (OrderType() == OP_BUY) LastType = 0;
if (OrderType() == OP_SELL) LastType = 1;
LastClosePrice = OrderClosePrice();
LastLots = OrderLots();
if (LastType == 0)
{
if (OrderClosePrice() < OrderOpenPrice()) Profit -= (OrderOpenPrice() - OrderClosePrice()) * OrderLots() / Point;
if (OrderClosePrice() > OrderOpenPrice()) Profit += (OrderClosePrice() - OrderOpenPrice()) * OrderLots() / Point;
}
if (LastType == 1)
{
if (OrderClosePrice() > OrderOpenPrice()) Profit -= (OrderClosePrice() - OrderOpenPrice()) * OrderLots() / Point;
if (OrderClosePrice() < OrderOpenPrice()) Profit += (OrderOpenPrice() - OrderClosePrice()) * OrderLots() / Point;
}
}
}
Profit = Profit * PipValue;
text = "Profit: $" + DoubleToStr(Profit,2) + " +/-";
/*
if (LastType == 0 && state == 1)
{
OrderClose(LastTicket,LastLots,LastClosePrice,slippage,Yellow);
EnableTrading = false;
return(0);
}
if (LastType == 1 && state == 2)
{
OrderClose(LastTicket,LastLots,LastClosePrice,slippage,Yellow);
EnableTrading = false;
return(0);
}
*/
if ((OrdersOpened >= MaxTrades - OrdersToProtect) && (AccountProtection == 1))
{
if (Profit >= SecureProfit)
{
OrderClose(LastTicket,LastLots,LastClosePrice,slippage,Yellow);
EnableTrading = false;
return(0);
}
}
if (!IsTesting())
{
if (state == 3)
text2 = "No conditions to open trades";
else
text2 = " ";
}
if ((state == 1) && EnableTrading)
{
if ((Bid - openprice >= Pips * Point) || (OrdersOpened < 1))
{
sprice = Bid;
openprice = 0;
if (TakeProfit == 0.0)
takeprofit = 0;
else
takeprofit = sprice - TakeProfit * Point;
if (InitialStop == 0.0)
stoploss = 0;
else
stoploss = sprice + InitialStop * Point;
if (OrdersOpened != 0)
{
lots = lotsi;
for (cnt = 1; cnt <= OrdersOpened; cnt++)
{
if (MaxTrades>12) { lots=NormalizeDouble(lots*1.5,2); }
else { lots=NormalizeDouble(lots*2,2); }
}
}
else
{
lots = lotsi;
}
if (lots > 100.0) lots = 100;
OrderSend(Symbol(),OP_SELL,lots,sprice,slippage,stoploss,takeprofit,0,0,0,Red);
return(0);
}
}
if ((state == 2) && EnableTrading)
{
if ((openprice - Ask >= Pips * Point) || (OrdersOpened < 1))
{
bprice = Ask;
openprice = 0;
if (TakeProfit == 0.0) takeprofit = 0; else takeprofit = bprice + TakeProfit * Point;
if (InitialStop == 0.0) stoploss = 0; else stoploss = bprice - InitialStop * Point;
if (OrdersOpened != 0)
{
lots = lotsi;
for (cnt = 1; cnt <= OrdersOpened; cnt++)
{
if (MaxTrades>12) { lots=NormalizeDouble(lots*1.5,2); }
else { lots=NormalizeDouble(lots*2,2); }
}
}
else
{
lots = lotsi;
}
if (lots > 100.0) lots = 100;
OrderSend(Symbol(),OP_BUY,lots,bprice,slippage,stoploss,takeprofit,0,0,0,Blue);
return(0);
}
}
return(0);
}
void Check_trade()
{
trade = iCustom(Symbol(),PERIOD_H4, "RSIOMA_v2",0,0);
if(rel >= 0)
{
trendtype = 2;
}
if(rel < 0)
{
trendtype = 1;
}
return(0);
}
Comments
Markdown Formatting Guide
# H1
## H2
### H3
**bold text**
*italicized text*
[title](https://www.example.com)

`code`
```
code block
```
> blockquote
- Item 1
- Item 2
1. First item
2. Second item
---