• Home
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • User/Email: Password:
  • 5:12am
Menu
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • 5:12am
Sister Sites
  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Options

Bookmark Thread

First Page First Unread Last Page Last Post

Print Thread

Similar Threads

Smjones' Buy & Sell Scripts with BE settings 2 replies

Help with pending buy stop and sell stop scripts 5 replies

T101 buy all or sell all scripts with a twist. 0 replies

Scripts To buy, sell 2 replies

Can anyone share Buy-Sell-Close scripts to use as a hotkey without using F9 option? 5 replies

  • Platform Tech
  • /
  • Reply to Thread
  • Subscribe
  • 1
Attachments: Buy-Sell-Close scripts ?
Exit Attachments
Tags: Buy-Sell-Close scripts ?
Cancel

Buy-Sell-Close scripts ?

  • Post #1
  • Quote
  • First Post: Jun 30, 2008 2:04pm Jun 30, 2008 2:04pm
  •  Coconut
  • | Joined Jun 2008 | Status: Member | 62 Posts
Hi, ive been searching online for some scripts i could use HOTMEY for buying , selling and closing....

I found a few but i cannot make them work....

I save under /experts/scripts

So i open metatrader and try to run them and nothing happens ....

Any ideas ? ^ thnx
  • Post #2
  • Quote
  • Jul 1, 2008 12:38pm Jul 1, 2008 12:38pm
  •  DaveL
  • | Joined Aug 2006 | Status: Member | 142 Posts
Might help to post the scripts in question, so that someone can help examine them for you.
Dave
 
 
  • Post #3
  • Quote
  • Jul 1, 2008 5:52pm Jul 1, 2008 5:52pm
  •  lucidlamp
  • | Joined May 2007 | Status: I do my best while asleep... | 238 Posts
Coconut,

Are they compiled? If not let me know, otherwise:

Hit 'CTRL+O' on your keyboard while MetaTrader is active. This will open an 'Options' window. Click the 'Expert Advisors' tab. Make sure the option 'Allow Live Trading' is checked.

If this is not the problem. The script may be returning errors. Check your 'Experts' tab in the 'Terminal' window.

lucidlamp
 
 
  • Post #4
  • Quote
  • Jul 4, 2008 1:55pm Jul 4, 2008 1:55pm
  •  Coconut
  • | Joined Jun 2008 | Status: Member | 62 Posts
Hi Davel and lucid !

Thnx for support....

I found them on google...

The scripts are:

Close.mq4 Runs but is removed and doesnt close an open trade......



//| close.mq4 |
//| Copyright 2004, MetaQuotes Software Corp. |
//| http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright 2004, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net/"
#property show_confirm
//+------------------------------------------------------------------+
//| script "close first market order if it is first in the list" |
//+------------------------------------------------------------------+
int start()
{
int total = OrdersTotal();
for(int i=total-1;i>=0;i--)
{
OrderSelect(i, SELECT_BY_POS);
int type = OrderType();
bool result = false;

switch(type)
{
//Close opened long positions
case OP_BUY : result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, Red );
break;

//Close opened short positions
case OP_SELL : result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 5, Red );

}

if(result == false)
{
// Alert("Order " , OrderTicket() , " failed to close. Error:" , GetLastError() );
if(!IsTesting( ) )
Sleep(3000);
}
}

return(0);
}





And



//| Hotkey Sell.mq4 |
//| Copyright 2006, Archer Trading, LLC |
//| http://www.archertrading.net |
//+------------------------------------------------------------------+
#property copyright "Copyright 2006, Archer Trading, LLC"
#property link "http://www.archertrading.net"
#include <stdlib.mqh>
extern int TakeProfit = 20;
extern int StopLoss = 20;
extern int Slippage = 3;
extern double Lots = 5.0;
int start()
{
int ticket = 0;
int err = 0;
int SL = 0;
int TP = 0;

while(true)
{
SL = Bid + StopLoss*Point;
TP = Bid - TakeProfit*Point;
ticket = OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,SL,TP,"HotKey Sell",0,0,Red);
if(ticket == -1)
{
err=GetLastError();
Print("Error(",err,"): ",ErrorDescription(err));
if(err == 129 || err == 138 || err == 135)
{
RefreshRates();
}
}
if(ticket == -1)
{
err=GetLastError();
Print("Error(",err,"): ",ErrorDescription(err));
if(err==134)
{
break;
}
Print("Retrying SELL entry");
ticket = OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,SL,TP,"HotKey Sell",0,0,Red);
if(ticket == -1)
{
err=GetLastError();
Print("Retrying SELL error(",err,"): ",ErrorDescription(err));
}
if(ticket > 0)
{
Print("SELL order placed at: " + Bid + ", ticket: " + ticket + ", current price: " + Ask);
}
return(0);
}
}
return(0);
}




Anddddd


