Edit Your Comment
MT4 EA Not placing trades
Sep 27, 2017 at 14:45
Sep 13, 2017 부터 멤버
게시물2
Hi,
back in 2011 attempted an auto trading ea, read up on custom indicators, writing your own etc, then the EA component on which I seem to have got stuck on, things seemed to work except no trades were being placed, ended up doing a few versions.
Using SHI, Heiken Ashi, Accelerator , Awesome,
Chewed up my months bandwidth, down to a snails pace for the next few days, in the mean time, going through old files.
Just dug it up again, any clues ?, (probably something really simple, that I just can not seem to see, over it and over it, left it til now & still)
Came up with the 'egotistical' name for it and here it is. of the other versions, think was minus TP+SL etc.
[IMG]https://i64.tinypic.com/2z8e1jn.jpg[/IMG]
//+------------------------------------------------------------------+
//| AHAA Mega Profit Machine V1.mq4 |
//| Copyright ?2011, Nik Jakotic |
//| https://www.instaforex.com.au |
//| email: {removed}
//+------------------------------------------------------------------+
#property copyright 'Copyright ?2011, Nik Jakotic'
#property link 'https://www.instaforex.com.au'
#include <stdlib.mqh>
#include <WinUser32.mqh>
//--- input parameters
// exported variables
extern double Lots = 0.1;
extern double BalanceRiskPercent = 2;
extern int Stoploss = 20;
extern int Takeprofit = 30;
extern int TrailingTP = 30;
extern int TrailingGap = 7;
extern int MagicNumber=1234567;
// 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;
int Count10 = 0;
int init()
{
NDigits = Digits;
if (false) ObjectsDeleteAll(); // clear the chart
//==Custom Graphic Code====Start====!
ObjectCreate('AHAA Profits',OBJ_LABEL,0,0,0,0,0);
// ObjectSet('AHAA Profits',OBJPROP_XDISTANCE,50);
// ObjectSet('AHAA Profits',OBJPROP_YDISTANCE,50);
// use symbols from the Wingdings font
ObjectSetText('AHAA Profits',CharToStr(74),20,'Wingdings',Gold);
// CharToStr() - this function returns a line with a single
// symbol, the code of which is specified in the single argument.
// Simply select a symbol from the table above and write
// its number into this function
// 60 - use large font
// 'Wingdings' - use font Wingdings
ObjectCreate('AHAA Profits, Copyright ?2011, Nik Jakotic',OBJ_LABEL,0,0,0,0,0);
ObjectSet('AHAA Profits, Copyright ?2011, Nik Jakotic',OBJPROP_CORNER,0);
ObjectSet('AHAA Profits, Copyright ?2011, Nik Jakotic',OBJPROP_YDISTANCE,0);
// use symbols from the Wingdings font
ObjectSetText('AHAA Profits, Copyright ?2011, Nik Jakotic',CharToStr(78),30,'Wingdings',White);
return(0);
//==Custom Graphic Code====END====!
Comment(''); // clear the chart
}
// Expert start
int start()
{
if (Bars < 10)
{
Comment('Not enough bars');
return (0);
}
if (Terminated == true)
{
Comment('EA Terminated.');
return (0);
}
OnEveryTick1();
}
void OnEveryTick1()
{
if (true == false && false) PipValue = 10;
if (true && (NDigits == 3 || NDigits == 5)) PipValue = 10;
PrintInfoToChart10();
TechnicalAnalysis9();
TechnicalAnalysis8();
}
void PrintInfoToChart10()
{
string temp = 'AHAA Profits is Operational - All Systems GO!! {^_^} \nExecuted : ' + Count10 + '\n'
+ 'Spread: ' + DoubleToStr(MarketInfo(Symbol(), MODE_SPREAD)/PipValue, 2)+ '\n'
+ '------------------------------------------------\n'
+ '\n'
+ 'BROKER INFORMATION:\n'
+ '\n'
+ 'Broker Company: ' + AccountCompany()+ '\n'
+ ' Server Time : ' + TimeToStr(TimeCurrent(), TIME_MINUTES)+ '\n'
+ ' Local Time :' + TimeToStr(TimeLocal(), TIME_MINUTES)+ '\n'
+ '\n'
+ '------------------------------------------------\n'
+ '\n'
+ 'ACCOUNT INFORMATION:\n'
+ '\n'
+ 'Account Name : ' + AccountName()+ '\n'
+ 'Account Number : ' + AccountNumber()+ '\n'
+ 'Account Type : ' + AccountServer()+ '\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);
Count10++;
//==Custom Graphic Code part 2===Start===!
CustomCode();
ObjectCreate('AHAA Profits',OBJ_LABEL,0,0,0,0,0);
ObjectSetText('AHAA Profits',CharToStr(74),20,'Wingdings',Gold);
}
void CustomCode()
{
//==Custom Graphic Code part 2===End===!
}
void TechnicalAnalysis9()
{
if (iCustom(NULL, NULL, 'Heiken Ashi',Red,White,Red,White,0,0) == White)
{
TechnicalAnalysis3x6();
}
}
void TechnicalAnalysis3x6()
{
if ((iCustom(NULL, NULL, 'Accelerator',0,0) > 0.0) && (iCustom(NULL, NULL, 'Awesome',0,0) > 0.0) && (iCustom(NULL, NULL, 'Mega-trend',144,3,0,0,0) == 0))
{
BuyOrderRiskFixed2();
}
}
void BuyOrderRiskFixed2()
{
double lotsize = MarketInfo(Symbol(),MODE_LOTSIZE) / AccountLeverage();
double pipsize = 0.1 * 10;
double maxlots = AccountFreeMargin() / 100 * BalanceRiskPercent / lotsize * pipsize;
if (Stoploss == 0) Print('OrderSend() error - stoploss can not be zero');
double lots = maxlots / Stoploss * 10;
// calculate lot size based on current risk
double lotvalue = 0.001;
double minilot = MarketInfo(Symbol(), MODE_MINLOT);
int powerscount = 0;
while (minilot < 1)
{
minilot = minilot * MathPow(10, powerscount);
powerscount++;
}
lotvalue = NormalizeDouble(lots, powerscount - 1);
if (lotvalue < MarketInfo(Symbol(), MODE_MINLOT)) // make sure lot is not smaller than allowed value
{
lotvalue = MarketInfo(Symbol(), MODE_MINLOT);
}
if (lotvalue > MarketInfo(Symbol(), MODE_MAXLOT)) // make sure lot is not greater than allowed value
{
lotvalue = MarketInfo(Symbol(), MODE_MAXLOT);
}
double SL = Ask - Stoploss*PipValue*Point;
if (Stoploss == 0) SL = 0;
double TP = Ask + Takeprofit*PipValue*Point;
if (Takeprofit == 0) TP = 0;
int ticket = -1;
if (true)
ticket = OrderSend(Symbol(), OP_BUY, lotvalue, Ask, 4, 0, 0, 'AHAA Profits', 1, 0, Blue);
else
ticket = OrderSend(Symbol(), OP_BUY, lotvalue, Ask, 4, SL, TP, 'AHAA Profits', 1, 0, Blue);
if (ticket > -1)
{
if (true)
{
OrderSelect(ticket, SELECT_BY_TICKET);
bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0, Blue);
if (ret == false)
Print('OrderModify() error - ', ErrorDescription(GetLastError()));
}
BuyOrder5();
}
else
{
Print('OrderSend() error - ', ErrorDescription(GetLastError()));
}
}
void BuyOrder5()
{
double SL = Ask - Stoploss*PipValue*Point;
if (Stoploss == 0) SL = 0;
double TP = Ask + Takeprofit*PipValue*Point;
if (Takeprofit == 0) TP = 0;
int ticket = -1;
if (true)
ticket = OrderSend(Symbol(), OP_BUY, Lots, Ask, 4, 0, 0, 'AHAA Profits', 1, 0, Blue);
else
ticket = OrderSend(Symbol(), OP_BUY, Lots, Ask, 4, SL, TP, 'AHAA Profits', 1, 0, Blue);
if (ticket > -1)
{
if (true)
{
OrderSelect(ticket, SELECT_BY_TICKET);
bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0, Blue);
if (ret == false)
Print('OrderModify() error - ', ErrorDescription(GetLastError()));
}
BuyOrderModifyFlex24();
}
else
{
Print('OrderSend() error - ', ErrorDescription(GetLastError()));
}
}
void BuyOrderModifyFlex24()
{
for (int i=OrdersTotal()-1; i >= 0; i--)
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
{
if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == 1)
{
double SL = NormalizeDouble(iCustom(NULL, NULL, 'SHI-SIGNAL',0,17,13,0,0), NDigits);
double TP = NormalizeDouble(0, NDigits);
bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0, Blue);
if (ret == false)
Print('OrderModify() error - ', ErrorDescription(GetLastError()));
}
}
TrailingStopFlex27();
}
void TrailingStopFlex27()
{
for (int i=OrdersTotal()-1; i >= 0; i--)
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
{
if (OrderSymbol() == Symbol() && OrderMagicNumber() == 1)
{
double takeprofit = OrderTakeProfit();
double trailingstop = Low[1];
if (OrderType() == OP_BUY && Ask - OrderOpenPrice() > trailingstop)
{
if (OrderStopLoss() < Ask-(TrailingGap*PipValue*Point+trailingstop))
{
if (TrailingTP != 0) takeprofit = Ask+(TrailingTP*PipValue*Point + trailingstop);
bool ret1 = OrderModify(OrderTicket(), OrderOpenPrice(), Ask-trailingstop, takeprofit, OrderExpiration(), Blue);
if (ret1 == false)
Print('OrderModify() error - ', ErrorDescription(GetLastError()));
}
}
if (OrderType() == OP_SELL && OrderOpenPrice() - Bid > trailingstop)
{
if (OrderStopLoss() > Bid+(trailingstop+TrailingGap*PipValue*Point))
{
if (TrailingTP != 0) takeprofit = Bid-(TrailingTP*PipValue*Point + trailingstop);
bool ret2 = OrderModify(OrderTicket(), OrderOpenPrice(), Bid+trailingstop, takeprofit, OrderExpiration(), Blue);
if (ret2 == false)
Print('OrderModify() error - ', ErrorDescription(GetLastError()));
}
}
}
}
else
Print('OrderSelect() error - ', ErrorDescription(GetLastError()));
}
void TechnicalAnalysis8()
{
if (iCustom(NULL, NULL, 'Heiken Ashi',Red,White,Red,White,0,0) == Red)
{
TechnicalAnalysis3x7();
}
}
void TechnicalAnalysis3x7()
{
if ((iCustom(NULL, NULL, 'Accelerator',0,0) < 0.0) && (iCustom(NULL, NULL, 'Awesome',0,0) < 0.0) && (iCustom(NULL, NULL, 'Mega-trend',144,3,0,0,0) == 1))
{
SellOrderRiskFixed3();
}
}
void SellOrderRiskFixed3()
{
double lotsize = MarketInfo(Symbol(),MODE_LOTSIZE) / AccountLeverage();
double pipsize = 0.1 * 10;
double maxlots = AccountFreeMargin() / 100 * BalanceRiskPercent / lotsize * pipsize;
if (Stoploss == 0) Print('OrderSend() error - stoploss can not be zero');
double lots = maxlots / Stoploss * 10;
// calculate lot size based on current risk
double lotvalue = 0.001;
double minilot = MarketInfo(Symbol(), MODE_MINLOT);
int powerscount = 0;
while (minilot < 1)
{
minilot = minilot * MathPow(10, powerscount);
powerscount++;
}
lotvalue = NormalizeDouble(lots, powerscount - 1);
if (lotvalue < MarketInfo(Symbol(), MODE_MINLOT)) // make sure lot is not smaller than allowed value
{
lotvalue = MarketInfo(Symbol(), MODE_MINLOT);
}
if (lotvalue > MarketInfo(Symbol(), MODE_MAXLOT)) // make sure lot is not greater than allowed value
{
lotvalue = MarketInfo(Symbol(), MODE_MAXLOT);
}
double SL = Bid + Stoploss*PipValue*Point;
if (Stoploss == 0) SL = 0;
double TP = Bid - Takeprofit*PipValue*Point;
if (Takeprofit == 0) TP = 0;
int ticket = -1;
if (true)
ticket = OrderSend(Symbol(), OP_SELL, lotvalue, Bid, 4, 0, 0, 'AHAA Profits', 1, 0, Red);
else
ticket = OrderSend(Symbol(), OP_SELL, lotvalue, Bid, 4, SL, TP, 'AHAA Profits', 1, 0, Red);
if (ticket > -1)
{
if (true)
{
OrderSelect(ticket, SELECT_BY_TICKET);
bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0, Red);
if (ret == false)
Print('OrderModify() error - ', ErrorDescription(GetLastError()));
}
SellOrder4();
}
else
{
Print('OrderSend() error - ', ErrorDescription(GetLastError()));
}
}
void SellOrder4()
{
double SL = Bid + Stoploss*PipValue*Point;
if (Stoploss == 0) SL = 0;
double TP = Bid - Takeprofit*PipValue*Point;
if (Takeprofit == 0) TP = 0;
int ticket = -1;
if (true)
ticket = OrderSend(Symbol(), OP_SELL, Lots, Bid, 4, 0, 0, 'AHAA Profits', 1, 0, Red);
else
ticket = OrderSend(Symbol(), OP_SELL, Lots, Bid, 4, SL, TP, 'AHAA Profits', 1, 0, Red);
if (ticket > -1)
{
if (true)
{
OrderSelect(ticket, SELECT_BY_TICKET);
bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0, Red);
if (ret == false)
Print('OrderModify() error - ', ErrorDescription(GetLastError()));
}
SellOrderModifyFlex25();
}
else
{
Print('OrderSend() error - ', ErrorDescription(GetLastError()));
}
}
void SellOrderModifyFlex25()
{
for (int i=OrdersTotal()-1; i >= 0; i--)
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
{
if (OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == 1)
{
double SL = NormalizeDouble(iCustom(NULL, NULL, 'SHI-SIGNAL',0,17,13,0,0), NDigits);
double TP = NormalizeDouble(0, NDigits);
bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0, Red);
if (ret == false)
Print('OrderModify() error - ', ErrorDescription(GetLastError()));
}
}
TrailingStopFlex26();
}
void TrailingStopFlex26()
{
for (int i=OrdersTotal()-1; i >= 0; i--)
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
{
if (OrderSymbol() == Symbol() && OrderMagicNumber() == 1)
{
double takeprofit = OrderTakeProfit();
double trailingstop = High[1];
if (OrderType() == OP_BUY && Ask - OrderOpenPrice() > trailingstop)
{
if (OrderStopLoss() < Ask-(TrailingGap*PipValue*Point+trailingstop))
{
if (TrailingTP != 0) takeprofit = Ask+(TrailingTP*PipValue*Point + trailingstop);
bool ret1 = OrderModify(OrderTicket(), OrderOpenPrice(), Ask-trailingstop, takeprofit, OrderExpiration(), Red);
if (ret1 == false)
Print('OrderModify() error - ', ErrorDescription(GetLastError()));
}
}
if (OrderType() == OP_SELL && OrderOpenPrice() - Bid > trailingstop)
{
if (OrderStopLoss() > Bid+(trailingstop+TrailingGap*PipValue*Point))
{
if (TrailingTP != 0) takeprofit = Bid-(TrailingTP*PipValue*Point + trailingstop);
bool ret2 = OrderModify(OrderTicket(), OrderOpenPrice(), Bid+trailingstop, takeprofit, OrderExpiration(), Red);
if (ret2 == false)
Print('OrderModify() error - ', ErrorDescription(GetLastError()));
}
}
}
}
else
Print('OrderSelect() error - ', ErrorDescription(GetLastError()));
}
int deinit()
{
if (false) ObjectsDeleteAll();
}
back in 2011 attempted an auto trading ea, read up on custom indicators, writing your own etc, then the EA component on which I seem to have got stuck on, things seemed to work except no trades were being placed, ended up doing a few versions.
Using SHI, Heiken Ashi, Accelerator , Awesome,
Chewed up my months bandwidth, down to a snails pace for the next few days, in the mean time, going through old files.
Just dug it up again, any clues ?, (probably something really simple, that I just can not seem to see, over it and over it, left it til now & still)
Came up with the 'egotistical' name for it and here it is. of the other versions, think was minus TP+SL etc.
[IMG]https://i64.tinypic.com/2z8e1jn.jpg[/IMG]
//+------------------------------------------------------------------+
//| AHAA Mega Profit Machine V1.mq4 |
//| Copyright ?2011, Nik Jakotic |
//| https://www.instaforex.com.au |
//| email: {removed}
//+------------------------------------------------------------------+
#property copyright 'Copyright ?2011, Nik Jakotic'
#property link 'https://www.instaforex.com.au'
#include <stdlib.mqh>
#include <WinUser32.mqh>
//--- input parameters
// exported variables
extern double Lots = 0.1;
extern double BalanceRiskPercent = 2;
extern int Stoploss = 20;
extern int Takeprofit = 30;
extern int TrailingTP = 30;
extern int TrailingGap = 7;
extern int MagicNumber=1234567;
// 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;
int Count10 = 0;
int init()
{
NDigits = Digits;
if (false) ObjectsDeleteAll(); // clear the chart
//==Custom Graphic Code====Start====!
ObjectCreate('AHAA Profits',OBJ_LABEL,0,0,0,0,0);
// ObjectSet('AHAA Profits',OBJPROP_XDISTANCE,50);
// ObjectSet('AHAA Profits',OBJPROP_YDISTANCE,50);
// use symbols from the Wingdings font
ObjectSetText('AHAA Profits',CharToStr(74),20,'Wingdings',Gold);
// CharToStr() - this function returns a line with a single
// symbol, the code of which is specified in the single argument.
// Simply select a symbol from the table above and write
// its number into this function
// 60 - use large font
// 'Wingdings' - use font Wingdings
ObjectCreate('AHAA Profits, Copyright ?2011, Nik Jakotic',OBJ_LABEL,0,0,0,0,0);
ObjectSet('AHAA Profits, Copyright ?2011, Nik Jakotic',OBJPROP_CORNER,0);
ObjectSet('AHAA Profits, Copyright ?2011, Nik Jakotic',OBJPROP_YDISTANCE,0);
// use symbols from the Wingdings font
ObjectSetText('AHAA Profits, Copyright ?2011, Nik Jakotic',CharToStr(78),30,'Wingdings',White);
return(0);
//==Custom Graphic Code====END====!
Comment(''); // clear the chart
}
// Expert start
int start()
{
if (Bars < 10)
{
Comment('Not enough bars');
return (0);
}
if (Terminated == true)
{
Comment('EA Terminated.');
return (0);
}
OnEveryTick1();
}
void OnEveryTick1()
{
if (true == false && false) PipValue = 10;
if (true && (NDigits == 3 || NDigits == 5)) PipValue = 10;
PrintInfoToChart10();
TechnicalAnalysis9();
TechnicalAnalysis8();
}
void PrintInfoToChart10()
{
string temp = 'AHAA Profits is Operational - All Systems GO!! {^_^} \nExecuted : ' + Count10 + '\n'
+ 'Spread: ' + DoubleToStr(MarketInfo(Symbol(), MODE_SPREAD)/PipValue, 2)+ '\n'
+ '------------------------------------------------\n'
+ '\n'
+ 'BROKER INFORMATION:\n'
+ '\n'
+ 'Broker Company: ' + AccountCompany()+ '\n'
+ ' Server Time : ' + TimeToStr(TimeCurrent(), TIME_MINUTES)+ '\n'
+ ' Local Time :' + TimeToStr(TimeLocal(), TIME_MINUTES)+ '\n'
+ '\n'
+ '------------------------------------------------\n'
+ '\n'
+ 'ACCOUNT INFORMATION:\n'
+ '\n'
+ 'Account Name : ' + AccountName()+ '\n'
+ 'Account Number : ' + AccountNumber()+ '\n'
+ 'Account Type : ' + AccountServer()+ '\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);
Count10++;
//==Custom Graphic Code part 2===Start===!
CustomCode();
ObjectCreate('AHAA Profits',OBJ_LABEL,0,0,0,0,0);
ObjectSetText('AHAA Profits',CharToStr(74),20,'Wingdings',Gold);
}
void CustomCode()
{
//==Custom Graphic Code part 2===End===!
}
void TechnicalAnalysis9()
{
if (iCustom(NULL, NULL, 'Heiken Ashi',Red,White,Red,White,0,0) == White)
{
TechnicalAnalysis3x6();
}
}
void TechnicalAnalysis3x6()
{
if ((iCustom(NULL, NULL, 'Accelerator',0,0) > 0.0) && (iCustom(NULL, NULL, 'Awesome',0,0) > 0.0) && (iCustom(NULL, NULL, 'Mega-trend',144,3,0,0,0) == 0))
{
BuyOrderRiskFixed2();
}
}
void BuyOrderRiskFixed2()
{
double lotsize = MarketInfo(Symbol(),MODE_LOTSIZE) / AccountLeverage();
double pipsize = 0.1 * 10;
double maxlots = AccountFreeMargin() / 100 * BalanceRiskPercent / lotsize * pipsize;
if (Stoploss == 0) Print('OrderSend() error - stoploss can not be zero');
double lots = maxlots / Stoploss * 10;
// calculate lot size based on current risk
double lotvalue = 0.001;
double minilot = MarketInfo(Symbol(), MODE_MINLOT);
int powerscount = 0;
while (minilot < 1)
{
minilot = minilot * MathPow(10, powerscount);
powerscount++;
}
lotvalue = NormalizeDouble(lots, powerscount - 1);
if (lotvalue < MarketInfo(Symbol(), MODE_MINLOT)) // make sure lot is not smaller than allowed value
{
lotvalue = MarketInfo(Symbol(), MODE_MINLOT);
}
if (lotvalue > MarketInfo(Symbol(), MODE_MAXLOT)) // make sure lot is not greater than allowed value
{
lotvalue = MarketInfo(Symbol(), MODE_MAXLOT);
}
double SL = Ask - Stoploss*PipValue*Point;
if (Stoploss == 0) SL = 0;
double TP = Ask + Takeprofit*PipValue*Point;
if (Takeprofit == 0) TP = 0;
int ticket = -1;
if (true)
ticket = OrderSend(Symbol(), OP_BUY, lotvalue, Ask, 4, 0, 0, 'AHAA Profits', 1, 0, Blue);
else
ticket = OrderSend(Symbol(), OP_BUY, lotvalue, Ask, 4, SL, TP, 'AHAA Profits', 1, 0, Blue);
if (ticket > -1)
{
if (true)
{
OrderSelect(ticket, SELECT_BY_TICKET);
bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0, Blue);
if (ret == false)
Print('OrderModify() error - ', ErrorDescription(GetLastError()));
}
BuyOrder5();
}
else
{
Print('OrderSend() error - ', ErrorDescription(GetLastError()));
}
}
void BuyOrder5()
{
double SL = Ask - Stoploss*PipValue*Point;
if (Stoploss == 0) SL = 0;
double TP = Ask + Takeprofit*PipValue*Point;
if (Takeprofit == 0) TP = 0;
int ticket = -1;
if (true)
ticket = OrderSend(Symbol(), OP_BUY, Lots, Ask, 4, 0, 0, 'AHAA Profits', 1, 0, Blue);
else
ticket = OrderSend(Symbol(), OP_BUY, Lots, Ask, 4, SL, TP, 'AHAA Profits', 1, 0, Blue);
if (ticket > -1)
{
if (true)
{
OrderSelect(ticket, SELECT_BY_TICKET);
bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0, Blue);
if (ret == false)
Print('OrderModify() error - ', ErrorDescription(GetLastError()));
}
BuyOrderModifyFlex24();
}
else
{
Print('OrderSend() error - ', ErrorDescription(GetLastError()));
}
}
void BuyOrderModifyFlex24()
{
for (int i=OrdersTotal()-1; i >= 0; i--)
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
{
if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == 1)
{
double SL = NormalizeDouble(iCustom(NULL, NULL, 'SHI-SIGNAL',0,17,13,0,0), NDigits);
double TP = NormalizeDouble(0, NDigits);
bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0, Blue);
if (ret == false)
Print('OrderModify() error - ', ErrorDescription(GetLastError()));
}
}
TrailingStopFlex27();
}
void TrailingStopFlex27()
{
for (int i=OrdersTotal()-1; i >= 0; i--)
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
{
if (OrderSymbol() == Symbol() && OrderMagicNumber() == 1)
{
double takeprofit = OrderTakeProfit();
double trailingstop = Low[1];
if (OrderType() == OP_BUY && Ask - OrderOpenPrice() > trailingstop)
{
if (OrderStopLoss() < Ask-(TrailingGap*PipValue*Point+trailingstop))
{
if (TrailingTP != 0) takeprofit = Ask+(TrailingTP*PipValue*Point + trailingstop);
bool ret1 = OrderModify(OrderTicket(), OrderOpenPrice(), Ask-trailingstop, takeprofit, OrderExpiration(), Blue);
if (ret1 == false)
Print('OrderModify() error - ', ErrorDescription(GetLastError()));
}
}
if (OrderType() == OP_SELL && OrderOpenPrice() - Bid > trailingstop)
{
if (OrderStopLoss() > Bid+(trailingstop+TrailingGap*PipValue*Point))
{
if (TrailingTP != 0) takeprofit = Bid-(TrailingTP*PipValue*Point + trailingstop);
bool ret2 = OrderModify(OrderTicket(), OrderOpenPrice(), Bid+trailingstop, takeprofit, OrderExpiration(), Blue);
if (ret2 == false)
Print('OrderModify() error - ', ErrorDescription(GetLastError()));
}
}
}
}
else
Print('OrderSelect() error - ', ErrorDescription(GetLastError()));
}
void TechnicalAnalysis8()
{
if (iCustom(NULL, NULL, 'Heiken Ashi',Red,White,Red,White,0,0) == Red)
{
TechnicalAnalysis3x7();
}
}
void TechnicalAnalysis3x7()
{
if ((iCustom(NULL, NULL, 'Accelerator',0,0) < 0.0) && (iCustom(NULL, NULL, 'Awesome',0,0) < 0.0) && (iCustom(NULL, NULL, 'Mega-trend',144,3,0,0,0) == 1))
{
SellOrderRiskFixed3();
}
}
void SellOrderRiskFixed3()
{
double lotsize = MarketInfo(Symbol(),MODE_LOTSIZE) / AccountLeverage();
double pipsize = 0.1 * 10;
double maxlots = AccountFreeMargin() / 100 * BalanceRiskPercent / lotsize * pipsize;
if (Stoploss == 0) Print('OrderSend() error - stoploss can not be zero');
double lots = maxlots / Stoploss * 10;
// calculate lot size based on current risk
double lotvalue = 0.001;
double minilot = MarketInfo(Symbol(), MODE_MINLOT);
int powerscount = 0;
while (minilot < 1)
{
minilot = minilot * MathPow(10, powerscount);
powerscount++;
}
lotvalue = NormalizeDouble(lots, powerscount - 1);
if (lotvalue < MarketInfo(Symbol(), MODE_MINLOT)) // make sure lot is not smaller than allowed value
{
lotvalue = MarketInfo(Symbol(), MODE_MINLOT);
}
if (lotvalue > MarketInfo(Symbol(), MODE_MAXLOT)) // make sure lot is not greater than allowed value
{
lotvalue = MarketInfo(Symbol(), MODE_MAXLOT);
}
double SL = Bid + Stoploss*PipValue*Point;
if (Stoploss == 0) SL = 0;
double TP = Bid - Takeprofit*PipValue*Point;
if (Takeprofit == 0) TP = 0;
int ticket = -1;
if (true)
ticket = OrderSend(Symbol(), OP_SELL, lotvalue, Bid, 4, 0, 0, 'AHAA Profits', 1, 0, Red);
else
ticket = OrderSend(Symbol(), OP_SELL, lotvalue, Bid, 4, SL, TP, 'AHAA Profits', 1, 0, Red);
if (ticket > -1)
{
if (true)
{
OrderSelect(ticket, SELECT_BY_TICKET);
bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0, Red);
if (ret == false)
Print('OrderModify() error - ', ErrorDescription(GetLastError()));
}
SellOrder4();
}
else
{
Print('OrderSend() error - ', ErrorDescription(GetLastError()));
}
}
void SellOrder4()
{
double SL = Bid + Stoploss*PipValue*Point;
if (Stoploss == 0) SL = 0;
double TP = Bid - Takeprofit*PipValue*Point;
if (Takeprofit == 0) TP = 0;
int ticket = -1;
if (true)
ticket = OrderSend(Symbol(), OP_SELL, Lots, Bid, 4, 0, 0, 'AHAA Profits', 1, 0, Red);
else
ticket = OrderSend(Symbol(), OP_SELL, Lots, Bid, 4, SL, TP, 'AHAA Profits', 1, 0, Red);
if (ticket > -1)
{
if (true)
{
OrderSelect(ticket, SELECT_BY_TICKET);
bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0, Red);
if (ret == false)
Print('OrderModify() error - ', ErrorDescription(GetLastError()));
}
SellOrderModifyFlex25();
}
else
{
Print('OrderSend() error - ', ErrorDescription(GetLastError()));
}
}
void SellOrderModifyFlex25()
{
for (int i=OrdersTotal()-1; i >= 0; i--)
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
{
if (OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == 1)
{
double SL = NormalizeDouble(iCustom(NULL, NULL, 'SHI-SIGNAL',0,17,13,0,0), NDigits);
double TP = NormalizeDouble(0, NDigits);
bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0, Red);
if (ret == false)
Print('OrderModify() error - ', ErrorDescription(GetLastError()));
}
}
TrailingStopFlex26();
}
void TrailingStopFlex26()
{
for (int i=OrdersTotal()-1; i >= 0; i--)
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
{
if (OrderSymbol() == Symbol() && OrderMagicNumber() == 1)
{
double takeprofit = OrderTakeProfit();
double trailingstop = High[1];
if (OrderType() == OP_BUY && Ask - OrderOpenPrice() > trailingstop)
{
if (OrderStopLoss() < Ask-(TrailingGap*PipValue*Point+trailingstop))
{
if (TrailingTP != 0) takeprofit = Ask+(TrailingTP*PipValue*Point + trailingstop);
bool ret1 = OrderModify(OrderTicket(), OrderOpenPrice(), Ask-trailingstop, takeprofit, OrderExpiration(), Red);
if (ret1 == false)
Print('OrderModify() error - ', ErrorDescription(GetLastError()));
}
}
if (OrderType() == OP_SELL && OrderOpenPrice() - Bid > trailingstop)
{
if (OrderStopLoss() > Bid+(trailingstop+TrailingGap*PipValue*Point))
{
if (TrailingTP != 0) takeprofit = Bid-(TrailingTP*PipValue*Point + trailingstop);
bool ret2 = OrderModify(OrderTicket(), OrderOpenPrice(), Bid+trailingstop, takeprofit, OrderExpiration(), Red);
if (ret2 == false)
Print('OrderModify() error - ', ErrorDescription(GetLastError()));
}
}
}
}
else
Print('OrderSelect() error - ', ErrorDescription(GetLastError()));
}
int deinit()
{
if (false) ObjectsDeleteAll();
}
Jan 05, 2016 부터 멤버
게시물1189
Oct 06, 2017 at 21:11
(편집됨 Oct 06, 2017 at 21:12)
Jan 05, 2016 부터 멤버
게시물1189
asguard posted:
Hi,
back in 2011 attempted an auto trading ea, read up on custom indicators, writing your own etc, then the EA component on which I seem to have got stuck on, things seemed to work except no trades were being placed, ended up doing a few versions.
It will never open trades, because it isn't loaded on the chart.
It's obvious because there is no smiley face icon in the top right corner of the chart.
Check your terminal logs and see what it say's.
If it looks too good to be true, it's probably a scam! Let the buyer beware.
Dec 20, 2017 at 07:23
Jan 26, 2012 부터 멤버
게시물23
I stand under correction Asg... but from your long drawn out code... you just have a string of Functions....
You haven't called any of them man... Don't just copy and paste code from the internet... work out what it does before you try to be clever....
Seriously... work it out...
You haven't called any of them man... Don't just copy and paste code from the internet... work out what it does before you try to be clever....
Seriously... work it out...
miketantoon@
Dec 20, 2017 at 13:14
Sep 13, 2017 부터 멤버
게시물2
Hi Mike, no copy pasting... creation software was used obviously not much chop. & using the course materials mt4 how-to etc. the indicator part, well fine , the ea part not so. Pull it out of the creation software & yeah, went over it at the time not much luck as mentioned, from memory it was the one, Venn diagram, forget its name, Molanis or something like it. At this time, can`t do much, on an old mac, got one of those ransom-wear bugs in the pc so quite peeved atm. (pull hd out & access via usb, whatever`s left). Thanks for the input, I`ll give it another look, wasn`t anything too major, you seem to have confirmed that.
To you & yours , all the best for a safe & joyous Christmas & Festive season.😄
To you & yours , all the best for a safe & joyous Christmas & Festive season.😄
*상업적 사용 및 스팸은 허용되지 않으며 계정이 해지될 수 있습니다.
팁: 이미지/유튜브 URL을 게시하면 게시물에 자동으로 삽입됩니다!
팁: @기호를 입력하여 이 토론에 참여하는 사용자 이름을 자동으로 완성합니다.