Welcome to Forex-TSD!, one of the largest Forex forums worldwide, where you will be able to find the most complete and reliable Forex information imaginable.
From the list below, select the forum that you want to visit and register to post, as many times you want. It’s absolutely free. Click here for registering on Forex-TSD.
Exclusive Forum
The Exclusive Forum is the only paid section. Once you subscribe, you will get free access to real cutting-edge Trading Systems (automated and not), Indicators, Signals, Articles, etc., that will help and guide you, in ways that you could only imagine, with your Forex trading.
Elite Section
Get access to private discussions, specialized support, indicators and trading systems reported every week.
Advanced Elite Section
For professional traders, trading system developers and any other member who may need to use and/or convert, the most cutting-edge exclusive indicators and trading systems for MT4 and MT5.
How To Make Trade Until The Next Bar After Closed?
Hey guys,
Can anyone help me to add the code to this EA to stop trade and wait until the next bar after closing the previous position. I've tried to disable EachTickMode but it doesn't just like i want.
PHP Code:
#property copyright "Expert Advisor Builder"
#property link "http://sufx.core.t3-ism.net/ExpertAdvisorBuilder/"
extern int MagicNumber = 777;
extern bool SignalMail = False;
extern bool EachTickMode = True;
extern double Lots = 0.1;
extern int Slippage = 3;
extern bool StopLossMode = True;
extern int StopLoss = 10;
extern bool TakeProfitMode = True;
extern int TakeProfit = 10;
extern bool TrailingStopMode = False;
extern int TrailingStop = 15;
extern int EntryPoint = 1;
extern int ExitPoint = 2;
int BarCount;
int Current;
bool TickCheck = False;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init() {
BarCount = Bars;
if (EachTickMode) Current = 0; else Current = 1;
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit() {
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start() {
int Order = SIGNAL_NONE;
int Total, Ticket;
double StopLossLevel, TakeProfitLevel;
if (EachTickMode && Bars != BarCount) TickCheck = False;
Total = OrdersTotal();
Order = SIGNAL_NONE;
//+------------------------------------------------------------------+
//| Variable Begin |
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Signal Begin(Entry) |
//+------------------------------------------------------------------+
if (Buy1_1 >= Buy1_2) Order = SIGNAL_BUY;
if (Sell1_1 <= Sell1_2) Order = SIGNAL_SELL;
//+------------------------------------------------------------------+
//| Signal End |
//+------------------------------------------------------------------+
//Buy
if (Order == SIGNAL_BUY && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {
if(!IsTrade) {
//Check free margin
if (AccountFreeMargin() < (10 * Lots)) {
Print("We have no money. Free Margin = ", AccountFreeMargin());
return(0);
}
Hi, Unfortunately cant help you with code but am interested to try EA. Which timeframe do you run it on?
Best regards
I'm running it on M5, also i'll try on on bigger time frame such as H1,H4 and Daily,..i think it will be best if it can stop trade after hit SL, TP or the Closing signal rules than wait and see the next bar,..it will placing another position after the new bar that fit the rule. I hope the improvement will be like that.
Thanks Harry. I had put it on a 30min chart EUR/USD and just had a trade that made 10pips! I am using a stoploss of 20pips. I will ask a buddy of mine if he knows how to correct your code. If I hear from him I will post the code for you. All the best will try on 5min
Thanks Harry. I had put it on a 30min chart EUR/USD and just had a trade that made 10pips! I am using a stoploss of 20pips. I will ask a buddy of mine if he knows how to correct your code. If I hear from him I will post the code for you. All the best will try on 5min
congratulations,..i hope this will be a successfull EA,..the concept are very simple,...just like a simple manual trade. Go long when break high and go shot when break low,...but,...i want to wait and see first if there's any chance to enter the market once again on the same way or take the reverse positions.
int BarCount;
int Current;
bool TickCheck = False;
datetime CheckEntryTime;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init() {
BarCount = Bars;
if (EachTickMode) Current = 0; else Current = 1;
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit() {
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start() {
int Order = SIGNAL_NONE;
int Total, Ticket;
double StopLossLevel, TakeProfitLevel;
if (EachTickMode && Bars != BarCount) TickCheck = False;
Total = OrdersTotal();
Order = SIGNAL_NONE;
//+------------------------------------------------------------------+
//| Variable Begin |
//+------------------------------------------------------------------+
if (Buy1_1 >= Buy1_2) Order = SIGNAL_BUY;
if (Sell1_1 <= Sell1_2) Order = SIGNAL_SELL;
//+------------------------------------------------------------------+
//| Signal End |
//+------------------------------------------------------------------+
//Buy
if (Order == SIGNAL_BUY && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {
if(!IsTrade) {
//Check free margin
if (AccountFreeMargin() < (10 * Lots)) {
Print("We have no money. Free Margin = ", AccountFreeMargin());
return(0);
}
I've tested your code,...unfortunatly it's doesn't really work. If "OneEntryPerBar" is set True than no any trade to make, if "OneEntryPerBar" is set False trede is on, but sometime it doesn't hold the trade until the next bar. Maybe you can give another code to meke it happen. Thank's anyway for your help,...i'm still working a progress here and i'm waiting the improvement from all of you guys,...any set, any code, any comment, just anything...please give your idea here