Forex Forum - EarnForex
Serving Traders Since 2005
 

Go Back   Forex Forum - EarnForex > MetaTrader > MetaTrader Expert Advisors

MetaTrader Expert Advisors Post and discuss the MetaTrader expert advisors here.

Reply
 
LinkBack Thread Tools Display Modes
  #11 (permalink)  
Old 27th March 2011, 17:27
Enivid's Avatar
Administrator
 
Join Date: Nov 2008
Posts: 1,542
Thanks: 18
Thanked 20 Times in 16 Posts
Default

Quote:
Originally Posted by univetsity View Post
thank you for your help to show the cycle correctly,but now when I backtracking EURUSD on 01.01.2011-03.26.2011 M5 the starting balance is 50,000 by add.mq4,it produce some results amazing me again.
I modified the decrease factor=3,and
if(losses>=1) lot=NormalizeDouble(lot-lot*losses/DecreaseFactor,1);

my question is why the third order's lot is 2?
I think it should count like this,
lot=50180*0.02/500=2,
since losses=1,lot=2-2*1/3=1.34=1.3 after normalizing
confused:
Are you sure you were running the test on a newer version of add.mq4 (with if(losses>=1))? Because I've got 1.3 lots on the 3rd order and results were the same for open prices and for every tick models.
__________________
Please, read the Forum Rules and the Signature Rules to avoid termination of your account.
Reply With Quote
  #12 (permalink)  
Old 4th April 2011, 06:19
Default Avatar
Junior Member
 
Join Date: Mar 2011
Location: china
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by Enivid View Post
Are you sure you were running the test on a newer version of add.mq4 (with if(losses>=1))? Because I've got 1.3 lots on the 3rd order and results were the same for open prices and for every tick models.
I am sure running the newer version.sickeningly,I even got different result by different Version of MT4,but all of them are wrong.
Enviod,I am appreciating for show your MT4's downloading address.
Reply With Quote
  #13 (permalink)  
Old 4th April 2011, 13:18
Enivid's Avatar
Administrator
 
Join Date: Nov 2008
Posts: 1,542
Thanks: 18
Thanked 20 Times in 16 Posts
Default

It's MetaTrader 4 from Alpari.
__________________
Please, read the Forum Rules and the Signature Rules to avoid termination of your account.
Reply With Quote
  #14 (permalink)  
Old 7th April 2011, 10:06
Default Avatar
Junior Member
 
Join Date: Mar 2011
Location: china
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by Enivid View Post
It's MetaTrader 4 from Alpari.
TKS!
another problem:I wanna add Trailing stop for my code as follow:
void TS(double ts=550)
{
bool res = false;
int total = OrdersTotal();

for(int i = 0;i<total;i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES) ==false) continue;
if(OrderSymbol()==Symbol() && OrderMagicNumber()==MAGICMA)
{
if( OrderType()==OP_BUY && Bid-OrderOpenPrice()>Point*ts && OrderStopLoss()<Bid-Point*ts)//OrderOpenPrice() - OffsetPips * Point > OrderStopLoss())
OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*ts,OrderTakeProfit(),0,Blue);
if( OrderType()==OP_SELL && OrderOpenPrice()-Ask>OrderStopLoss()&& OrderStopLoss()<Point*ts-Ask) //OrderOpenPrice() + OffsetPips * Point < OrderStopLoss()
OrderModify(OrderTicket(),OrderOpenPrice(),Point*t s-Ask,OrderTakeProfit(),0,Yellow);
}
}
}

and I insert TS() into my open order condtion code,but I found it couldn't make effect.The whole frame is the same as the add.MQ4 ,thd digits is 5.
Reply With Quote
  #15 (permalink)  
Old 9th April 2011, 07:22
Enivid's Avatar
Administrator
 
Join Date: Nov 2008
Posts: 1,542
Thanks: 18
Thanked 20 Times in 16 Posts
Default

