Linear Regression Candle for MT4
- Indicatori
- Yashar Seyyedin
- Versione: 1.30
- Aggiornato: 28 novembre 2023
- Attivazioni: 20
To download MT5 version please click here.
- This is the exact conversion from TradingView: "Linear Regression Candles" By "ugurvu".
- This is a non-repaint and light processing load indicator
- You can message in private chat for further changes you need.
This is a sample EA code that operates based on bullish and bearish linear regression candles.
#property strict input string EA_Setting=""; input int magic_number=1234; input string Risk_Management=""; input double fixed_lot_size=0.01; // select fixed lot size input string LINREG_Setting=""; input int signal_length = 7; //signal SMoothing input bool sma_signal_line = true; //Simple MA(Signal Line) input bool linreg = true; //Lin Reg input int linreg_length = 11; //Linear Regression Length void OnTick() { if(!isNewBar()) return; bool buy_condition=true; buy_condition &= (BuyPositionCount()==0); buy_condition &= (CloseOfCandle(1)>OpenOfCandle(1)); if(buy_condition) { CloseSell(); Buy(); } bool sell_condition=true; sell_condition &= (SellPositionCount()==0); sell_condition &= (CloseOfCandle(1)<OpenOfCandle(1)); if(sell_condition) { CloseBuy(); Sell(); } } int BuyPositionCount() { int counter=0; for(int i=0;i<OrdersTotal();i++) { if(OrderSelect(i, SELECT_BY_POS)==false) continue; if(OrderSymbol()!=_Symbol) continue; if(OrderMagicNumber()!=magic_number) continue; if(OrderType()==OP_BUY) counter++; } return counter; } int SellPositionCount() { int counter=0; for(int i=0;i<OrdersTotal();i++) { if(OrderSelect(i, SELECT_BY_POS)==false) continue; if(OrderSymbol()!=_Symbol) continue; if(OrderMagicNumber()!=magic_number) continue; if(OrderType()==OP_SELL) counter++; } return counter; } void Buy() { if(OrderSend(_Symbol, OP_BUY, fixed_lot_size, Ask, 3, 0, 0, NULL, magic_number, 0, clrNONE)==-1) { Print("Could not execute order: ", GetLastError()); } } void Sell() { double sl = High[iHighest(_Symbol, PERIOD_CURRENT, MODE_HIGH, 15, 0)]; double sl_points=MathAbs(Bid-sl)/_Point; double tp = 0; double lot=CalculateLots(sl_points); if(OrderSend(_Symbol, OP_SELL, fixed_lot_size, Bid, 3, 0, 0, NULL, magic_number, 0, clrNONE)==-1) { Print("Could not execute order: ", GetLastError()); } } datetime timer=NULL; bool isNewBar() { if(timer==NULL){} else if(timer==Time[0]) return false; timer=Time[0]; return true; } void CloseBuy() { for(int i=OrdersTotal()-1;i>=0;i--) { if(OrderSelect(i, SELECT_BY_POS)==false) continue; if(OrderSymbol()!=_Symbol) continue; if(OrderMagicNumber()!=magic_number) continue; if(OrderType()==OP_BUY) { if(OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 3, clrNONE)==false) { Print("Error closing orde: ", GetLastError()); } } } } void CloseSell() { for(int i=OrdersTotal()-1;i>=0;i--) { if(OrderSelect(i, SELECT_BY_POS)==false) continue; if(OrderSymbol()!=_Symbol) continue; if(OrderMagicNumber()!=magic_number) continue; if(OrderType()==OP_SELL) { if(OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 3, clrNONE)==false) { Print("Error closing orde: ", GetLastError()); } } } } double CloseOfCandle(int index) { return iCustom(_Symbol, PERIOD_CURRENT, "Market/Linear Regression Candle for MT4", signal_length, sma_signal_line, linreg, linreg_length, 3, index); } double OpenOfCandle(int index) { return iCustom(_Symbol, PERIOD_CURRENT, "Market/Linear Regression Candle for MT4", signal_length, sma_signal_line, linreg, linreg_length, 2, index); }
High quality from a high quality programmer. Also, it is true that if you need something the programmer will help you. Thank you very much to him. You are in good hands with his indicators. He is the one if you look tradingview indicators for MT4.