//+------------------------------------------------------------------+
//| Hotkey Buy.mq4 |
//| Copyright 2006, Archer Trading, LLC |
//| http://www.archertrading.net |
//+------------------------------------------------------------------+
#property copyright "Copyright 2006, Archer Trading, LLC"
#property link "http://www.archertrading.net"
#include <stdlib.mqh>
extern int TakeProfit = 20;
extern int StopLoss = 20;
extern int Slippage = 3;
extern double Lots = 5.0;
int start()
{
int ticket = 0;
int err = 0;
int SL = 0;
int TP = 0;

while(true)
{
SL = Ask - StopLoss*Point;
TP = Ask + TakeProfit*Point;
ticket = OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,SL,TP,"HotKeyBuy",0,0,Blue);
if(ticket == -1)
{
err=GetLastError();
Print("Error(",err,"): ",ErrorDescription(err));
if(err == 129 || err == 138 || err == 135)
{
RefreshRates();
}
}
if(ticket == -1)
{
err=GetLastError();
Print("Error(",err,"): ",ErrorDescription(err));
if(err==134)
{
break;
}
Print("Retrying BUY entry.");
ticket = OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,SL,TP,"HotKeyBuy",0,0,Blue);
if(ticket == -1)
{
err=GetLastError();
Print("Retrying BUY error(",err,"): ",ErrorDescription(err));
}
if(ticket > 0)
{
Print("BUY order placed at: " + Ask + ", ticket: " + ticket + ", current price: " + Bid);
}
return(0);
}
}
return(0);
}



Lucid i looked the log and they are being executed but automaticly removed

It says invalid stops....

Also found this other script it loads but is removed also with no error tho doesnt work either....

#property copyright "Copyright 2006, Archer Trading, LLC"
#property link "http://www.archertrading.net"
#include <stdlib.mqh>
extern int TakeProfit = 20.0;
extern int StopLoss = 20.0;
extern int Slippage = 3;
extern double Lots = 5.0;
if(signal==2)
{
res=OrderSend(Symbol(),OP_SELL,LotsOptimized(),Bid,3,Bid+(StopLoss*Point),Bid-(TakeProfit*Point), "Sell",MAGICMA,0,Red);
if (res>0)
{
Print("Order #",res," opend by Sell Signal");
}
else
{
err=GetLastError();
Print("Error(",err,") opening Sell position: ",ErrorDescription(err));
}
return;
}if(signal==1)
{
res=OrderSend(Symbol(),OP_BUY,LotsOptimized(),Ask,3,StopLoss,TakeProfit,"Buy",MAGICMA,0,Blue);
if (res>0)
{
Print("Order #",res," opend by normale Buy Signal");
}
else
{
err=GetLastError();
Print("Error(",err,") opening Buy position: ",ErrorDescription(err));
}
return;
}



Also im having problem with another indicator... 4_Pivot_Calculator : Arrayinitialize function internal error any ideas ? This one is creating 10mb log files every day.... LoL


Thanks allot !
Attached File(s)
File Type: mq4 PivotCustom_4TimeFrames.mq4   45 KB | 328 downloads
 
 
  • Post #5
  • Quote
  • Jul 5, 2008 10:24am Jul 5, 2008 10:24am
  •  ravster
  • | Joined Jun 2008 | Status: Member | 31 Posts
Hey,
With regard to the invalid stops error, you are currently using
Inserted Code
OrderSend(Symbol(),OP_BUY,Lots,Ask,  Slippage,SL,TP,"HotKeyBuy",0,0,Blue  );
This is incorrect. What you should put is
Inserted Code
OrderSend(Symbol(),OP_BUY,Lots,Ask,  Slippage,Ask - SL * Point, Ask + TP * Point,"HotKeyBuy",0,0,Blue  );
This way, the function will get an absolute value for the SL and TP points.
 
 
  • Post #6
  • Quote
  • Last Post: Jul 8, 2008 4:14pm Jul 8, 2008 4:14pm
  •  Coconut
  • | Joined Jun 2008 | Status: Member | 62 Posts
Ravster, i couldnt manage the correct the script!

Can you or anyone help me sending working files of BUY - CLOSE and Sell scripts ???

Thank you.
 
 
  • Platform Tech
  • /
  • Buy-Sell-Close scripts ?
  • Reply to Thread
0 traders viewing now
Top of Page
  • Facebook
  • Twitter
About FF
  • Mission
  • Products
  • User Guide
  • Media Kit
  • Blog
  • Contact
FF Products
  • Forums
  • Trades
  • Calendar
  • News
  • Market
  • Brokers
  • Trade Explorer
FF Website
  • Homepage
  • Search
  • Members
  • Report a Bug
Follow FF
  • Facebook
  • Twitter

FF Sister Sites:

  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Forex Factory® is a brand of Fair Economy, Inc.

Terms of Service / ©2023