- Experts: AlliHeik
- my own EA not executed
- Function Placement
What is it?
iOpen(m_symbol.Name(), 15, 1)
Have you read the help ?
double iOpen( const string symbol, // Symbol ENUM_TIMEFRAMES timeframe, // Period int shift // Shift );
What is it?
if((iOpen(m_symbol.Name(), 15, 2) - iClose(m_symbol.Name(), 15, 2)) > 0) // 2nd candle before current must be bearish { { m_need_open_buy=true; return; }
15 is the Period_M15. I want the EA to only look for the signal in the M15 timeframe.
Have you read the help? (Note, I point out to you for the SECOND time that you DO NOT READ the help). There are no '1' ... '15' - the timeframe is set using ENUM_TIMEFRAMES
PERIOD_CURRENT, PERIOD_M1,PERIOD_M2,PERIOD_M3, PERIOD_M4,PERIOD_M5,PERIOD_M6, PERIOD_M10,PERIOD_M12,PERIOD_M15, PERIOD_M20,PERIOD_M30,PERIOD_H1, PERIOD_H2,PERIOD_H3,PERIOD_H4, PERIOD_H6,PERIOD_H8,PERIOD_H12, PERIOD_D1,PERIOD_W1,PERIOD_MN1

- www.mql5.com
Have you read the help? (Note, I point out to you for the SECOND time that you DO NOT READ the help). There are no '1' ... '15' - the timeframe is set using ENUM_TIMEFRAMES
Yes yes i read the help and changed the script to ENUM_TIMEFRAMES. I forgot to mention that. But thank you for the response
Isn't in this case the "if" statement has to state the first candle before current, which must be bullish?
if((iOpen(m_symbol.Name(), PERIOD_15, 1) - iClose(m_symbol.Name(), PERIOD_15, 1)) > 0) // 1st candle before current must be bullish
So that if (first candle from current is bullish and second candle from current is bearish),
execute a buy at the open of current candle.
Like this:
if((iOpen(m_symbol.Name(), PERIOD_15, 1) - iClose(m_symbol.Name(), PERIOD_15, 1)) < 0) && //1st candle must be bullish if((iOpen(m_symbol.Name(), PERIOD_15, 2) - iClose(m_symbol.Name(), PERIOD_15, 2)) > 0) //2nd candle must be bearish { { m_need_open_buy=true; return; }
Isn't in this case the "if" statement has to state the first candle before current, which must be bullish?
So that if (first candle from current is bullish and second candle from current is bearish),
execute a buy at the open of current candle.
Like this:
Forum on trading, automated trading systems and testing trading strategies
Can you assist how to use OHLC to create signals for Harami candlestick pattern
Vladimir Karputov, 2021.09.27 19:54
Drop the 'm_need_open_buy' variable and the 'm_need_open_sell' variable from the code.i have dropped 'm_need_open_buy' variable and the 'm_need_open_sell' variable from the code
Its compiling with no errors. I am just not sure yet of the condition i added (Candle bar 1)
void OnTick() { //--- double Ask=NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_ASK),_Digits); // calculate the Ask price double Bid=NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_BID),_Digits); // calculate the Bid price string signal =""; // Create a string for the signal int digits =(int)SymbolInfoInteger(_Symbol,SYMBOL_DIGITS); // number of decimal places double point =SymbolInfoDouble(_Symbol,SYMBOL_POINT); // point double SellSL =Bid-InpStopLossPts*point; // unnormalized SL value SellSL =NormalizeDouble(SellSL,digits); // normalizing Stop Loss double SellTP =Bid+InpTakeProfitPts*point; // unnormalized TP value SellTP =NormalizeDouble(SellTP,digits); // normalizing Take Profit double BuySL =Ask-InpStopLossPts*point; // unnormalized SL value BuySL =NormalizeDouble(BuySL,digits); // normalizing Stop Loss double BuyTP =Ask+InpTakeProfitPts*point; // unnormalized TP value BuyTP =NormalizeDouble(BuyTP,digits); // normalizing Take Profit //--- work only at the time of the birth of new bar datetime time_0=iTime(m_symbol.Name(),Period(),0); if(time_0==m_prev_bars) return; m_prev_bars=time_0; //--- Condition for opening BUY position //--- check volume before OrderSend to avoid "not enough money" error (CTrade) double free_margin_check=m_account.FreeMarginCheck(m_symbol.Name(), ORDER_TYPE_BUY, m_symbol.LotsMin(), m_symbol.Ask()); double margin_check=m_account.MarginCheck(m_symbol.Name(), ORDER_TYPE_BUY, m_symbol.LotsMin(), m_symbol.Ask()); if(free_margin_check>margin_check) if((iOpen(m_symbol.Name(), PERIOD_M15, 1) - iClose(m_symbol.Name(), PERIOD_M15, 1)) < 0) //1st candle must be bullish if((iOpen(m_symbol.Name(), PERIOD_M15, 2) - iClose(m_symbol.Name(), PERIOD_M15, 2)) > 0) //2nd candle must be bearish { if(InpPrintLog) Print(__FILE__," ",__FUNCTION__,", OK: ","Signal BUY"); m_trade.Buy(m_symbol.LotsMin(),m_symbol.Name(),m_symbol.Ask(),BuySL,BuyTP); } else m_prev_bars=0; //--- }
If you are looking for a condition only at the moment of the birth of a new bar, why are you doing this AT EVERY TICK?
double Ask= NormalizeDouble ( SymbolInfoDouble ( _Symbol , SYMBOL_ASK ), _Digits ); // calculate the Ask price double Bid= NormalizeDouble ( SymbolInfoDouble ( _Symbol , SYMBOL_BID ), _Digits ); // calculate the Bid price string signal = "" ; // Create a string for the signal int digits =( int ) SymbolInfoInteger ( _Symbol , SYMBOL_DIGITS ); // number of decimal places double point = SymbolInfoDouble ( _Symbol , SYMBOL_POINT ); // point double SellSL =Bid-InpStopLossPts*point; // unnormalized SL value SellSL = NormalizeDouble (SellSL,digits); // normalizing Stop Loss double SellTP =Bid+InpTakeProfitPts*point; // unnormalized TP value SellTP = NormalizeDouble (SellTP,digits); // normalizing Take Profit double BuySL =Ask-InpStopLossPts*point; // unnormalized SL value BuySL = NormalizeDouble (BuySL,digits); // normalizing Stop Loss double BuyTP =Ask+InpTakeProfitPts*point; // unnormalized TP value BuyTP = NormalizeDouble (BuyTP,digits); // normalizing Take Profit

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use