Forex
Google

Go Back   Forex Trading > Programming > Metatrader Programming
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
  #871 (permalink)  
Old 05-04-2008, 02:19 PM
birami birami is offline
Member
 
Join Date: Nov 2006
Posts: 31
birami is on a distinguished road
Quote:
Originally Posted by ak97052d View Post
hello
try this !
excuse me this expert sl have to using this formul for having profit result on thefix sl have bad result
order sl = ((MaxTrades*MinGS)+SL) - (n*MinGS)
exampel for this info
extern int MinGS=5;
extern int TP=20;
extern int SL=10;
extern double lot=0.10;
extern int MaxTrades=7;
extern int RegularSpread=2;
extern double Multiplier=2;
extern double LotInc=0;
extern double MarginLevelAlert=1000;

we have
first order sl= ((7*5)+10)-(0*5)=40
second order sl= ((7*5)+10)-(1*5)=35
and other sl are
35
30
25
20
15
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #872 (permalink)  
Old 05-04-2008, 05:53 PM
Nordic12 Nordic12 is offline
Member
 
Join Date: Mar 2007
Posts: 32
Nordic12 is on a distinguished road
Help with an indicator

Hi

Ive tried to create an indicator and was wondering to see if someone can help me (i feel its 99.9% finished - well phase I anyway)




//+------------------------------------------------------------------+
//| CCI_Stoc_Xover.mq4 |
//| Copyright © 2007, MetaQuotes Software Corp. |
//| Forex Trading Software: Forex Trading Platform MetaTrader 4 |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 SeaGreen
#property indicator_color2 Red

extern int CCI_Period = 14;
extern int Stoc_K=5;
extern int Stoc_D=3;
extern int Stoc_Slowing=3;

