Forex



Go Back   Forex Trading > Programming > Metatrader Programming






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
 
Thread Tools Display Modes
  #1511 (permalink)  
Old 12-22-2008, 11:29 PM
Junior Member
 
Join Date: Sep 2008
Posts: 13
kk81 is on a distinguished road
buy and sell at the same time

can someone help to program so tat i can buy and sell at the same time...some scripts or etc...

i appreciate it...

example:

if (Stoch1>=Stoch2)
{
ticket=OrderSend(Symbol(), OP_BUY, Lots, Ask, 3, Ask-Stoploss*Point, Ask+TakeProfit*Point, "-", 0, 0, Green);
ticket=OrderSend(Symbol(), OP_SELL, Lots, Bid, 3, Ask-Stoploss*Point, Bid-TakeProfit*Point,"-", 0, 0, Red);
}

the problem is it wil only buy..but i ned it to execute both order...thanks..

Last edited by newdigital; 12-23-2008 at 07:42 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #1512 (permalink)  
Old 12-23-2008, 12:28 AM
Senior Member
 
Join Date: Oct 2008
Location: Vancouver, BC
Posts: 158
Roger09 is on a distinguished road
Quote:
Originally Posted by kk81 View Post
can someone help to program so tat i can buy and sell at the same time...some scripts or etc...

i appreciate it...

example:

if (Stoch1>=Stoch2)
{
ticket=OrderSend(Symbol(), OP_BUY, Lots, Ask, 3, Ask-Stoploss*Point, Ask+TakeProfit*Point, "-", 0, 0, Green);
ticket=OrderSend(Symbol(), OP_SELL, Lots, Bid, 3, Ask-Stoploss*Point, Bid-TakeProfit*Point, "-", 0, 0, Red);
}

the problem is it wil only buy..but i ned it to execute both order...thanks..
MQL4 Learning

Last edited by newdigital; 12-23-2008 at 07:43 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #1513 (permalink)  
Old 12-27-2008, 11:36 AM
Senior Member
 
Join Date: Apr 2008
Location: Rawalpindi
Posts: 106
arshadFX is on a distinguished road
how to get OrderClose return price ?

