Dear ll
Please help edit my code EA_BB can not compile I am beginner EA
Please help edit my code EA_BB can not compile I am beginner EA
MQL4:
//+------------------------------------------------------------------+ //| BB+arttyv1.mq4 | //| Copyright 2021, MetaQuotes Software Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2021, MetaQuotes Software Corp." #property link "https://www.mql5.com" #property version "1.00" #property strict //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ input int InpBandsPeriods = 20; input double InpBandsDeviations = 2.0; input ENUM_APPLIED_PRICE InpBandsAppliedPrice = PRICE_CLOSE; //TPSL input double InpTPDeviations = 1.0; //tp input double InpSLDeviations = 1.0; //sl //Standard input input double InpVolume = 0.01; //lot size input int InpMagicNumber = 202016; input string InpTradeComment = __FILE__; int OnInit() { return(INIT_SUCCEEDED); } void OnDeinit(const int reason) void OnTick() { if (IsNewBar()) return; double closel = iClose(Symbol(), Period(), 1) ; double highl = iHigh(Symbol(), Period(), 1) ; double lowl = iLow(Symbol(), Period(), 1) ; // // double upper1 = iBands(Symbol(), Period(), InpBandsPeriods, InpBandsDeviations, 0,InpBandsAppliedPrice, MODE_UPPER, 1); double lower1 = iBands(Symbol(), Period(), InpBandsPeriods, InpBandsDeviations, 0,InpBandsAppliedPrice, MODE_LOWER, 1); double close2 = iClose(Symbol(),Period(),2); double upper2 = iBands(Symbol(),Period(), InpBandsPeriods, InpBandsPeriods, InpBandsDeviations,0, InpBandsAppliedPrice, MODndsDeviations,0, InpBandsAppliedPrice, MODE_UPPER, 2); double lower2 = iBands(Symbol(),Period(), InpBandsPeriods, InpBandsPeriods, InpBandsDeviations,0, InpBandsAppliedPrice, MODndsDeviations,0, InpBandsAppliedPrice, MODE_LOWER, 2); if (close2>upper2 && close1<upper1) { // reentry from above =sell OpenOrder(ORDER_TYPE_SELL_STOP,low1, (upper1-lower1()); } if (close2>lower2 && close1<lower1) { // reentry from below =buy OpenOrder(ORDER_TYPE_BUY_STOP, high1, (upper1-lower1()); } return; } bool IsNewBar() { //Open time for the current bar datetime currentBarTime = iTime(Symbol(), Period(),0); //Ini on first use static datetime prevBarTime = currentBartime ; if (prevBarTime<currentBarTime) ; //New bar opened (prevBarTime = currentBarTime); //Update prev time before exit return(true); } return(false); } int OpenOrders(ENUM_ORDER_TYPE orderType,double entryPrice, double channelWidth) { // Size of one devition double deviation = channelWidth/(2*InpBandsDeviations); double tp = deviation * InpTPDeviations; double sl = deviation * InpSLDeviations; datetime expiration = iTime(Symbol() , Period(), 0)+PeriodSeconds() -1; entryPrice = NormalizeDouble(entryPrice, Digits()); double tpPrice = 0.0; double slPrice = 0.0; double Price = 0.0; if (orderType%2==ORDER_TYPE_BUY) { // buy stop price = Ask; if (price>=(entryPrice-stopLevel) { entryPrice = price; orderType = ORDER_TYPE_BUY; } tpPrice = NormalizeDouble(entryPrice+tp, Digits()); slPrice = NormalizeDouble(entryPrice+sl, Digits()); { else if (orderType%2==ORDER_TYPE_SELL) { // sell stop price = Bid; if (price>=(entryPrice+stopLevel) { entryPrice = price; orderType = ORDER_TYPE_SELL; } tpPrice = NormalizeDouble(entryPrice+tp, Digits()); slPrice = NormalizeDouble(entryPrice+sl, Digits()); } else { return(0); } return(OrderSend(Symbol(), orderType, InpVolume,entryPrice, 0 slPrice, toPrice, InpTradeComment, InpMagicNumber, expiration)); }