View Single Post
  #7 (permalink)  
Old 06-14-2007, 06:24 PM
iscuba11's Avatar
iscuba11 iscuba11 is offline
Senior Member
 
Join Date: May 2006
Location: Houston
Posts: 398
iscuba11 is on a distinguished road
Question

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(0SELECT_BY_POS);

if (
OrderType() == OP_BUY) {
if (
OrderStopLoss() < Bid-Point*TSOrderModify(OrderTicket(),0,Bid-Point*TS,OrderTakeProfit(),0,Red); }

if (
OrderType() == OP_SELL) {
if (
OrderStopLoss() > Bid+Point*TSOrderModify(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); }
//----

Reply With Quote