if(select == true) return(string PositionGetString(_Symbol,POSITION_MAGIC));
hi, it have yet error:
'PositionGetString' - no one of the overloads can be applied to the function call TradeHedge.mqh 439 28
could be one of 2 function(s) TradeHedge.mqh 439 28
built-in: string PositionGetString(ENUM_POSITION_PROPERTY_STRING) TradeHedge.mqh 439 28
built-in: bool PositionGetString(ENUM_POSITION_PROPERTY_STRING,string&) TradeHedge.mqh 439 28
Btw, it is PositionGetInteger();
ok,thanks I tested and enjoied!
hello, when I compile my EA , I receive following errors(check highlighted line):
'Init' - no one of the overloads can be applied to the function call Bands RSI jadid.mq5 121 12
could be one of 2 function(s) Bands RSI jadid.mq5 121 12
int CiAlligator::Init(string,ENUM_TIMEFRAMES,int,int,int,int,int,int,ENUM_MA_METHOD,ENUM_APPLIED_PRICE) Indicators.mqh 435 7
int CIndicator::Init() Indicators.mqh 36 15
any one can help me, please?
//+------------------------------------------------------------------+ //| Bands/RSI CounterTrend | //| Andrew Young | //| http://www.expertadvisorbook.com | //+------------------------------------------------------------------+ #property copyright "Andrew Young" #property link "http://www.expertadvisorbook.com" #property description "A counter-trend trading system using Bollinger Bands and RSI" /* Creative Commons Attribution-NonCommercial 3.0 Unported http://creativecommons.org/licenses/by-nc/3.0/ You may use this file in your own personal projects. You may modify it if necessary. You may even share it, provided the copyright above is present. No commercial use permitted. */ // Trade #include <Mql5Book\Trade.mqh> CTrade Trade; // Price #include <Mql5Book\Price.mqh> CBars Bar; // Money management #include <Mql5Book\MoneyManagement.mqh> // Trailing stops #include <Mql5Book\TrailingStops.mqh> CTrailing Trail; // Timer #include <Mql5Book\Timer.mqh> CTimer Timer; CNewBar NewBar; // Indicators #include <Mql5Book\Indicators.mqh> CiAlligator Alligator; CiCCI CCI; //+------------------------------------------------------------------+ //| Input variables | //+------------------------------------------------------------------+ input ulong Slippage = 3; input bool TradeOnNewBar = true; sinput string MM; // Money Management input bool UseMoneyManagement = true; input double RiskPercent = 2; input double FixedVolume = 0.1; sinput string SL; // Stop Loss & Take Profit input int StopLoss = 0; input int TakeProfit = 0; sinput string TS; // Trailing Stop input bool UseTrailingStop = false; input int TrailingStop = 0; input int MinimumProfit = 0; input int Step = 0; sinput string BE; // Break Even input bool UseBreakEven = false; input int BreakEvenProfit = 0; input int LockProfit = 0; sinput string Alli; // Bollinger Bands input int JawPeriod = 13; input int JawShift = 8; input int TeethPeriod = 8; input int TeethShift = 5; input int LipsPeriod = 5; input int LipsShift = 3; input double AlligatorMethod = MODE_SMMA; input ENUM_APPLIED_PRICE AlligatorPrice = PRICE_MEDIAN; sinput string CC; // RSI input int CCIPeriod = 14; input ENUM_APPLIED_PRICE CCIPrice = PRICE_CLOSE; sinput string TI; // Timer input bool UseTimer = false; input int StartHour = 0; input int StartMinute = 0; input int EndHour = 0; input int EndMinute = 0; input bool UseLocalTime = false; //+------------------------------------------------------------------+ //| Global variables | //+------------------------------------------------------------------+ bool glBuyPlaced, glSellPlaced; enum Signal { SIGNAL_BUY, SIGNAL_SELL, SIGNAL_NONE, }; Signal glSignal; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //problem line//Alligator.Init(_Symbol,_Period,JawPeriod,JawShift,TeethPeriod,TeethShift,LipsPeriod,LipsShift,AlligatorMethod,AlligatorPrice); CCI.Init(_Symbol,_Period,CCIPeriod,CCIPrice); Trade.Deviation(Slippage); return(0); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { // Check for new bar bool newBar = true; int barShift = 0; if(TradeOnNewBar == true) { newBar = NewBar.CheckNewBar(_Symbol,_Period); barShift = 1; } // Timer bool timerOn = true; if(UseTimer == true) { timerOn = Timer.DailyTimer(StartHour,StartMinute,EndHour,EndMinute,UseLocalTime); } // Update prices Bar.Update(_Symbol,_Period); // Order placement if(newBar == true && timerOn == true) { // Money management double tradeSize; if(UseMoneyManagement == true) tradeSize = MoneyManagement(_Symbol,FixedVolume,RiskPercent,StopLoss); else tradeSize = VerifyVolume(_Symbol,FixedVolume); if(Bar.Close(barShift) < Alligator.Jaw(barShift) && CCI.Main(barShift) < 30) glSignal = SIGNAL_BUY; else if(Bar.Close(barShift) > Alligator.Lips(barShift) && CCI.Main(barShift) > 70) glSignal = SIGNAL_SELL; // Open buy order if(glSignal == SIGNAL_BUY && Bar.Close(barShift) > Alligator.Jaw(barShift) && Bar.Close(barShift+1) <= Alligator.Jaw(barShift+1)) { glBuyPlaced = Trade.Buy(_Symbol,tradeSize); if(glBuyPlaced == true) { do(Sleep(100)); while(PositionSelect(_Symbol) == false); double openPrice = PositionOpenPrice(_Symbol); double buyStop = BuyStopLoss(_Symbol,StopLoss,openPrice); if(buyStop > 0) AdjustBelowStopLevel(_Symbol,buyStop); double buyProfit = BuyTakeProfit(_Symbol,TakeProfit,openPrice); if(buyProfit > 0) AdjustAboveStopLevel(_Symbol,buyProfit); if(buyStop > 0 || buyProfit > 0) Trade.ModifyPosition(_Symbol,buyStop,buyProfit); glSignal = SIGNAL_NONE; } } // Open sell order if(glSignal == SIGNAL_SELL && Bar.Close(barShift) < Alligator.Lips(barShift) && Bar.Close(barShift+1) >= Alligator.Lips(barShift+1)) { glSellPlaced = Trade.Sell(_Symbol,tradeSize); if(glSellPlaced == true) { do(Sleep(100)); while(PositionSelect(_Symbol) == false); double openPrice = PositionOpenPrice(_Symbol); double sellStop = SellStopLoss(_Symbol,StopLoss,openPrice); if(sellStop > 0) sellStop = AdjustAboveStopLevel(_Symbol,sellStop); double sellProfit = SellTakeProfit(_Symbol,TakeProfit,openPrice); if(sellProfit > 0) sellProfit = AdjustBelowStopLevel(_Symbol,sellProfit); if(sellStop > 0 || sellProfit > 0) Trade.ModifyPosition(_Symbol,sellStop,sellProfit); glSignal = SIGNAL_NONE; } } } // Order placement end // Break even if(UseBreakEven == true && PositionType(_Symbol) != -1) { Trail.BreakEven(_Symbol,BreakEvenProfit,LockProfit); } // Trailing stop if(UseTrailingStop == true && PositionType(_Symbol) != -1) { Trail.TrailingStop(_Symbol,TrailingStop,MinimumProfit,Step); } }
My EA opens positions but they haven't take profit and stop loss!
the include file (trade) that implement take profit and stop loss don't work correctly meanwhile when in doesn't show any error. I attached trade file bottom because of its size. does any one know how can I fix this problem.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
This is a tradehedge . it have these 7 errors in two lines before end (yellow line).
'PositionGetString' - unexpected token TradeHedge.mqh 439 35
',' - unexpected token TradeHedge.mqh 439 60
'POSITION_MAGIC' - some operator expected TradeHedge.mqh 439 61
')' - unexpected token TradeHedge.mqh 439 76
')' - semicolon expected TradeHedge.mqh 439 76
')' - unexpected token TradeHedge.mqh 439 76
'else' - illegal 'else' without matching 'if' TradeHedge.mqh 440 2
'}' - not all control paths return a value TradeHedge.mqh 441 1
what can i do for resolve?