Detected Country () : English
Buy & Sell Trading Execution - codingforex.com

Welcome to CodingForex.Com!

Knowledge portal where you can learn how to create forex indicators and robot.

Click button below to choose level that suite you:

Buy & Sell Trading Execution

Level Beginner [2017-11-07 09:41:56] - by hillzx
Featured Image

Previously we have discussed the difference in Ask and Bid prices in this article. Next how do trade execution?

Buy execution is done using Ask price, while selling execution or Sell is done using Bid price.

 

OrderSend(param1,param2,param3,param4,param5,param6,param7,param8);

Parameter 1: Symbols, for example EURUSD

Parameter 2: OP_BUY / OP_SELL

Parameter 3: Lot Volume, for example 0.01

Parameter 4: Selling / Purchasing Price, eg 1.03855

Parameter 5: Slippage tolerance, for example 7, means that transactions are still done despite slipping up to 7 points from the original price

Parameter 6: Stoploss, for example 1.03800

Parameter 7: Takeprofit, for example 1.03900

Parameter 8: Comment, for example "Robot I"

 

Here is an example code how to Buy And Sell :

 

double LotSize = 0.01;
int Slippage = 7;
int StopLoss=100;
int TakeProfit=100;
string Komentar="Ini orderan robot gue";

// Transaksi Buy
OrderSend(Symbol(),OP_BUY,LotSize,Ask,Slippage,Ask-StopLoss*Point,Ask+TakeProfit*Point,Komentar);

// Transaksi Sell
OrderSend(Symbol(),OP_SELL,LotSize,Bid,Slippage,Bid+StopLoss*Point,Bid-TakeProfit*Point,Komentar);



But sometimes the transaction conditions often can not be executed because the internet connection is unstable or choked so that the transaction becomes void, to prevent it we can repeat the transaction up to 3 times so the transaction is really ascertained executed, the way as follows:

 

double LotSize = 0.01;
int Slippage = 7;
int StopLoss=100;
int TakeProfit=100;
string Komentar="Ini orderan robot gue";
int Repeat=3; //Ulangi hingga 3x apabila transaksi gagal


for(int r=0;r<Repeat;r++)
{
   int ticket;
// Transaksi Buy
OrderSend(Symbol(),OP_BUY,LotSize,Ask,Slippage,Ask-StopLoss*Point,Ask+TakeProfit*Point,Komentar);
            
   if(ticket>0)
   {
     break; // Segera hentikan perulangan apabila transaksi sukses
   }
 
   RefreshRates(); // Perbarui harga Ask dan Bid
}

Good luck, do not forget to share and follow our official facebook and youtube, happy trading!



Previous Article

Featured Image

Ask And Bid Price

Next Article

Featured Image

Accepting Input




- Provided by HiLLzSoft Studio -