I want to know, at what price the order is closed
Attached Images
File Type: jpg closeorder.JPG (61.7 KB, 89 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #1514 (permalink)  
Old 12-29-2008, 11:56 PM
Junior Member
 
Join Date: Nov 2008
Posts: 3
m_43_62 is on a distinguished road
Smile Forex freedom Bar

hi
thanks very much all friends , specific Roger09
I want expert (automatic trade) ForexFreedomBars .
when square 5m , 15m ,30m ,1H is Red , send order SELL by 10-20 TP
when square 5m , 15m ,30m ,1H is Blue , send order BUY by 10-20 TP
(TP, SL , lot, maxtrade) ability have to change
please help me .



//+------------------------------------------------------------------+
//| #The Forex Freedom Bars
//|
//+------------------------------------------------------------------+
#property copyright "Programmed by Eli hayun"
#property indicator_separate_window
#property indicator_minimum -0.5
//#property indicator_maximum 5
#property indicator_buffers 8
#property indicator_color1 Red
#property indicator_color2 DodgerBlue
#property indicator_color3 Red
#property indicator_color4 DodgerBlue
#property indicator_color5 Red
#property indicator_color6 DodgerBlue
#property indicator_color7 Red
#property indicator_color8 DodgerBlue
//---- buffers
double buf4_up[];
double buf4_down[];
double buf3_up[];
double buf3_down[];
double buf2_up[];
double buf2_down[];
double buf1_up[];
double buf1_down[];

extern double Gap = 1; // Gap between the lines of bars

extern int Period_1 = PERIOD_M5;//M15
extern int Period_2 = PERIOD_M15;//M30
extern int Period_3 = PERIOD_M30;//H1
extern int Period_4 = PERIOD_H1;//H4

extern int cci_1 = 2;//50
extern int cci_2 = 2;//14
extern int cci_3 = 2;
extern int cci_4 = 2;
extern int StopLoss=100;
extern int TakeProfit=100;
extern double Lots=0.1;

extern bool AutoDisplay = false;

string shortname = "";
bool firstTime = true;

int UniqueNum = 228;

//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{


SetAutoDisplay();


shortname = "# Forex Freedom("+Period_1+","+Period_2+","+Period_3+","+P eriod_4+")";
firstTime = true;

IndicatorShortName(shortname);
//---- indicators
SetIndexStyle(0,DRAW_ARROW);
SetIndexArrow(0,110);
SetIndexBuffer(0,buf4_up);
SetIndexEmptyValue(0,0.0);
SetIndexStyle(1,DRAW_ARROW);
SetIndexArrow(1,110);
SetIndexBuffer(1,buf4_down);
SetIndexEmptyValue(1,0.0);
SetIndexStyle(2,DRAW_ARROW);
SetIndexArrow(2,110);
SetIndexBuffer(2,buf3_up);
SetIndexEmptyValue(2,0.0);
SetIndexStyle(3,DRAW_ARROW);
SetIndexArrow(3,110);
SetIndexBuffer(3,buf3_down);
SetIndexEmptyValue(3,0.0);
SetIndexStyle(4,DRAW_ARROW);
SetIndexArrow(4,110);
SetIndexBuffer(4,buf2_up);
SetIndexEmptyValue(4,0.0);
SetIndexStyle(5,DRAW_ARROW);
SetIndexArrow(5,110);
SetIndexBuffer(5,buf2_down);
SetIndexEmptyValue(5,0.0);
SetIndexStyle(6,DRAW_ARROW);
SetIndexArrow(6,110);
SetIndexBuffer(6,buf1_up);
SetIndexEmptyValue(6,0.0);
SetIndexStyle(7,DRAW_ARROW);
SetIndexArrow(7,110);
SetIndexBuffer(7,buf1_down);
SetIndexEmptyValue(7,0.0);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
SetAutoDisplay();

shortname = "# Forex Freedom("+Period_1+","+Period_2+","+Period_3+","+P eriod_4+")";
firstTime = true;
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
int i=0, y5m=0, y1h=0, y30m=0, y15m=0, yy;
int limit=Bars-counted_bars;

datetime TimeArray_1H[], TimeArray_30M[], TimeArray_15M[], TimeArray_5M[];
//----



if (firstTime || NewBar())
{
firstTime = false;
int win = UniqueNum; // WindowFind(shortname);
double dif = Time[0] - Time[1];
for (int ii=ObjectsTotal()-1; ii>-1; ii--)
{
if (StringFind(ObjectName(ii),"FF_"+win+"_") >= 0)
ObjectDelete(ObjectName(ii));
else
ii=-1;
}

double shift = 0.2;
for (ii=0; ii<4; ii++)
{
string txt = "??";
double gp;
switch (ii)
{
case 0: txt = tf2txt(Period_1); gp = 1 + shift; break;
case 1: txt = tf2txt(Period_2); gp = 1 + Gap + shift; break;
case 2: txt = tf2txt(Period_3); gp = 1 + Gap*2 + shift; break;
case 3: txt = tf2txt(Period_4); gp = 1 + Gap*3 + shift; break;
}
string name = "FF_"+win+"_"+ii+"_"+txt;
ObjectCreate(name, OBJ_TEXT, WindowFind(shortname), iTime(NULL,0,0)+dif*3, gp);
ObjectSetText(name, txt,8,"Arial", Silver);
}
}

ArrayCopySeries(TimeArray_1H,MODE_TIME,Symbol(),Pe riod_4);
ArrayCopySeries(TimeArray_30M,MODE_TIME,Symbol(),P eriod_3);
ArrayCopySeries(TimeArray_15M,MODE_TIME,Symbol(),P eriod_2);
ArrayCopySeries(TimeArray_5M,MODE_TIME,Symbol(),Pe riod_1);

for(i=0, y5m=0, y1h=0, y30m=0, y15m=0;i<limit;i++)
{
if (Time[i]<TimeArray_5M[y5m]) y5m++;
if (Time[i]<TimeArray_1H[y1h]) y1h++;
if (Time[i]<TimeArray_30M[y30m]) y30m++;
if (Time[i]<TimeArray_15M[y15m]) y15m++;

int cci_n = cci_1;
for (int tf = 0; tf < 4; tf++)
{
int prd;
switch (tf)
{
case 0: prd = Period_1; cci_n = cci_1; yy = y5m; break;
case 1: prd = Period_2; cci_n = cci_2; yy = y15m; break;
case 2: prd = Period_3; cci_n = cci_3; yy = y30m; break;
case 3: prd = Period_4; cci_n = cci_4; yy = y1h; break;
}

double cci = iCCI(NULL, prd, cci_n,PRICE_TYPICAL, yy);
double dUp = EMPTY_VALUE; // iCustom(NULL, prd, "SuperTrend", false, 1, yy);
double dDn = EMPTY_VALUE; //iCustom(NULL, prd, "SuperTrend", false, 0, yy);

if (cci < 0) dUp = 1; else dDn = 1;

switch (tf)
{
case 0: if (dUp == EMPTY_VALUE) buf1_down[i] = 1; else buf1_up[i] = 1; break;
case 1: if (dUp == EMPTY_VALUE) buf2_down[i] = 1 + Gap * 1; else buf2_up[i] = 1 + Gap * 1; break;
case 2: if (dUp == EMPTY_VALUE) buf3_down[i] = 1 + Gap * 2; else buf3_up[i] = 1 + Gap * 2; break;
case 3: if (dUp == EMPTY_VALUE) buf4_down[i] = 1 + Gap * 3; else buf4_up[i] = 1 + Gap * 3; break;
}
if (NewBar())
{
string sDir = "";
if (buf1_up[0] + buf2_up[0] + buf3_up[0] + buf4_up[0] == 4)
sDir = "Up";
if (buf1_down[0] + buf2_down[0] + buf3_down[0] + buf4_down[0] == 4)
sDir = "Down";
if (sDir != "")
{
PlaySound("alert1.wav");
Print("Forex freeway - Direction ",sDir);
}
}
}
}

if (buf1_up[0] + buf2_up[0] + buf3_up[0] + buf4_up[0] == 4)

OrderSend(Symbol(),OP_BUY,Lots,Ask,3,StopLoss ,TakeProfit); else

return(0);
}
//+------------------------------------------------------------------+

