Hi Guys,
Can someone please help with CoderGurus script below.
It works great as it is but I wanted to modify it so that it will stop the stop loss and profit take based on the opening price of the trade, not the current bid and ask prices.
As I said, it works fine as is, I thought I would just have to change OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*StopLoss,Bid+Point*TakeProfit,0,Green); to
OrderModify(OrderTicket(),OrderOpenPrice(),OrderOp enPrice()-Point*StopLoss,OrderOpenPrice()+Point*TakeProfit,0 ,Green);
but when I try and run it nothing happens.
Can someone please point me in the right direction.
Thanks
Steve
//+------------------------------------------------------------------+
//| My_First_Script.mq4 |
//| Copyright Coders Guru |
//| http://www.forex-tsd.com |
//+------------------------------------------------------------------+
#property copyright "Copyright Coders Guru"
#property link "http://www.forex-tsd.com"
#property show_inputs
#include <stdlib.mqh>
extern double TakeProfit=250;
extern double StopLoss=35;
//+------------------------------------------------------------------+
//| script program start function |
//+------------------------------------------------------------------+
int start()
{
int total,cnt,err;
double stop_loss_value;
double take_profit_value;
total = OrdersTotal();
for(cnt=0;cnt<total;cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if(OrderType()==OP_BUY) // long position is opened
{
OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*StopLoss,Bid+Point*TakeProfit,0,Green);
err=GetLastError();
Print ("High - ");
Print("error(",err,"): ",ErrorDescription(err));
Sleep(1000);
}
if(OrderType()==OP_SELL) // short position is opened
{
OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Poi nt*StopLoss,Ask-Point*TakeProfit,0,Red);
err=GetLastError();
Print("error(",err,"): ",ErrorDescription(err));
Sleep(1000);
}
}
return(0);
}
Can someone please help with CoderGurus script below.
It works great as it is but I wanted to modify it so that it will stop the stop loss and profit take based on the opening price of the trade, not the current bid and ask prices.
As I said, it works fine as is, I thought I would just have to change OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*StopLoss,Bid+Point*TakeProfit,0,Green); to
OrderModify(OrderTicket(),OrderOpenPrice(),OrderOp enPrice()-Point*StopLoss,OrderOpenPrice()+Point*TakeProfit,0 ,Green);
but when I try and run it nothing happens.
Can someone please point me in the right direction.
Thanks
Steve
//+------------------------------------------------------------------+
//| My_First_Script.mq4 |
//| Copyright Coders Guru |
//| http://www.forex-tsd.com |
//+------------------------------------------------------------------+
#property copyright "Copyright Coders Guru"
#property link "http://www.forex-tsd.com"
#property show_inputs
#include <stdlib.mqh>
extern double TakeProfit=250;
extern double StopLoss=35;
//+------------------------------------------------------------------+
//| script program start function |
//+------------------------------------------------------------------+
int start()
{
int total,cnt,err;
double stop_loss_value;
double take_profit_value;
total = OrdersTotal();
for(cnt=0;cnt<total;cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if(OrderType()==OP_BUY) // long position is opened
{
OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*StopLoss,Bid+Point*TakeProfit,0,Green);
err=GetLastError();
Print ("High - ");
Print("error(",err,"): ",ErrorDescription(err));
Sleep(1000);
}
if(OrderType()==OP_SELL) // short position is opened
{
OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Poi nt*StopLoss,Ask-Point*TakeProfit,0,Red);
err=GetLastError();
Print("error(",err,"): ",ErrorDescription(err));
Sleep(1000);
}
}
return(0);
}