double CrossUp[];
double CrossDown[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0, DRAW_ARROW, EMPTY,3);
SetIndexArrow(0, 233);
SetIndexBuffer(0, CrossUp);
SetIndexStyle(1, DRAW_ARROW, EMPTY,3);
SetIndexArrow(1, 234);
SetIndexBuffer(1, CrossDown);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start() {
int limit, i, counter;
int counted_bars=IndicatorCounted();
//---- check for possible errors
if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;

limit=Bars-counted_bars;

for(i = 0; i <= limit; i++) {

counter=i;
double cci_1 = iCCI(Symbol(), Period(), CCI_Period, PRICE_TYPICAL, 1);
double cci_2 = iCCI(Symbol(), Period(), CCI_Period, PRICE_TYPICAL, 2);
double stok_0 = iStochastic(Symbol(), Period(), Stoc_K, Stoc_D, Stoc_Slowing, MODE_SMA, 0, MODE_MAIN, 0);
double stod_0 = iStochastic(Symbol(), Period(), Stoc_K, Stoc_D, Stoc_Slowing, MODE_SMA, 0, MODE_SIGNAL, 0);
double stok_1 = iStochastic(Symbol(), Period(), Stoc_K, Stoc_D, Stoc_Slowing, MODE_SMA, 0, MODE_MAIN, 1);
double stod_1 = iStochastic(Symbol(), Period(), Stoc_K, Stoc_D, Stoc_Slowing, MODE_SMA, 0, MODE_SIGNAL, 1);

if ((cci_2 <= 0 && cci_1 > 0 && stok_1 < stod_1 && stok_0 > stod_0)) {
CrossUp[i] = Low[i];
}
else if ((cci_2 >= 0 && cci_1 < 0 && stok_1 > stod_1 && stok_0 < stod_0)) {
CrossDown[i] = High[i];
}
}
return(0);
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #873 (permalink)  
Old 05-05-2008, 04:21 PM
Big Be Big Be is offline
Member
 
Join Date: Oct 2006
Posts: 68
Big Be is on a distinguished road
Wolfe's Question

Quote:
Originally Posted by wolfe View Post
Does anyone know how to code so that when you call an indicator in an EA it automatically attaches the called indicator to the chart your EA is attached to? This way it would visually be in the exact same time as what is being read by your EA.

Thanks.
The previous reply was incomplete.
If the indicator is standard in MT4, it will show up in the normal place. If it is called by iCustom, it will also show up, if coded right.
The following EAs even have the indicators show on the chart window. Study them to learn how:

bouncingPipEA_mpowerV42.mq4
bouncingPipEA_BigBear_v23.mq4

Big Be
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #874 (permalink)  
Old 05-07-2008, 02:19 AM
mastoto mastoto is offline
Junior Member
 
Join Date: Mar 2008
Posts: 13
mastoto is on a distinguished road
Spread in Pending Order

Hi folks,

I made an EA that calculates daily hi-low between some period, and then place pending orders buystop/sellstop, that will expired in 12 hours.
I run it in GBP-JPY pair (8 pips spread in my broker)
Code:
int ticket, SL, TP; //SL= StopLoss , TP= TakeProfit
int Spacing = 10; // Spacing Pips 
double vAsk = HighestPrice+Spacing*Point;  //  raise/lower 10 pips for OP Buystop/Sellstop , HighestPrice= some highest price  

ticket=OrderSend(Symbol(),OP_BUYSTOP,Lots,vAsk,0,vAsk-SL*Point,vAsk+TP*Point,"Pending Order BUY STOP",20070125,CurTime() + 12 * 3600,Green);
The result, Pending Order Buy Stop was executed, even price did not touch it. I have traced the OP Buy Stop, placed at price 204.08, but it was executed when the price is at 204.00. It seems that Spread factor is involved.
My friend told me that manual Pending Order Buystop/Sellstop is executed without spread factor, but why it's different with placing order by EA ?

So is there any mistakes in my code ?

Thanks in advance.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #875 (permalink)  
Old 05-07-2008, 05:35 AM
Michel Michel is offline
Senior Member
 
Join Date: Feb 2006
Posts: 502
Michel is on a distinguished road
Quote:
Originally Posted by mastoto View Post
Hi folks,

I made an EA that calculates daily hi-low between some period, and then place pending orders buystop/sellstop, that will expired in 12 hours.
I run it in GBP-JPY pair (8 pips spread in my broker)
Code:
int ticket, SL, TP; //SL= StopLoss , TP= TakeProfit
int Spacing = 10; // Spacing Pips 
double vAsk = HighestPrice+Spacing*Point;  //  raise/lower 10 pips for OP Buystop/Sellstop , HighestPrice= some highest price  

ticket=OrderSend(Symbol(),OP_BUYSTOP,Lots,vAsk,0,vAsk-SL*Point,vAsk+TP*Point,"Pending Order BUY STOP",20070125,CurTime() + 12 * 3600,Green);
The result, Pending Order Buy Stop was executed, even price did not touch it. I have traced the OP Buy Stop, placed at price 204.08, but it was executed when the price is at 204.00. It seems that Spread factor is involved.
My friend told me that manual Pending Order Buystop/Sellstop is executed without spread factor, but why it's different with placing order by EA ?

So is there any mistakes in my code ?

Thanks in advance.
If your "HighestPrice" is a BID price as they are on all charts, you probably have to add the spread. Any BUY order is triggered by a ASK price.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #876 (permalink)  
Old 05-07-2008, 06:26 AM
shanyang shanyang is offline
Junior Member
 
Join Date: Apr 2008
Posts: 15
shanyang is on a distinguished road
how to get the information on the main chart

i have downloaded an indicator,which shows green/red arrow when the buy/sell signal come.
now i want to program my own EA based on this indicator.
but i have only the ex4 file of this indicator(no source code)
I want my EA read the indicator arrow on the mainchart and send the buy/sell order(green arrow==>buy, red arrow==>sell)
is there any approach to get indicator arrow information on the main chart?
thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #877 (permalink)  
Old 05-07-2008, 08:41 AM
FerruFx FerruFx is offline
Senior Member
 
Join Date: Feb 2007
Posts: 539
FerruFx is on a distinguished road
Quote:
Originally Posted by shanyang View Post
i have downloaded an indicator,which shows green/red arrow when the buy/sell signal come.
now i want to program my own EA based on this indicator.
but i have only the ex4 file of this indicator(no source code)
I want my EA read the indicator arrow on the mainchart and send the buy/sell order(green arrow==>buy, red arrow==>sell)
is there any approach to get indicator arrow information on the main chart?
thanks
The EA has to call the indicator signals up/down with the iCustom(); function. You don't need the source code to do this.

FerruFx
__________________
THE HEART of FOREX & THE PROBABILITY METER - Trade with 100% confidence and ... Stress Less!!!
Coding services: Experts Advisors, indicators, alerts, etc ... more info by PM
NEW: video presentation of the Probability Meter ... 24hrs action on the website
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #878 (permalink)  
Old 05-07-2008, 07:40 PM
Michel Michel is offline
Senior Member
 
Join Date: Feb 2006
Posts: 502
Michel is on a distinguished road
Quote:
Originally Posted by shanyang View Post
i have downloaded an indicator,which shows green/red arrow when the buy/sell signal come.
now i want to program my own EA based on this indicator.
but i have only the ex4 file of this indicator(no source code)
I want my EA read the indicator arrow on the mainchart and send the buy/sell order(green arrow==>buy, red arrow==>sell)
is there any approach to get indicator arrow information on the main chart?
thanks
An arrow can be drawn as a value of one of the indicator's buffers; in this case, the color in the indicator's properties should give you the buffer's number, which is enough to call it by "ICustom()" function; You also need to fill all the values of the "Input" tab as parametres of the ICustom() call.
If the arrow is not a value of a buffer, it is an object. Select it to see its properties. Most of the time, it's easy to understand how the names are generate and then it will be possible to use ObjectFind().
The EA should watch ObjectsTotal(), and only when it is incremented it may try to recognize the last object. If the name is unknow, the EA cannot use OjectFind() and has to scan all objects to identify the last one. The last object is not obviously the one with the highest index (ObjectsTotal() - 1), but it's better to start to scan from the higest index as you probably can break faster. Now you have to compare the OBJPROP_TIME1 get by ObjectGet() to Time[0] or Time[1] for exemple, and check the color or the arrow type, or a substring of the name, to identify a buy or a sell signal.
It seems complex but it is not. Try to write it and dont hesitate to ask more precisions if needed.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #879 (permalink)  
Old 05-08-2008, 01:28 AM
wolfe's Avatar
wolfe wolfe is offline
Senior Member
 
Join Date: Jan 2006
Posts: 673
wolfe is on a distinguished road
Quote:
Originally Posted by Big Be View Post
The previous reply was incomplete.
If the indicator is standard in MT4, it will show up in the normal place. If it is called by iCustom, it will also show up, if coded right.
The following EAs even have the indicators show on the chart window. Study them to learn how:

bouncingPipEA_mpowerV42.mq4
bouncingPipEA_BigBear_v23.mq4

Big Be
Thanks Big Be, I'll check them out.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #880 (permalink)  
Old 05-08-2008, 02:15 AM
FerruFx FerruFx is offline
Senior Member
 
Join Date: Feb 2007
Posts: 539
FerruFx is on a distinguished road
Quote:
Originally Posted by Michel View Post
An arrow can be drawn as a value of one of the indicator's buffers; in this case, the color in the indicator's properties should give you the buffer's number, which is enough to call it by "ICustom()" function; You also need to fill all the values of the "Input" tab as parametres of the ICustom() call.
If the arrow is not a value of a buffer, it is an object. Select it to see its properties. Most of the time, it's easy to understand how the names are generate and then it will be possible to use ObjectFind().
The EA should watch ObjectsTotal(), and only when it is incremented it may try to recognize the last object. If the name is unknow, the EA cannot use OjectFind() and has to scan all objects to identify the last one. The last object is not obviously the one with the highest index (ObjectsTotal() - 1), but it's better to start to scan from the higest index as you probably can break faster. Now you have to compare the OBJPROP_TIME1 get by ObjectGet() to Time[0] or Time[1] for exemple, and check the color or the arrow type, or a substring of the name, to identify a buy or a sell signal.
It seems complex but it is not. Try to write it and dont hesitate to ask more precisions if needed.
Great explanation Michel ... 100% more complete than mine !

Thanks for who is interested.

FerruFx
__________________
THE HEART of FOREX & THE PROBABILITY METER - Trade with 100% confidence and ... Stress Less!!!
Coding services: Experts Advisors, indicators, alerts, etc ... more info by PM
NEW: video presentation of the Probability Meter ... 24hrs action on the website
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
How to code this? iscuba11 Metatrader 4 mql 4 - Development course 1 08-03-2007 04:22 PM


All times are GMT. The time now is 11:43 AM.