string tf2txt(int tf)
{
if (tf == PERIOD_M1) return("M1");
if (tf == PERIOD_M5) return("M5");
if (tf == PERIOD_M15) return("M15");
if (tf == PERIOD_M30) return("M30");
if (tf == PERIOD_H1) return("H1");
if (tf == PERIOD_H4) return("H4");
if (tf == PERIOD_D1) return("D1");
if (tf == PERIOD_W1) return("W1");
if (tf == PERIOD_MN1) return("MN1");

return("??");
}

void SetValues(int p1, int p2, int p3, int p4)
{
Period_1 = p1; Period_2 = p2; Period_3 = p3; Period_4 = p4;
}


void SetAutoDisplay()
{
if (AutoDisplay)
{
switch (Period())
{
case PERIOD_M1 : SetValues(PERIOD_M1, PERIOD_M5, PERIOD_M15,PERIOD_M30); break;
case PERIOD_M5 : SetValues(PERIOD_M5, PERIOD_M15,PERIOD_M30,PERIOD_H1); break;
case PERIOD_M15 : SetValues(PERIOD_M5, PERIOD_M15,PERIOD_M30,PERIOD_H1); break;
case PERIOD_M30 : SetValues(PERIOD_M5, PERIOD_M15,PERIOD_M30, PERIOD_H1); break;
case PERIOD_H1 : SetValues(PERIOD_M15, PERIOD_M30,PERIOD_H1, PERIOD_H4); break;
case PERIOD_H4 : SetValues(PERIOD_M30, PERIOD_H1, PERIOD_H4, PERIOD_D1); break;
case PERIOD_D1 : SetValues(PERIOD_H1, PERIOD_H4, PERIOD_D1, PERIOD_W1); break;
case PERIOD_W1 : SetValues(PERIOD_H4, PERIOD_D1, PERIOD_W1,PERIOD_MN1); break;
case PERIOD_MN1 : SetValues(PERIOD_H4, PERIOD_D1, PERIOD_W1,PERIOD_MN1); break;
}
}

}

