Forex
Google

Go Back   Forex Trading > Discussion Areas > Metatrader 4
Forex Forum Register FAQ Members List Calendar Search Today's Posts Mark Forums Read


Register in Forex TSD!
Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time).
Click here to register and get more information

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-13-2005, 04:24 AM
secxces's Avatar
secxces secxces is offline
Senior Member
 
Join Date: Nov 2005
Posts: 90
secxces is on a distinguished road
Talking MetaTrader 4 Scripts

I noticed there isnt a thread for MetaTrader 4 scripts. I dont really have any, and the few I have collected dont work. Besides the buy scripts, which can be found almost everywere, maybe someone has a trailing stop script, or a close all script, etc. I had a "close all open and pending order", but it didnt work. Ill see if I can find it to post it anyway.

Thanks all,
- secXces
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 12-13-2005, 12:03 PM
codersguru's Avatar
codersguru codersguru is offline
Senior Member
 
Join Date: Oct 2005
Posts: 987
codersguru has a spectacular aura aboutcodersguru has a spectacular aura aboutcodersguru has a spectacular aura about
Thumbs up Scripts thread!

Quote:
Originally Posted by secxces
I noticed there isnt a thread for MetaTrader 4 scripts. I dont really have any, and the few I have collected dont work. Besides the buy scripts, which can be found almost everywere, maybe someone has a trailing stop script, or a close all script, etc. I had a "close all open and pending order", but it didnt work. Ill see if I can find it to post it anyway.

Thanks all,
- secXces
secXces,
It's a very good idea to have a thread for the scrpits( mql2 & mql4).
Hope to see this thread soon.
__________________
Hope it helps !
Coders' Guru
Senior MQL programmer:
www.xpworx.com/custom.htm
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 01-06-2006, 10:18 AM
jimmycash jimmycash is offline
Junior Member
 
Join Date: Dec 2005
Posts: 4
jimmycash is on a distinguished road
Trendline Script

Quote:
Originally Posted by codersguru
Originally Posted by codersguru
Hi folks,

I've got a lot of private messages asking me for helping with some pieces of code.

Here you can post your questions related to MQL4, and I'll do my best to answer them.
codersguru I would like a script that executes a buy or sell order with stop loss and take profit when price crosses a trendline that I draw on the chart. Also, I would like the script to have the ability to disable the buy/sell function and only generate an alert when the trendline is crossed by the price. I hope you can help with this. Thank you very much, Happy New Year!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 01-11-2006, 02:26 PM
Roets's Avatar
Roets Roets is offline
Senior Member
 
Join Date: Nov 2005
Location: North West South Africa
Posts: 115
Roets is on a distinguished road
Question

Can you please help me with the referencing of the previous value on an indicator for example:

MovingAverage[2]
__________________
Pro FX Experts for Professional Meta Trader Experts
Automate your manual method!
We accept all major credit cards with no upfront payment required!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 01-12-2006, 08:50 AM
pileo pileo is offline
Junior Member
 
Join Date: Jan 2006
Posts: 2
pileo is on a distinguished road
Post Script to close all positions

Here is a little script I wrote that closes all open positions. You need to check "Alow Live Trading" option under Options > Expert Advisor tab in order for this script to work.

To Setup:
- Open up MetaEditor.
- Click File > New
- Select "Script program"
- Select replace all text with code below
- Compile & Run

I hope you find it as useful as I do.

Code:
//+------------------------------------------------------------------+
//|                                                    CLOSE_ALL.mq4 |
//|                                                             pileo|
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "pileo"
#property link      "http://www.metaquotes.net"

#include <stdlib.mqh>
#include <WinUser32.mqh>
//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
int start()
  {
//---- 
   if(MessageBox("Do you really want to close all positions?", "Close All", MB_YESNO|MB_ICONQUESTION) !=IDYES) return(1);
 
   double prc;
   int prc_mode;
     
   int total = OrdersTotal();
   int orders[];
   
   int size;
   size = ArrayResize(orders, total);
   
   //Get original positions
   for(int i=0;i<total;i++)
   {
      OrderSelect(i, SELECT_BY_POS);
      orders[i] = OrderTicket();
   }
   
   if(size <= 0)
   {
      //No open orders
      return(-1);
   }


   int ticketSent;   
   for(int x=0;x<size;x++)
   {
      OrderSelect(orders[x], SELECT_BY_TICKET);
      
      if(OrderType()==OP_BUY)
         prc_mode = MODE_BID; 
      else
         prc_mode = MODE_ASK;
         
      prc = MarketInfo(OrderSymbol(), prc_mode);
      
      Print("Closing Order # ", orders[x], " symbol: ", OrderSymbol(), " price: ", prc);
      
      if(OrderClose(orders[x],OrderLots(),prc,3))
      {
         Print("Order # ", orders[x], " closed");
      }
      else
      {
         Print("Failed to close Order # ", orders[x], " Error: ", GetLastError());
         return(false);
      }
   }

//----
   return(0);
  }
//+------------------------------------------------------------------+
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


Similar Threads
Thread Thread Starter Forum Replies Last Post
'Close all'/'Open' tools newdigital Tools and utilities 168 07-17-2008 08:27 PM
applying mt4 scripts symtec23 Metatrader 4 2 01-31-2006 02:44 PM


All times are GMT. The time now is 09:27 AM.