Menu
Brokers
MT4 Forex Brokers
MT5 Forex brokers
PayPal Brokers
Skrill Brokers
Oil Trading Brokers
Gold Trading Brokers
Web Browser Platform
Brokers with CFD Trading
ECN Brokers
Bitcoin FX Brokers
PAMM Forex Brokers
With Cent Accounts
With High Leverage
Cryptocurrency Brokers
Forums
All threads
New threads
New posts
Trending
Search forums
What's new
New threads
New posts
Latest activity
Log in
Register
Search
Search titles only
By:
Search titles only
By:
Menu
Install the app
Install
Reply to thread
Forums
Trading Platforms
MetaTrader Expert Advisors
Please help edit my code EA_BB can not compile
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
[QUOTE="ARTTYV1, post: 192765, member: 72463"] Dear ll Please help edit my code EA_BB can not compile I am beginner EA [CODE=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)); } [/CODE] [/QUOTE]
Insert quotes…
Verification
Post reply
Top
Bottom
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.
Accept
Learn more…