What do you mean by "couldn't make effect"? Did you see any errors in the Journal or Experts tab of MT4?

BTW, it's always better to use brackets around separate conditions inside one "if". E.g.:
if ((OrderType()==OP_BUY) && (Bid-OrderOpenPrice()>Point*ts) && (OrderStopLoss()<Bid-Point*ts))
__________________
Please, read the Forum Rules and the Signature Rules to avoid termination of your account.
Reply With Quote
  #16 (permalink)  
Old 9th April 2011, 09:48
Default Avatar
Junior Member
 
Join Date: Mar 2011
Location: china
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by Enivid View Post
What do you mean by "couldn't make effect"? Did you see any errors in the Journal or Experts tab of MT4?

BTW, it's always better to use brackets around separate conditions inside one "if". E.g.:
if ((OrderType()==OP_BUY) && (Bid-OrderOpenPrice()>Point*ts) && (OrderStopLoss()<Bid-Point*ts))
no error,no warning.
It seems this is connected with the code
if(CalculateCurrentOrders(Symbol())<1)
when it is modified with“<2”,TS() could takes effect(sorry,not make effect ).
however,under "<2" ,I found the the first open condition as follow:
if (m1<m3-0.0003)
{
ticket1=OrderSend(Symbol(),OP_SELL,LotsOptimized() ,Bid,5,Ask+105*Point,0,"SELL#1",MAGICMA,0,Red); return;
}
often would open 2 orders,but the second open condition as follow:
if (m1<m4-0.0005)
{
ticket2=OrderSend(Symbol(),OP_SELL,LotsOptimized() ,Bid,5,Ask+105*Point,0,"SELL#2",MAGICMA,0,Green); return;
}
often could't open any order.
I wanna the code on the basis of the first conditon could open 1 order, then, if meet the second condition would add another order.
I have tried to nest them,but failed. could you help me again?
Reply With Quote
  #17 (permalink)  
Old 9th April 2011, 12:15
Enivid's Avatar
Administrator
 
Join Date: Nov 2008
Posts: 1,542
Thanks: 18
Thanked 20 Times in 16 Posts
Default

Use the first open condition with && (CalculateCurrentOrders(Symbol())<1) and the second open condition with && (CalculateCurrentOrders(Symbol())<2).
__________________
Please, read the Forum Rules and the Signature Rules to avoid termination of your account.
Reply With Quote
  #18 (permalink)  
Old 9th April 2011, 15:51
Default Avatar
Junior Member
 
Join Date: Mar 2011
Location: china
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default

is modify like this?
if(CalculateCurrentOrders(Symbol())<1&&(m1<m3-0.0003))
{ticket1=OrderSend(Symbol(),OP_SELL,LotsOptimized( ),Bid,5,Ask+105*Point,0,"SELL#1",MAGICMA,0,Red); return; }
if(CalculateCurrentOrders(Symbol())<2&&(m1<m4-0.0005))
{ticket2=OrderSend(Symbol(),OP_SELL,LotsOptimized( ),Bid,5,Ask+105*Point,0,"SELL#2",MAGICMA,0,Green); return; }
now the second condtion will open 2 orders,but the first will none.
My strategy is follow trend mode.Although there are 2 open condition,when meet the second contion,the first order should be profit. but I donn't know how to nest them to when the 1 order profit meet some points,the 2 will open.but if the 1's profit (even loss)couldn't meet this point,the 2 should not be opened.This makes an add opening strategy.

Last edited by univetsity; 9th April 2011 at 15:55.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Genetic Algorithm for EA, how? lumanauw MetaTrader Expert Advisors 5 30th June 2011 07:51
MDT's Daily Forex Analysis and FX-Market Algorithm mdtforex Advertisements 12 11th March 2009 07:45


All times are GMT. The time now is 02:44.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Inactive Reminders By Icora Web Design

SEO by vBSEO 3.3.2