And where is the code so far ?
Code is a bit of a mess at the moment. I have defined a bar that signals a change in market direction but need this to only be effective when n=4 bars have passed from the order.
//+------------------------------------------------------------------------------------------------------------------------------------------------- extern double buystoploss =0; //SL for a buy open order extern double buytakeprofit =??; //ТР for a buy opened order extern int buycount =0; //Number of buy market orders placed within 24 hours extern int sellcount =0; //Number of sell market orders placed within 24 hours //+------------------------------------------------------------------------------------------------------------------------------------------------ int start() { int spinningtop = 33, //percentage parameter of spinning candle top currentorder = OrdersTotal(); //total number of open market orders double totalcandlelength = MathAbs((iHigh("EURUSD",PERIOD_M1,1))-((iLow("EURUSD",PERIOD_M1,1)))), //total length of a single individual candle candlelength = MathAbs((iOpen("EURUSD",PERIOD_M1,1))-((iClose("EURUSD",PERIOD_M1,1)))), //length of open and close position of each candle price = Ask; //Price of market entry bool spinningtoprule = false; // 33% rule for opening an order //+------------------------------------------------------------------------------------------------------------------------------------------------ if (currentorder<1 && (((candlelength/totalcandlelength)*100) <= spinningtop)) //Limit market order at any time to n=1 & implement 33% rule { spinningtoprule = true; OrderSend("EURUSD",OP_BUY,1,Ask,10,buystoploss,buytakeprofit,NULL,0,0,clrGreen); buycount++; Alert("Buy Order No.",buycount," Price=",price); } return; }
int barcount=0; datetime time;
if(time!=iTime(_Symbol,PERIOD_M1,0)) { barcount++; time=iTime(_Symbol,PERIOD_M1,0); } if(barcount==4) { // Do Something... barcount=0; }
Thank you very much. Worked a treat!
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi,
I'm trying to code for a limit criteria to close an order, however the criteria needs only to be relevant when the 4th bars appears following a marker order. I would like to code to assess the characteristics of all bars (already have coded this), subsequent to the 4th bar of an order. I am struggling how to code this so any help would be greatly appreciated