sebasbox:
The errror are:
'sl' - undeclared identifier Ichiyou.mq5 189 41
'entry' - undeclared identifier Ichiyou.mq5 190 33
'sl' - undeclared identifier Ichiyou.mq5 190 39
'entry' - undeclared identifier Ichiyou.mq5 192 30
'sl' - undeclared identifier Ichiyou.mq5 192 36
in the code it seems that everythig is declared as it should...but..
First you need to fix the other errors you have not listed.. then things will become clearer...
Thank you for replays guys, but unfortunately I still don't know how to fix it. I need to read more, because right now it seem to be black magic for me..
ok, fixed, once again thank you for the replays
here you are, this should work:
#include <Trade\Trade.mqh> CTrade trade; #include <Indicators\Trend.mqh> CiIchimoku ichimoku; //Useer Input input ENUM_TIMEFRAMES Timeframe = PERIOD_CURRENT; input ulong InpMagic = 8234; input double RiskPercent =2; bool FutureCloudGreen =false, FutureCloudRed =false; bool PriceaboveCloud =false, PricebelowCloud =false; bool TenkanaboveKijun =false, TenkanbelowKijun =false; bool ChikouaboveCloud =false, ChikoubelowCloud =false; int OnInit(){ trade.SetExpertMagicNumber(InpMagic); ichimoku = new CiIchimoku(); ichimoku.Create(_Symbol,Timeframe,9,26,52); return(INIT_SUCCEEDED); } void OnDeinit(const int reason){ } void OnTick(){ if(!IsNewBar()) return; ichimoku.Refresh(-1); double SpanAx1 = ichimoku.SenkouSpanA(1); double SpanAx2 = ichimoku.SenkouSpanA(2); double SpanAx26 = ichimoku.SenkouSpanA(26); double SpanAf26 = ichimoku.SenkouSpanA(-26); double SpanBx1 = ichimoku.SenkouSpanB(1); double SpanBx2 = ichimoku.SenkouSpanB(2); double SpanBx26 = ichimoku.SenkouSpanB(26); double SpanBf26 = ichimoku.SenkouSpanB(-26); double Tenkan = ichimoku.TenkanSen(1); double Kijun = ichimoku.KijunSen(1); double Chikou = ichimoku.ChinkouSpan(26); double Closex1 = iClose(_Symbol,Timeframe,1); double Closex2 = iClose(_Symbol,Timeframe,2); //Checking Conditions if(SpanAf26>SpanBf26){ FutureCloudGreen=true; FutureCloudRed=false;} if(SpanBf26>SpanAf26){ FutureCloudGreen=false; FutureCloudRed=true;} //Exit Cloud if(PriceaboveCloud==false && (Closex2<SpanAx2 || Closex2<SpanBx2) && Closex1>SpanAx1 && Closex1>SpanBx1){ PriceaboveCloud=true; PricebelowCloud=false;} if(PricebelowCloud==false && (Closex2>SpanAx2 || Closex2>SpanBx2) && Closex1<SpanAx1 && Closex1<SpanBx1){ PriceaboveCloud=false; PricebelowCloud=true;} //Tenkan if(Tenkan>Kijun){ TenkanaboveKijun=true; TenkanbelowKijun=false;} if(Tenkan<Kijun){ TenkanaboveKijun=false; TenkanbelowKijun=true;} //Chikou if(Chikou>SpanAx26 && Chikou>SpanBx26){ ChikouaboveCloud=true; ChikoubelowCloud=false;} if(Chikou<SpanAx26 && Chikou<SpanBx26){ ChikouaboveCloud=false; ChikoubelowCloud=true;} //Price in the cloud if(SpanAx1>SpanBx1 && Closex1>SpanBx1 && Closex1<SpanAx1){ PriceaboveCloud=false; PricebelowCloud=false;} if(SpanBx1>SpanAx1 && Closex1>SpanAx1 && Closex1<SpanBx1){ PriceaboveCloud=false; PricebelowCloud=false;} //Chikou in the cloud if(SpanAx26>SpanBx26 && Chikou>SpanBx26 && Chikou<SpanAx26){ ChikouaboveCloud=false; ChikoubelowCloud=false;} if(SpanBx26>SpanAx26 && Chikou>SpanAx26 && Chikou<SpanBx26){ ChikouaboveCloud=false; ChikoubelowCloud=false;} Comment("\n FutureCloudRed:",FutureCloudRed, "\n PricebelowCloud:",PricebelowCloud, "\n TenkanbelowKijun:",TenkanbelowKijun, "\n ChikouaboveCloud:",ChikouaboveCloud); //Buy Condition if(FutureCloudGreen==true && PriceaboveCloud==true && TenkanaboveKijun==true && ChikouaboveCloud==true){ double entry = Closex1; double sl = Kijun - 50*_Point; double tp = entry + (entry - sl)*2; double lots = calcLots(entry - sl); trade.Buy(lots,_Symbol,entry,sl,tp,"Buy"); SetAllConditionstofalse(); } //Sell Condition if(FutureCloudRed==true && PricebelowCloud==true && TenkanbelowKijun==true&& ChikoubelowCloud==true) { double entry = Closex1; double sl = Kijun + 50*_Point; double tp = entry - (sl - entry)*2; double lots = calcLots(sl - entry); trade.Sell(lots,_Symbol,entry,sl,tp,"Sell"); SetAllConditionstofalse(); } } //---------------------------------------------------------- bool IsNewBar(){ static datetime previousTime = 0; datetime currentTime = iTime(_Symbol,PERIOD_CURRENT,0); if(previousTime!=currentTime){ previousTime=currentTime; return true; } return false; } double calcLots(double slPoints){ double risk = AccountInfoDouble(ACCOUNT_BALANCE) * RiskPercent/100; double ticksize = SymbolInfoDouble(_Symbol,SYMBOL_TRADE_TICK_SIZE); double tickvalue = SymbolInfoDouble(_Symbol,SYMBOL_TRADE_TICK_VALUE); double lotstep = SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_STEP); double moneyPerLotstep = slPoints / ticksize * tickvalue * lotstep; double lots = MathFloor(risk / moneyPerLotstep) * lotstep; double minvolume=SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_MIN); double maxvolume=SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_MAX); if(maxvolume!=0) lots = MathMin(lots,maxvolume); if(minvolume!=0) lots = MathMax(lots,minvolume); lots = NormalizeDouble(lots,2); return lots; } void SetAllConditionstofalse() { FutureCloudGreen = false; FutureCloudRed = false; PriceaboveCloud = false; PricebelowCloud = false; TenkanaboveKijun = false; TenkanbelowKijun = false; ChikouaboveCloud = false; ChikoubelowCloud = false; }
Discover new MetaTrader 5 opportunities with MQL5 community and services
- 2024.09.06
- www.mql5.com
MQL5: language of trade strategies built-in the MetaTrader 5 Trading Platform, allows writing your own trading robots, technical indicators, scripts and libraries of functions
any success with the strategy?
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
Firsr of all hello everyone.
I'm form Poland and I'm new in this topic, so please just be gentle;)
Anyway, I'v started to learn how to build EA few days ago. So I'v started to read theory and I thought that practice from the beginning would give me some benefits too. I understand basic instructions but I'm still in very beginning of this trip.
I checked some videos on youtube and found this:
https://www.youtube.com/watch?v=H0GjjPl1Qjw
So after rewriting all the code like in the movie I have some errors, and although it should just work i doesn't. I'm checking and checking and can't find anything...
The errror are:
'sl' - undeclared identifier Ichiyou.mq5 189 41
'entry' - undeclared identifier Ichiyou.mq5 190 33
'sl' - undeclared identifier Ichiyou.mq5 190 39
'entry' - undeclared identifier Ichiyou.mq5 192 30
'sl' - undeclared identifier Ichiyou.mq5 192 36
in the code it seems that everythig is declared as it should...but..
I would be grateful for your help.
Sebastian