bool NewBar()
{
static datetime dt = 0;

if (Time[0] != dt)
{
dt = Time[0];
return(true);
}
return(false);
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #1515 (permalink)  
Old 01-03-2009, 07:49 PM
Junior Member
 
Join Date: Jun 2008
Posts: 1
mofat is on a distinguished road
Any help?

Also wish to know if Metatrader orders can be run from the command line. Or in general if it is possible to interface external applications with Metatrader using some sort of API.

Thanks

Jeff
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #1516 (permalink)  
Old 01-05-2009, 03:08 AM
Senior Member
 
Join Date: Oct 2008
Location: Vancouver, BC
Posts: 158
Roger09 is on a distinguished road
Quote:
Originally Posted by m_43_62 View Post
hi
thanks very much all friends
You can not use indicator as a advisor, you have to use advisor with indicator, like this:
P.S. Don't forget put the indicator to indicator directory.
Attached Files
File Type: mq4 ForexFreedomBars.mq4 (2.8 KB, 27 views)
File Type: mq4 Freedom Bars.mq4 (7.5 KB, 28 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #1517 (permalink)  
Old 01-07-2009, 04:09 AM
Junior Member
 
Join Date: Sep 2008
Posts: 2
twnuck is on a distinguished road
Code to show DAYS/HOURS since the last MA cross

I need a code that shows me the last time two MA's crossed (i.e. how long ago). It can show it in days or hours.

Any help would be appreciated!

Todd
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #1518 (permalink)  
Old 01-07-2009, 04:18 AM
Junior Member
 
Join Date: Apr 2007
Posts: 6
phasna is on a distinguished road
Smile Conversion to Market Execution

I have an EA built for the "Instant Execution" version of Metatrader4 and I need someone to change the code so it will work on a "Market Execution" version of Metatrader4. Please email me a quote or or any questions to phasna@gmail.com

Thanks
Paul
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #1519 (permalink)  
Old 01-07-2009, 01:44 PM
increase's Avatar
Senior Member
 
Join Date: May 2006
Posts: 837
increase is on a distinguished road
Does anyone know the icustom statement to use in an EA for this indicator?

It only has one buffer SetIndexBuffer( 0, TrStopLevel ); which is used for the trailing dots, the arrows are drawn by ObjectSet how do you pick that up in the icustom statement?

MT4-LevelStop-Reverse-v2-1.mq4
Attached Files
File Type: mq4 MT4-LevelStop-Reverse-v2-1.mq4 (16.4 KB, 40 views)
__________________
New to Forex? Get all you need for Free at my site Click Here
You can also get my Hot Forex System (scroll to the bottom of the page): Click Here

Last edited by increase; 01-07-2009 at 01:53 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #1520 (permalink)  
Old 01-08-2009, 02:18 AM
increase's Avatar
Senior Member
 
Join Date: May 2006
Posts: 837
increase is on a distinguished road
Quote:
Originally Posted by increase View Post
Does anyone know the icustom statement to use in an EA for this indicator?

It only has one buffer SetIndexBuffer( 0, TrStopLevel ); which is used for the trailing dots, the arrows are drawn by ObjectSet how do you pick that up in the icustom statement?

MT4-LevelStop-Reverse-v2-1.mq4
Is anyone out there for help?
__________________
New to Forex? Get all you need for Free at my site Click Here
You can also get my Hot Forex System (scroll to the bottom of the page): Click Here
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
Reply

Bookmarks

Tags
#include, candle time, CHinGsMAroonCLK, code, coders guru, conditionally, dll, eli hayun, Eur_harvester.ex4, expert adviser, expert advisor, forex, higher high, how to code, indicator, I_XO_A_H, kehedge, mechanical trading, metatrader command line, mt4, MT4-LevelStop-Reverse, OrderReliable.mqh, programming, rectangle tool, trading, volty channel stop

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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to code this? iscuba11 Metatrader 4 mql 4 - Development course 1 08-03-2007 05:22 PM


All times are GMT. The time now is 01:33 PM.



Search Engine Friendly URLs by vBSEO 3.2.0 ©2008, Crawlability, Inc.