Vondereich
CG Top Poster Club

- Messages
- 23,951
- Joined
- Jan 11, 2008
- Messages
- 23,951
- Reaction score
- 951
- Points
- 176
Den test buat coding guna etasoft punya software.. tapi try manual add blok martin manjang x jadi..
Sapa leh ejas code ni asal jd martin..
Kalau ok bole guna sama
Sapa leh ejas code ni asal jd martin..
Kalau ok bole guna sama
PHP:
#property copyright "https://facebook.com/kurama87"
#property version "1.0"
#property link "https://Facebook.com/kurama87"
#property description "Groups: https://www.facebook.com/kurama87"
#property description " "
#property description " "
#include <stdlib.mqh>
#include <WinUser32.mqh>
// exported variables
extern double BuyLots23 = 0.01;
extern int BuyStoploss23 = 0;
extern int BuyTakeprofit23 = 15;
extern double SellLots22 = 0.01;
extern int SellStoploss22 = 0;
extern int SellTakeprofit22 = 15;
// local variables
double PipValue=1; // this variable is here to support 5-digit brokers
bool Terminated = false;
string LF = "\n"; // use this in custom or utility blocks where you need line feeds
int NDigits = 4; // used mostly for NormalizeDouble in Flex type blocks
int ObjCount = 0; // count of all objects created on the chart, allows creation of objects with unique names
int current = 0; // current bar index, used by Cross Up, Cross Down and many other blocks
int varylots[101]; // used by Buy Order Varying, Sell Order Varying and similar
datetime BarTime15 = 0;
datetime BarTime20 = 0;
int Count16 = 0;
int init()
{
NDigits = Digits;
if (false) ObjectsDeleteAll(); // clear the chart
Comment(""); // clear the chart
return (0);
**
// Expert start
int start()
{
if (Bars < 10)
{
Comment("Not enough bars");
return (0);
**
if (Terminated == true)
{
Comment("EA Terminated.");
return (0);
**
OnEveryTick12();
return (0);
**
void OnEveryTick12()
{
PipValue = 1;
if (NDigits == 3 || NDigits == 5) PipValue = 10;
TechnicalAnalysis17();
TechnicalAnalysis18();
PrintInfoToChart16();
**
void TechnicalAnalysis17()
{
if (Close[1] < iMA(NULL, PERIOD_CURRENT,50,0,MODE_EMA,PRICE_CLOSE,current))
{
IfOrderDoesNotExist13();
**
**
void IfOrderDoesNotExist13()
{
bool exists = false;
for (int i=OrdersTotal()-1; i >= 0; i--)
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
{
if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == 1)
{
exists = true;
**
**
else
{
Print("OrderSelect() error - ", ErrorDescription(GetLastError()));
**
if (exists == false)
{
IfOrderDoesNotExist14();
**
**
void IfOrderDoesNotExist14()
{
bool exists = false;
for (int i=OrdersTotal()-1; i >= 0; i--)
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
{
if (OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == 1)
{
exists = true;
**
**
else
{
Print("OrderSelect() error - ", ErrorDescription(GetLastError()));
**
if (exists == false)
{
OncePerBar15();
**
**
void OncePerBar15()
{
if (BarTime15 < Time[0])
{
// we have a new bar opened
BarTime15 = Time[0]; // keep the new bar open time
BuyOrder23();
**
**
void BuyOrder23()
{
double SL = Ask - BuyStoploss23*PipValue*Point;
if (BuyStoploss23 == 0) SL = 0;
double TP = Ask + BuyTakeprofit23*PipValue*Point;
if (BuyTakeprofit23 == 0) TP = 0;
int ticket = -1;
if (true)
ticket = OrderSend(Symbol(), OP_BUY, BuyLots23, Ask, 4, 0, 0, "My Expert", 1, 0, Blue);
else
ticket = OrderSend(Symbol(), OP_BUY, BuyLots23, Ask, 4, SL, TP, "My Expert", 1, 0, Blue);
if (ticket > -1)
{
if (true)
{
bool sel = OrderSelect(ticket, SELECT_BY_TICKET);
bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0, Blue);
if (ret == false)
Print("OrderModify() error - ", ErrorDescription(GetLastError()));
**
**
else
{
Print("OrderSend() error - ", ErrorDescription(GetLastError()));
**
**
void TechnicalAnalysis18()
{
if (Open[1] > iMA(NULL, PERIOD_CURRENT,50,0,MODE_EMA,PRICE_CLOSE,current))
{
IfOrderDoesNotExist21();
**
**
void IfOrderDoesNotExist21()
{
bool exists = false;
for (int i=OrdersTotal()-1; i >= 0; i--)
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
{
if (OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == 2)
{
exists = true;
**
**
else
{
Print("OrderSelect() error - ", ErrorDescription(GetLastError()));
**
if (exists == false)
{
IfOrderDoesNotExist19();
**
**
void IfOrderDoesNotExist19()
{
bool exists = false;
for (int i=OrdersTotal()-1; i >= 0; i--)
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
{
if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == 2)
{
exists = true;
**
**
else
{
Print("OrderSelect() error - ", ErrorDescription(GetLastError()));
**
if (exists == false)
{
OncePerBar20();
**
**
void OncePerBar20()
{
if (BarTime20 < Time[0])
{
// we have a new bar opened
BarTime20 = Time[0]; // keep the new bar open time
SellOrder22();
**
**
void SellOrder22()
{
double SL = Bid + SellStoploss22*PipValue*Point;
if (SellStoploss22 == 0) SL = 0;
double TP = Bid - SellTakeprofit22*PipValue*Point;
if (SellTakeprofit22 == 0) TP = 0;
int ticket = -1;
if (true)
ticket = OrderSend(Symbol(), OP_SELL, SellLots22, Bid, 4, 0, 0, "My Expert", 2, 0, Red);
else
ticket = OrderSend(Symbol(), OP_SELL, SellLots22, Bid, 4, SL, TP, "My Expert", 2, 0, Red);
if (ticket > -1)
{
if (true)
{
bool sel = OrderSelect(ticket, SELECT_BY_TICKET);
bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0, Red);
if (ret == false)
Print("OrderModify() error - ", ErrorDescription(GetLastError()));
**
**
else
{
Print("OrderSend() error - ", ErrorDescription(GetLastError()));
**
**
void PrintInfoToChart16()
{
string temp = "Howdy\nExecuted : " + Count16 + "\n"
+ "Spread: " + DoubleToStr(MarketInfo(Symbol(), MODE_SPREAD)/PipValue, 2)+ "\n"
+ "------------------------------------------------\n"
+ "ACCOUNT INFORMATION:\n"
+ "\n"
+ "Account Name: " + AccountName()+ "\n"
+ "Account Leverage: " + DoubleToStr(AccountLeverage(), 0)+ "\n"
+ "Account Balance: " + DoubleToStr(AccountBalance(), 2)+ "\n"
+ "Account Equity: " + DoubleToStr(AccountEquity(), 2)+ "\n"
+ "Free Margin: " + DoubleToStr(AccountFreeMargin(), 2)+ "\n"
+ "Used Margin: " + DoubleToStr(AccountMargin(), 2)+ "\n"
+ "------------------------------------------------\n";
Comment(temp);
Count16++;
**
int deinit()
{
if (false) ObjectsDeleteAll();
return (0);
**