Quote:
|
Originally Posted by european
Plenty of examples of Trailing Stop code on this site - use 'Search' function
My example of TS:
*************************************
extern int TS = 30; //Trailing Stop
int start()
{
//----
OrderSelect(0, SELECT_BY_POS);
if (OrderType() == OP_BUY) {
if (OrderStopLoss() < Bid-Point*TS) OrderModify(OrderTicket(),0,Bid-Point*TS,OrderTakeProfit(),0,Red); }
if (OrderType() == OP_SELL) {
if (OrderStopLoss() > Bid+Point*TS) OrderModify(OrderTicket(),0,Bid+Point*TS,OrderTake Profit(),0,Red); }
//----
}
|
When I use this script as a script to just drag over a graph it does not reflect activation has taken place. If I use a modify script, and then right click the mouse and select modify or delete order, the modify script settings are reflected in the modify window. But if I use your trailing stop script it does not reflect in the right click mouse - trailing stop window. This is the problem - How do I know if the trailing stop is even activated??
PHP Code:
//+------------------------------------------------------------------+
//| Script Trailing Stop.mq4 |
//| |
//| |
//| |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net/"
#include <stdlib.mqh>
#include <WinUser32.mqh>
//+------------------------------------------------------------------+
//| script "Create Trailing Stop On Open Position" |
//+------------------------------------------------------------------+
extern int TS = 30; //Trailing Stop
int start()
{
//----
OrderSelect(0, SELECT_BY_POS);
if (OrderType() == OP_BUY) {
if (OrderStopLoss() < Bid-Point*TS) OrderModify(OrderTicket(),0,Bid-Point*TS,OrderTakeProfit(),0,Red); }
if (OrderType() == OP_SELL) {
if (OrderStopLoss() > Bid+Point*TS) OrderModify(OrderTicket(),0,Bid+Point*TS,OrderTakeProfit(),0,Red); }
//----
}
//+------------------------------------------------------------------+
/*My example of TS:
*************************************
extern int TS = 30; //Trailing Stop
int start()
{
//----
OrderSelect(0, SELECT_BY_POS);
if (OrderType() == OP_BUY) {
if (OrderStopLoss() < Bid-Point*TS) OrderModify(OrderTicket(),0,Bid-Point*TS,OrderTakeProfit(),0,Red); }
if (OrderType() == OP_SELL) {
if (OrderStopLoss() > Bid+Point*TS) OrderModify(OrderTicket(),0,Bid+Point*TS,OrderTake Profit(),0,Red); }
//----
}