Forex
Google
New signals service!

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
 
LinkBack (1) Thread Tools Display Modes
  #1351 (permalink)  
Old 10-15-2008, 12:06 PM
Junior Member
 
Join Date: Apr 2007
Posts: 14
haan is on a distinguished road
Please help to update the code of expert.

There is a simple expert. Code is clear and simple too, but i have a big problem - expert got only ONE try to Open/Close order.
Can somebody help to fix it?
Expert must try 5-10 times to open/close order.
Maybe n=number of try, and please without "while".
Thanks a lot.
Attached Files
File Type: mq4 test.mq4 (8.4 KB, 6 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1352 (permalink)  
Old 10-15-2008, 03:58 PM
Junior Member
 
Join Date: Jun 2008
Posts: 1
tommy0418 is on a distinguished road
My code for 'adjust lots after loss',need help..thanks

My code below for 'adjust lots after loss', but it did an error massage "incorrect start position 0 for ArraySort function" during Testing. Anyone can help me to fix it? need help..

PHP Code:
double AdjtLotsByWinRateint magicnumber,double NormLots)
{
  
int i,counter;
  
int ProfitAndTime[][2];
  
double Profits[];
//----
  
ArrayResize(ProfitAndTime,OrdersHistoryTotal());

  for (
i=0;i<OrdersHistoryTotal();i++)
  {
   if (
OrderSelect(i,SELECT_BY_POS,MODE_HISTORY))
   {
    if (
OrderType()<=OP_SELL && OrderMagicNumber()==magicnumber )  // 0  OP_BUY    1  OP_SELL  2 OP_BUYLIMIT  3 OP_SELLLIMIT 4 OP_BUYSTOP  5 OP_SELLSTOP      
    
{
    
ProfitAndTime[counter][0]=OrderCloseTime();
    
ProfitAndTime[counter][1]=OrderProfit();
    
counter++;
    }
   }
  }
  
ArrayResize(ProfitAndTime,counter);
  
ArrayResize(Profits,counter);
  
ArraySort(ProfitAndTime);
  
  for (
i=0;i<counter;i++)
  {
   
Profits[i]=ProfitAndTime[i][1];
  }
  
//Print(Profits);
  
int err=GetLastError();

  
int WinRate_N=0,WinRate_A=5;
  
double WinRate;
  for (
i=counter;i<counter-WinRate_A+1;i--)
  {
   if (
Profits[i]>0){ 
     
WinRate_N=WinRate_N+1;
     }
     else if (
Profits[i]<0)
     {
     
WinRate_N=WinRate_N-1;
     }
     else
     {
     
WinRate_N=WinRate_N+0;
     }
   }
   
   
   
WinRate=WinRate_N/WinRate_A;
   
double NewLots;
   if (
WinRate>=0.7)
   {
     
NewLots=NormLots*1.5;
   }
   else if (
WinRate>=0.5 && WinRate<0.7)
   {
     
NewLots=NormLots*1;
   }
   else if (
WinRate>=0.3 && WinRate<0.5)
   {
     
NewLots=NormLots*0.5;
   }
   else       
//if (WinRate<0.3)
   
{
     
NewLots=NormLots*0.1;
   }
   
   return(
NewLots);


Last edited by tommy0418; 10-16-2008 at 12:45 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1353 (permalink)  
Old 10-16-2008, 10:07 AM
Member
 
Join Date: Aug 2008
Posts: 36
fercan is on a distinguished road
how do you use Fractal?

lets say i only want the fractal up? i am confuse.. is fractal up mode upper?

and also about the shift?

below is the code i place to check the newest fractal up
iFractals (Symbol (), PERIOD_H1, MODE_UPPER, 1);

is this correct? or should i put 0 in the shift?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1354 (permalink)  
Old 10-16-2008, 10:30 AM
Senior Member
 
Join Date: Nov 2006
Posts: 220
luxinterior is on a distinguished road
0 shift is the current bar that is still forming, 1 is the previous bar that has already closed. It depends which one you want.

Good luck

Lux
__________________
Build An Expert Advisor. FREE E-course As Seen On TV
ForexArea.com
Users of Gap Trader from 'Forex-Assistant' MUST Read This
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1355 (permalink)  
Old 10-16-2008, 10:40 AM
Senior Member
 
Join Date: Sep 2007
Posts: 311
jturns23 is on a distinguished road
With fractals use a 1 shift would be your best bet.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1356 (permalink)  
Old 10-16-2008, 02:32 PM
Member
 
Join Date: Aug 2008
Posts: 36
fercan is on a distinguished road
Quote:
Originally Posted by luxinterior View Post
0 shift is the current bar that is still forming, 1 is the previous bar that has already closed. It depends which one you want.

Good luck

Lux
?
lux?? i have attach the image.. what shift and mode should i use for blue and yellow circle?

blue = iFractals (Symbol (), PERIOD_H1, MODE_UPPER, 1);
yellow=iFractals (Symbol (), PERIOD_H1, MODE_LOWER, 1);

is this correct?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1357 (permalink)  
Old 10-16-2008, 10:03 PM
Senior Member
 
Join Date: Nov 2006
Posts: 220
luxinterior is on a distinguished road
Not sure if you're understanding the shift variable correctly.

The shift will constantly be changing so you must decide when you want to check for a signal. As I said 0 will ALWAYS refer to the currently forming bar and 1 will ALWAYS refer to the bar preceding the currently forming bar.

Looking at your pic it looks like shift 4 and 6 but obviously as soon as the next bar would open those shifts would change, hence the name

Good luck

Lux
__________________
Build An Expert Advisor. FREE E-course As Seen On TV
ForexArea.com
Users of Gap Trader from 'Forex-Assistant' MUST Read This
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1358 (permalink)  
Old 10-17-2008, 06:09 PM
Member
 
Join Date: Aug 2008
Posts: 36
fercan is on a distinguished road
Quote:
Originally Posted by luxinterior View Post
Not sure if you're understanding the shift variable correctly.

The shift will constantly be changing so you must decide when you want to check for a signal. As I said 0 will ALWAYS refer to the currently forming bar and 1 will ALWAYS refer to the bar preceding the currently forming bar.

Looking at your pic it looks like shift 4 and 6 but obviously as soon as the next bar would open those shifts would change, hence the name

Good luck

Lux
ok thanks.. but how do i code it that it would only read the latest fractal up and down.. i thought the shift 1 would put the value of the latest fractal regardless of the bars.. i guess i am mistaken..

so what code should i place that it would read the latest fractal up and down?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1359 (permalink)  
Old 10-18-2008, 06:41 AM
Senior Member
 
Join Date: Nov 2006
Posts: 220
luxinterior is on a distinguished road
Just loop back from 0 until the value is not 0 or NULL (can't remember off the top of my head).

Lux
__________________
Build An Expert Advisor. FREE E-course As Seen On TV
ForexArea.com
Users of Gap Trader from 'Forex-Assistant' MUST Read This
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1360 (permalink)  
Old 10-18-2008, 09:34 AM
Junior Member
 
Join Date: May 2008
Posts: 17
mancai is on a distinguished road
appreciate who can help me on this, i just want to attach this indicator to main chart, when I change indicator_seperate_window to indicator_chart_window,
but this indicator become weird when attached to main chart window.

need your guys expertise to help me on this.

Last edited by Linuxser; 10-18-2008 at 04:45 PM. Reason: Copyrighted indicator
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

Tags
candle time, CHinGsMAroonCLK, coders guru, Eur_harvester.ex4, expert adviser, expert advisor, forex, how to code, indicator, I_XO_A_H, kehedge, mechanical trading, metatrader command line, programming, trading

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

LinkBacks (?)
LinkBack to this Thread: http://www.forex-tsd.com/metatrader-programming/554-how-code.html
Posted By For Type Date
Need an experienced programmer? - Page 2 Post #0 Refback 09-24-2008 07:24 AM

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 06:37 PM.



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