Why does this string function not update? MQL4

Why does this string function not update? MQL4

Manage alerts

Loading saved threads...

vinny9592 · External communityPost link
External question — Stack Overflow Stack Exchange Author: vinny9592 Original post: https://stackoverflow.com/questions/64672345 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'm super confused right now, been at this for some time. I'm trying to figure out why this string function won't update the string when I believe the if statement to be true. void OnTick() { string aboveprofit = ""; for ( int b = OrdersTotal() - 1; b >= 0; b-- ) { if ( OrderSelect( b, SELECT_BY_POS, MODE_TRADES ) ) if ( OrderSymbol() == Symbol() ) { if ( OrderSymbol() == OP_SELL ) { OrderModify( OrderTicket(), OrderOpenPrice(), Bid + ( 150 * _Point ), OrderTakeProfit(), 0, CLR_NONE ); if ( Ask < OrderOpenPrice() ) { abovepoint = "321"; } } if ( OrderSymbol() == OP_BUY ) { OrderModify( OrderTicket(), OrderOpenPrice(), Ask - ( 150 * _Point ), OrderTakeProfit(), 0, CLR_NONE ); if ( Bid > OrderOpenPrice() ) { abovepoint = "123"; } } } }
Quote
Report
user3666197 · External communityPost link
External answer — Stack Overflow Stack Exchange Author: user3666197 Original post: https://stackoverflow.com/a/64680366 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. Q : "why this string function won't update the string when I believe the if statement to be true?" Well, how do you know it did not? Add a Print( Volume[0], abovepoint ); command right onto the first line right upon the entry to the void OnTick(){...} -code-block, so as to check the validity of your above posted assumption in the Client Terminal log. The code fragment above is missing an actual abovepoint declaration, so it is impossible to add anything more than this. ERRATA : OrderSymbol() will most probably never match { OP_BUY | OP_SELL } -constants, it ought be OrderType() , ought be not? The OrderModify() -commands are almost sure to generate server-side rejections of any XTO-instruction, that will violate either a Broker-side defined FREEZE_LEVEL and/or minimum permitted distances of modified { TP | SL } -targets from the actual { Ask | Bid } -price-levels. Kindly review your Broker's T&C and best adapt your code to prevent falling into those conditions colliding instructions.
Quote
Report

Post Reply

Quoted from Forex.com.bd-Editorial External answer — Stack Overflow Stack Exchange Author: user3666197 Source score (net votes, not local likes): 2 Original post: https://stackoverflow.com/a/64680366 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. Q : "why this string function won't update the string when I believe the if statement to be true?" Well, how do you know it did not? Add a Print( Volume[0], abovepoint ); command right onto the first line right upon the entry to the void OnTick(){...} -code-block, so as to check the validity of your above posted assumption in the Client Terminal log. The code fragment above is missing an actual abovepoint declaration, so it is impossible to add anything more than this. ERRATA : OrderSymbol() will most probably never match { OP_BUY | OP_SELL } -constants, it ought be OrderType() , ought be not? The OrderModify() -commands are almost sure to generate server-side rejections of any XTO-instruction, that will violate either a Broker-side defined FREEZE_LEVEL and/or minimum permitted distances of modified { TP | SL } -targets from the actual { Ask | Bid } -price-levels. Kindly review your Broker's T&C and best adapt your code to prevent falling into those conditions colliding instructions.

Cancel quote

Checking account access…