Hi,
I'm using this code to open Limit Order, Is it possible to have it to open Trad only if current bar fully closed?
Not sure what you want, do you mean that you want to wait until the current bar closes before opening the pending order?
You can calculate how much time is left until the candle is due to close. store the Time[0] and then sleep for the period. Check that it is a new bar and send the order.
You cannot check if the current bar is fully closed in one step because as soon as it closes. it becomes the previous bar and the new bar is the current bar.
Hi GumRai
THank you for your reply.
YES exactly ( wait until the current bar closes before opening the pending order)
But See the attached photo.assuming that i add my order at the time of (Bar 4 ) You can see that (Bar 3 and Bar 2 ) are go below my entry level and reverse. (I don't want to open the trad) I want to open trad with the bar that fully closed bellow my level ( In my case here is bar 1).
int prev_bars; int start() { if(Bars==prevbars) return(0); prevbars=Bars;
Hi,
I got undeclared identifier for prevbars
#property show_inputs //#property show_confirm extern double Lots = 1.0; extern int Slippage = 3; extern int Stop_Loss = 25; extern int Take_Profit = 100; enum TimeToExp { M15 = 900, //15 Minute M30 = 1800, //30 Minute H1 = 3600, //1 Hour H2 = 7200, //2 Hours H3 = 10800, //3 Hours H4 = 14400, //4 Hours D1 = 86400, //1 Day }; input TimeToExp ExpirTime = H4; int prev_bars; //+------------------------------------------------------------------+ //| script "Open a new Buy Order" | //+------------------------------------------------------------------+ int start() { if(Bars==prev_bars) return(0); prev_bars=Bars; double Price = WindowPriceOnDropped(); bool result; int /*cmd,total,error,*/slippage; //---- int NrOfDigits = MarketInfo(Symbol(),MODE_DIGITS); // Nr. of decimals used by Symbol int PipAdjust; // Pips multiplier for value adjustment if(NrOfDigits == 5 || NrOfDigits == 3) // If decimals = 5 or 3 PipAdjust = 10; // Multiply pips by 10 else if(NrOfDigits == 4 || NrOfDigits == 2) // If digits = 4 or 3 (normal) PipAdjust = 1; //---- slippage = Slippage * PipAdjust; double stop_loss = Price - Stop_Loss * Point * PipAdjust; double take_profit = Price + Take_Profit * Point * PipAdjust; if(Close[1] > Price) { result = OrderSend(Symbol(),OP_BUYLIMIT,Lots,Price,slippage,stop_loss,take_profit,"",0,TimeCurrent()+ExpirTime,CLR_NONE); } if(Close[1] < Price) { result = OrderSend(Symbol(),OP_BUYSTOP,Lots,Price,slippage,stop_loss,take_profit,"",0,TimeCurrent()+ExpirTime,CLR_NONE); } //---- return(0); } //+------------------------------------------------------------------+
And i change it to perb_bars and the script doesn't work at all
Hi,
I got undeclared identifier for prevbars
And i change it to perb_bars and the script doesn't work at all
I do not know why you have undeclared.
Dou you know difference between script and EA?
Script doing code once. EA each tick.
I do not know why you have undeclared.
Dou you know difference between script and EA?
Script doing code once. EA each tick.
I got undeclared identifier for prevbars
And i change it to perb_bars and the script doesn't work at all
I follow your instruction and that what i got??
- There are no mind readers here; we can't know where your error is.
- "Doesn't work" is meaningless - just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires - meaningless. There are no mind readers here.
- When in doubt, think. A script runs once. Therefor your newbar code is irrelevant.
- Check your return codes (OrderSend) and find out why. What are Function return values ? How do I use them ? - MQL4 forum and Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
- Print your if statements (variable values,) and find out why.
- Check your return codes (OrderSend) and find out why. What are Function return values ? How do I use them ? - MQL4 forum and Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
- Print your if statements (variable values,) and find out why.
:)))))))
He want to use script like an EA.
All he needs is to put his file to EA folder and delete this.
#property show_inputs
//#property show_confirm
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I'm using this code to open Limit Order, Is it possible to have it to open Trad only if current bar fully closed?