MQL 4 Boll reversal trading bot

MQL 4 Boll reversal trading bot

Manage alerts

Loading saved threads...

nagakeipon · External communityPost link
External question — Stack Overflow Stack Exchange Author: nagakeipon Original post: https://stackoverflow.com/questions/75900009 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. I would like to write this EA in MQL4 Maxposition 1, No stopless Sell perttern Current price is more than Bool Upperband 5 Sigma sell Current price lower than 2 sigma boll lower band TP Buy puttern Bool Lowerband 5 Sigma Buy 2 sigma boll Upper band TP Problem -int total=0; said unexpected token. I don't know how to fix. -I ask if Ticket number has been idenityied? -Last parenthese does not work } not all controle paths return a value. -I asked chat GTP and source code based on program that I made but I cannot do it out. Please help me out. Thank you !! double waitBB,maisuu=0.01; datetime prevtime; input int Lotsize = 0.04 int total=0; int start() { int orderPtn=0; //0:Nothing 1:Buy 2:Sell int errorcode; // Error int ticket,ea_order_entry_Type=0,ea_order_MagicNo; // Ticket Noentrytype,Magic No. double ea_order_stop_price=0,ea_order_good_price=0,ea_order_entry_price=0; //Stopless TP, Entry //--- //Boll pricing rates double BB5UP = iBands(NULL,0,20,5,0,PRICE_CLOSE,MODE_UPPER,0); //upper 5σ double BB5LO = iBands(NULL,0,20,5,0,PRICE_CLOSE,MODE_LOWER,0); //lower 5σ double BB2UP = iBands(NULL,0,20,2,0,PRICE_CLOSE,MODE_UPPER,0); //upper 2σ double BB2LO = iBands(NULL,0,20,2,0,PRICE_CLOSE,MODE_LOWER,0); //lower 2σ //***Buy and sell checker***// //Bid price above the price of upper Boll 5σ and sell action if(BB5UP \> Bid) { orderPtn=2; } //Ask price below the price of lower Boll 5σ and buy action else if(BB5LO \< Ask) { orderPtn=1; } // otherwise nothing to do else { orderPtn=0; } //Buy action if((orderPtn==1) || waitBB\>0 ) { //lowerband 5σ equal or lower, buy if((BB5LO \> Ask || BB5LO == Ask )) { orderPtn=1; waitBB=0; }else{ orderPtn=0; waitBB=1; } } //Sell action if((orderPtn==2) || waitBB\<0 ) { // upperband 5σ equal or upper, sell if((BB5UP \< Bid || BB5UP == Ask )) { orderPtn=2; waitBB=0; }else{ orderPtn=0; waitBB=-1; } } //***sell buy positon check ***// int totalOrders = 0; totalOrders = OrdersTotal(); if(totalOrders == 1) { //If I have a position, don't have a position waitBB=0; } //Entry point else if(totalOrders == 0 && orderPtn \> 0) { if(BB5LO \> PERIOD_CURRENT ||BB5LO == PERIOD_CURRENT ) { OrderSend(NULL, OP_BUY, Lotsize, Ask, 20, Close[0] + 0.5, 0, "Buy", ea_order_MagicNo, 0, Red); } else if(BB5UP \< PERIOD_CURRENT || BB5UP == PERIOD_CURRENT ) { OrderSend(NULL, OP_SELL, Lotsize, Bid, 20, Close\[0\] + 0.5, 0, "sell", ea_order_MagicNo, 0, Red); } else if(totalOrders == 1 && orderPtn \> 0) { if (OrderType() == OP_BUY || OrderType() == OP_SELL) { if (OrderProfit() < 0) { } else if (OrderProfit() > 0) { if(BB2LO < PERIOD_CURRENT) { bool result = OrderClose(ticket ,Lotsize, PERIOD_CURRENT, 20,Red); } else if(BB2UP > PERIOD_CURRENT) { bool result = OrderClose(ticket ,Lotsize, PERIOD_CURRENT, 20, Blue); } } else { Print("Failed to close position: ", GetLastError()); } } } ea_order_MagicNo=33; //MagicNo33 ticket = OrderSend( // New order NULL, // Pair ea_order_entry_Type, // Order type [OP_BUY / OP_SELL] Lotsize, // Lots (0.01 ea_order_entry_price, // Order price rate 20, // Slip ea_order_stop_price, // Stop rate ea_order_good_price, // Limit rate "Ordered ", // Order comment ea_order_MagicNo, // MagicNo 0, // order limited time clrRed // order icon color ); if ( ticket == -1) // order error { errorcode = GetLastError(); // error code if( errorcode != ERR_NO_ERROR) // error producted { printf("Order Error"); } } else { // order executed Print("Order Done",ticket); } } }
Quote
Report
Mark SdS · External communityPost link
External answer — Stack Overflow Stack Exchange Author: Mark SdS Original post: https://stackoverflow.com/a/75908755 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. Seems as if you've forgotten the 'comma and point thing' (semicolon) after 0.04: input int Lotsize = 0.04 int total=0; Not all paths return a value : You made a lot of if -statements. Your function is probably an int() function, so compiler checks whether an integer is returned as a result of execution of that function. (I'm on my phone but and it's hard to break apart your code in that tiny screen). If compiler finds any if -statement that is not returning the expected type, it throws an error like you see. Better solution IMO: At the start of the function, declare a result variable with a default value. All if -statements can modify that default value. At the end of the function, return the variable, whether modified or not. Cheers!
Quote
Report

Post Reply

Quoted from Forex.com.bd-Editorial External answer — Stack Overflow Stack Exchange Author: Mark SdS Source score (net votes, not local likes): 0 Original post: https://stackoverflow.com/a/75908755 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. Seems as if you've forgotten the 'comma and point thing' (semicolon) after 0.04: input int Lotsize = 0.04 int total=0; Not all paths return a value : You made a lot of if -statements. Your function is probably an int() function, so compiler checks whether an integer is returned as a result of execution of that function. (I'm on my phone but and it's hard to break apart your code in that tiny screen). If compiler finds any if -statement that is not returning the expected type, it throws an error like you see. Better solution IMO: At the start of the function, declare a result variable with a default value. All if -statements can modify that default value. At the end of the function, return the variable, whether modified or not. Cheers!

Cancel quote

Checking account access…
MQL 4 Boll reversal trading bot | Forex.com.bd