View Single Post
  #1 (permalink)  
Old 01-15-2006, 09:29 PM
sadaloma's Avatar
sadaloma sadaloma is offline
Senior Member
 
Join Date: Sep 2005
Posts: 343
sadaloma is on a distinguished road
Script for buy/sell

Hi,

There is a script available in MT4 called trade.mq4 that open a "buy" position.

Could someone help me configure this script? What I want is a simple change of value. I don't want it to have a pop up configurable settings window because I just want to drag and drop the script at a currency window and have my trade open up instantly without having to input anything.

My idea is to create numerous script with different settings.

for example:

- 1 script with BUY TP 20, SL 35,TS 15
- 1 script with SELL TP 20, SL 35,TS 15
- etc

The code of trade.mq4:

Code:
//+------------------------------------------------------------------+
//|                                                        trade.mq4 |
//|                      Copyright © 2004, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net/"

#include <stdlib.mqh>
#include <WinUser32.mqh>
//+------------------------------------------------------------------+
//| script "trading for all money"                                   |
//+------------------------------------------------------------------+
int start()
  {
//----
   if(MessageBox("Do you really want to BUY 1.00 "+Symbol()+" at ASK price?    ",
                 "Script",MB_YESNO|MB_ICONQUESTION)!=IDYES) return(1);

  
   double                        ts, tp, sl;
   double                        TrailingStop;
   double                        TakeProfit;
   double                        InitialStopLoss;

   {
    
      TrailingStop = 40;
      TakeProfit = 72;
      InitialStopLoss=52;
   } 
   
   int ticket=OrderSend(Symbol(),OP_BUY,1.0,Ask,3,0,0,"expert comment",255,0,CLR_NONE);
   if(ticket<1)
     {
      int error=GetLastError();
      Print("Error = ",ErrorDescription(error));
      return;
     }
//----
   OrderPrint();
   return(0);
  }
//+------------------------------------------------------------------+


I tried changing around the values but I always get invalid stops.
What should I change to be able to get the values I want to configure?

Thank you in advance for your help.

Sada
Reply With Quote