How to formula entry to enter once and wait for next same entry
I have been trying to figure this out and using all sort of ways but still couldnt get it to work.
Show your code attempt and maybe somebody can help.
Use the code button (Alt+S) when pasting code.
string LAST_TRADE_SELL_POS = "NO TRADE"; string LAST_TRADE_BUY_POS = "NO TRADE"; string LAST_POSITION_BUY = "NO TRADE"; string LAST_POSITION_SELL = "NO TRADE"; string B_POS_ENTER = "Y"; string S_POS_ENTER = "Y"; bool B_TRADED = false; bool S_TRADED = false; void OnTick() { shortSmaM1 = iMA(NULL, PERIOD_M1, PeriodOne, 0, MODE_SMMA, PRICE_CLOSE, 0); longSmaM1 = iMA(NULL, PERIOD_M1, PeriodTwo, 0, MODE_SMMA, PRICE_CLOSE, 0); if (shortSmaM1 > longSmaM1) { PositionM1_BUY = "BUY"; if (LAST_TRADE_BUY_POS == "NO TRADE") { PositionM1_BUY = "BUY"; } else { if (LAST_TRADE_BUY_POS == PositionM1_BUY) { PositionM1_SELL = "SELL"; } if (LAST_TRADE_BUY_POS == "BUY") { PositionM1_SELL = "SELL"; } } } else { PositionM1_BUY = "SELL"; } if (shortSmaM1 < longSmaM1) { PositionM1_SELL = "SELL"; if (LAST_TRADE_SELL_POS == "NO TRADE") { PositionM1_SELL = "SELL"; } else { if (LAST_TRADE_SELL_POS == PositionM1_SELL) { PositionM1_SELL = "BUY"; } if (LAST_TRADE_SELL_POS == "BUY") { PositionM1_SELL = "SELL"; } } } else { PositionM1_SELL = "BUY"; } if (TradingType == 5) //MA { if ((PositionM1_BUY == "BUY") && (iClose(NULL,0,1)>iOpen(NULL,0,1)) && ((iClose(NULL,0,1) + 2 *Point) < iBands(NULL,0,50,2,0,PRICE_CLOSE,MODE_UPPER,0) ) ) { if (OrderSend(Symbol(), OP_BUY, lots, Ask, 3, 0, 0, Comment, MagicNumber, 0, Blue)) { LAST_TRADE_BUY_POS = PositionM1_BUY; B_TRADED = true; // LAST_TRADE_SELL_POS = "NO TRADE"; Print("Buy order succeeded!"); } } else (PositionM1_BUY ="NO TRADE" ); if ((PositionM1_SELL == "SELL") && (iClose(NULL,0,1)<iOpen(NULL,0,1)) && ((iClose(NULL,0,1) - 2* Point) > iBands(NULL,0,50,2,0,PRICE_CLOSE,MODE_LOWER,0) )) { if (OrderSend(Symbol(), OP_SELL, lots, Bid, 3, 0, 0, Comment, MagicNumber, 0, Red)) { LAST_TRADE_SELL_POS = PositionM1_SELL; S_TRADED = true; // LAST_TRADE_BUY_POS = "NO TRADE"; Print("Sell order succeeded!"); } } else (PositionM1_SELL = "NO TRADE"); }
never able to get it to work.
the new trade always enter after the current trade closes.
and sometime enters outside the boilinger band while I dont want that to happen. I want it to enter inside the boilinger band.
- www.metatrader5.com
Hi,
How do I code, for e.g 1 entery has entered and exit from within certain condition, however the current condition still allow for another entry to enter. but I dont want. I want to wait for next round of entry event to occur.
how do I make the code to wait for next round of event before entering again?
I have been trying to figure this out and using all sort of ways but still couldnt get it to work.
any idea shared will be greatly appreciated.