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
  #861 (permalink)  
Old 04-30-2008, 03:31 AM
wolfe's Avatar
wolfe wolfe is offline
Senior Member
 
Join Date: Jan 2006
Posts: 673
wolfe is on a distinguished road
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #862 (permalink)  
Old 04-30-2008, 02:45 PM
FerruFx FerruFx is online now
Senior Member
 
Join Date: Feb 2007
Posts: 543
FerruFx is on a distinguished road
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.
You must attach both EA and indicator unless the indy is coded inside the EA.

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
  #863 (permalink)  
Old 05-03-2008, 11:02 PM
ak97052d's Avatar
ak97052d ak97052d is offline
Junior Member
 
Join Date: Apr 2006
Location: Ukraine
Posts: 25
ak97052d is on a distinguished road
Help

hello
how to code this:
I need to extract some info from last closed trade,
and after use some info from this last trade
ex:
if last trade profit >0 'lasttradeprofit = 1'

and if last trade <=0 'lasttradeprofit = 0'

lasttradeprofit = 1 // if last trade >0
lasttradeprofit = 0 // if last trade <=0

thanks
__________________
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #864 (permalink)  
Old 05-04-2008, 05:34 AM
flourishing flourishing is offline
Member
 
Join Date: Mar 2007
Posts: 42
flourishing is on a distinguished road
why comment(2 / 1) display 2 but comment( 1 / 2) display 0?

how to make comment(1 / 2) display 0.5 ?
thank you.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #865 (permalink)  
Old 05-04-2008, 06:41 AM
nittany1's Avatar
nittany1 nittany1 is offline
Senior Member
 
Join Date: Dec 2006
Location: Sarasota, FL
Posts: 184
nittany1 is on a distinguished road
I threw together an adjust trailing stop function for EAs, can someone check it out?

Code:
//+-----------------------------------------------------+
//|           adjust trailing stop                      |
//+-----------------------------------------------------+
void AdjustTrailingStop()
{
  int orders = OrdersTotal();
  for(int j=orders-1;j>=0;j--)
  {
    OrderSelect(j, SELECT_BY_POS);
    int type = OrderType();
    //-- Adjust trailing stop for BUYs
    if (type == OP_BUY && OrderSymbol()==Symbol() && (OrderMagicNumber() == MagicNumber))
    {
      if (Ask-TrailingStop*Point > OrderOpenPrice() && Ask-TrailingStop*Point > OrderStopLoss())
        {
          OrderModify(OrderTicket(),OrderOpenPrice(),Ask-TrailingStop*Point,OrderTakeProfit(),0);
        }  
    }
    //-- Adjust trailing stop for SELLs
    if (type == OP_SELL && OrderSymbol()==Symbol() && (OrderMagicNumber() == MagicNumber))
    {  
      if (Bid+TrailingStop*Point < OrderOpenPrice() && Bid+TrailingStop*Point < OrderStopLoss())
        {
          OrderModify(OrderTicket(),OrderOpenPrice(),Bid+TrailingStop*Point,OrderTakeProfit(),0);
        } 
    }
  }
}
__________________
You can find me on irc.ircforex.com most of the time... on #forex
Myspace Facebook My Indicators: Trade Assistant Trend Friend ToR CCI Helper
Holder of US Patent 6,774,788
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #866 (permalink)  
Old 05-04-2008, 07:53 AM
birami birami is offline
Member
 
Join Date: Nov 2006
Posts: 31
birami is on a distinguished road
CHinGsMAroonCLK ea

hello
can anyone add sl for this expert .
Id like all orders have a fix sl
Attached Files
File Type: mq4 CHinGsMAroonCLK_2[1][1].2.mq4 (8.3 KB, 9 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #867 (permalink)  
Old 05-04-2008, 09:03 AM
ak97052d's Avatar
ak97052d ak97052d is offline
Junior Member
 
Join Date: Apr 2006
Location: Ukraine
Posts: 25
ak97052d is on a distinguished road
Quote:
Originally Posted by birami View Post
hello
can anyone add sl for this expert .
Id like all orders have a fix sl
hello
try this !
Attached Files
File Type: mq4 chingsmaroonclk_2-1-1-.2+sl.mq4 (8.4 KB, 18 views)
__________________
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #868 (permalink)  
Old 05-04-2008, 09:40 AM
Michel Michel is offline
Senior Member
 
Join Date: Feb 2006
Posts: 502
Michel is on a distinguished road
Quote:
Originally Posted by flourishing View Post
how to make comment(1 / 2) display 0.5 ?
thank you.
Please, try this:
PHP Code:
Comment(DoubleToStr(1/21)); 
The second argument of the function DoubleToStr() is the number of digits after the decimal point.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #869 (permalink)  
Old 05-04-2008, 09:59 AM
Michel Michel is offline
Senior Member
 
Join Date: Feb 2006
Posts: 502
Michel is on a distinguished road
Quote:
Originally Posted by ak97052d View Post
hello
how to code this:
I need to extract some info from last closed trade,
and after use some info from this last trade
ex:
if last trade profit >0 'lasttradeprofit = 1'

and if last trade <=0 'lasttradeprofit = 0'

lasttradeprofit = 1 // if last trade >0
lasttradeprofit = 0 // if last trade <=0

thanks
It's easy to scan the history and check OrderCloseTime() :
PHP Code:
datetime LastCloseTime;
bool LastTradeIsProfit;
for(
int i 0OrderHistoryTotal(), ++)
{
   
OrderSelect(iSELECT_BY_POSMODE_HISTORY);
   if(
OrderMagicNumber() != Magic) continue;
   if(
OrderCloseTime() > LastCloseTime
   {
      
LastCloseTime OrderCloseTime();
      
LastTradeIsProfit  = (OrderProfit() > 0);
   } 

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #870 (permalink)  
Old 05-04-2008, 01:16 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 !
thank you for edite expert
can you change this ea using my idea
from my idea after opening two orders we explain this info
1- all orders have fix stop loss same 10pip
2-if the first order going to profit opening 2* same this order but tp=fist order tp-fix sl
3- traling sl to second order opening place

exampel:
eur/usd
on the first price is : 1.5200
1-opening two orders ( buy@ 1.5200 0.1 lot size sl=10 tp 50 & sell@1.5200 0.1 lot size sl=10 tp=50)
price go to 15210
2-at this time (my sell order will be close & will opening second buy order 0.2 lot size by sl=10 tp=40 and fist order sl traling to 1.5210 )
price go to 1.5220
3-at this time (opening buy order 0.4 lot size by sl=10 tp=30 and two befor orders sl traling to 1.5220)
4-.....
5....
if the price going to 1.5250 all orders will be close by 560$
but at this time our orders sl we only lossing 60$
this method have very best risk

Last edited by birami : 05-04-2008 at 01:25 PM.
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 02:34 PM.