Hi,
Need help in fixing these error pls;
')' - unexpected end of program newpinbar.mq5 59 36
Try this : (when you ask chatGPT for a script it literally finds a script and not an expert advisor , also if you did use chatGPT send this code to it as a correction)
It is not tested as i assumed for what you wanted in the trade filtration
#property copyright "Read the discussion" #property link "https://www.mql5.com/en/forum/441063" #property version "1.00" #property strict input int TakeProfit1=50; input int TakeProfit2=100; input int StopLoss=200; input int TimeStart=9; input int TimeEnd=17; input int VolumeMin=100; input double lotSize=0.01; datetime barStamp=0; int OnInit() { barStamp=0; return(INIT_SUCCEEDED); } void OnTick() { int i; int ticket=-1; int day=DayOfWeek(); int hour=Hour(); //Day of week has Sunday on 0 and Saturday on 6 ! caution on that https://docs.mql4.com/dateandtime/dayofweek if(hour<TimeStart || hour>=TimeEnd || day==6 || day==0) return; if(Time[0]>barStamp) { barStamp=Time[0]; double bodySize=MathAbs(Close[1]-Open[1]); if(Close[1]<Open[1] && Close[1]<(Low[2]+bodySize*0.5) && Close[1]>(Low[2]+High[2])*0.5 && Open[1]>Close[2] && Volume[i]>VolumeMin){ ticket=OrderSend(Symbol(),OP_SELL,lotSize,Bid,1000, High[2]+((double)StopLoss)*_Point,Low[i]-((double)TakeProfit1)*_Point, "PinBar Sell",16384,0,clrGreen); } else if(Close[1]>Open[1] && Close[1]>(High[2]-bodySize*0.5) && Close[1]<(Low[2]+High[2])*0.5 && Open[1]<Close[2] && Volume[i]>VolumeMin) { ticket=OrderSend(Symbol(),OP_BUY,lotSize,Ask,1000, Low[2]-((double)StopLoss)*_Point,High[2]+((double)TakeProfit1)*_Point, "PinBar Buy",16384,0,clrRed); } } }
I'm not sure what does ChatGPT have to do with this. All you need to do is add a
}
symbol at the end of your code to fix the unbalanced parentheses/unexpected end of program error messages.
-
ticket=OrderSend(Symbol(),OP_SELL,lotSize,Bid,1000, High[2]+((double)StopLoss)*_Point,Low[i]-((double)TakeProfit1)*_Point, "PinBar Sell",16384,0,clrGreen);
Why did you post your MT4 question in the MT5 General section instead of the MQL4 section, (bottom of the Root page)?
General rules and best pratices of the Forum. - General - MQL5 programming forum? (2017)
Next time, post in the correct place. The moderators will likely move this thread there soon. -
return(ticket); } } // end of for return(0); // where is the end of start?
MT4: Learn to code it.
MT5: Begin learning to code it.If you don't learn MQL4/5, there is no common language for us to communicate. If we tell you what you need, you can't code it. If we give you the code, you don't know how to integrate it into your code.
-
int start() {
You should stop using the old event handlers (init, start, deinit) and IndicatorCounted() and start using new event handlers (OnInit, OnTick/OnCalculate, OnDeinit).
Event Handling Functions - MQL4 Reference
How to do your lookbacks correctly - MQL4 programming forum #9-14 & #19 (2016)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
Need help in fixing these error pls;
')' - unexpected end of program newpinbar.mq5 59 36