how can I get last trade result?

how can I get last trade result?

Manage alerts

Loading saved threads...

Gudy · External communityPost link
External question — Stack Overflow Stack Exchange Author: Gudy Original post: https://stackoverflow.com/questions/65936413 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. How can I get the last trade result in mql4 bot? I mean the part of code, mine does not work. This is code, how can I do it? int a = 0; while(a == 0){ OrderSend(Symbol(),OP_BUY,0.01,price,5,0,(Ask+0.0002),0,0,0,Green); a = 1; } //if(OrderSelect(OrdersTotal()-1, SELECT_BY_POS)==true){ // Print("Profit for the order 10 " + OrderProfit()); //} //else{ // Print("OrderSelect returned the error of " + GetLastError()); //} OrderSelect(OrderTicket(), SELECT_BY_POS); Print("Profit for the order 10 " + OrderProfit()); OrderModify(OrderTicket(),OrderOpenPrice(),(Ask-0.0001),0,0,0); if(OrderProfit()<0){ OrderSend(Symbol(),OP_SELL,0.01,price,5,0,0,0,0,0,Green); } else{ OrderSend(Symbol(),OP_BUY,0.01,price,5,0,0,0,0,0,Red); }
Quote
Report
tomgny · External communityPost link
External answer — Stack Overflow Stack Exchange Author: tomgny Original post: https://stackoverflow.com/a/66003215 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. To select last open or pending order from trading pool: OrderSelect(OrdersTotal()-1, SELECT_BY_POS); If you want to select last closed or canceled order: OrderSelect(OrdersHistoryTotal()-1, SELECT_BY_POS, MODE_HISTORY); You can get more information in the docs OrderSelect()
Quote
Report
Yasin İPEK · External communityPost link
External answer — Stack Overflow Stack Exchange Author: Yasin İPEK Original post: https://stackoverflow.com/a/75755218 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. double KapananPozisyon() { static datetime biletZaman=0; static double kar=0; for(int i=0; i<OrdersHistoryTotal(); i++) { if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)) if(biletZaman<OrderCloseTime()) { kar=OrderProfit(); biletZaman=OrderCloseTime(); } } return kar; }
Quote
Report

Post Reply

Quoted from Forex.com.bd-Editorial External answer — Stack Overflow Stack Exchange Author: Yasin İPEK Source score (net votes, not local likes): 0 Original post: https://stackoverflow.com/a/75755218 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. double KapananPozisyon() { static datetime biletZaman=0; static double kar=0; for(int i=0; i<OrdersHistoryTotal(); i++) { if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)) if(biletZaman<OrderCloseTime()) { kar=OrderProfit(); biletZaman=OrderCloseTime(); } } return kar; }

Cancel quote

Checking account access…