Script to place market order with TP and SL set

 

Hi guys,

I was wondering whether someone might quickly code up a script that will allow me to place a market order with a defined stop loss and take profit. I've included a feeble attempt below which doesn't seem to be working.

Any help would be fantastic

Martin

//+------------------------------------------------------------------+

//| Buy.mq4 |

//+------------------------------------------------------------------+

#property copyright ""

#property link ""

#include

#include

double Lots=0.1;

int Slippage=3;

int TakeProfit=99;

int StopLoss=10;

//+------------------------------------------------------------------+

//| script program start function |

//+------------------------------------------------------------------+

int start()

{

double MyStopLoss=Ask-StopLoss*Point;

double MyTakeProfit=Ask+TakeProfit*Point;

//----

OrderPrint();

OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,MyStopLoss,MyTakeProfit,"Buy",0,0,CLR_NONE);

return(0);

}

//+------------------------------------------------------------------+

 
Reason: