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
  #191 (permalink)  
Old 02-04-2007, 08:18 PM
Junior Member
 
Join Date: Nov 2006
Posts: 26
Luke_P is on a distinguished road
static variable accumulation on open

I want to accumulated a static variable but only once per bar. If someone could suggest a way to do this I'd be grateful. My problem is that it gets re-added on every tick when I only want to run the calculation once per bar on the very first tick.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #192 (permalink)  
Old 02-05-2007, 12:20 AM
Member
 
Join Date: Jun 2006
Posts: 56
timbobo is on a distinguished road
Thumbs up

static datetime myTime = 0;

if(myTime != Time[0])
{
//do what you want to be done once after openning new bar

myTime = Time[0];
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #193 (permalink)  
Old 02-05-2007, 02:50 AM
Junior Member
 
Join Date: Nov 2006
Posts: 26
Luke_P is on a distinguished road
Quote:
Originally Posted by timbobo
static datetime myTime = 0;

if(myTime != Time[0])
{
//do what you want to be done once after openning new bar

myTime = Time[0];
}
Thank you timbobo!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #194 (permalink)  
Old 02-07-2007, 06:03 AM
Senior Member
 
Join Date: Jan 2006
Posts: 80
jyrik is on a distinguished road
Please help me I am using code posting above and its not working 100%. If I get 1 signal it will not trade but if it wil get second signal it will trade . Its very strange why in second signal trade but in first not??
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #195 (permalink)  
Old 02-07-2007, 08:24 AM
Administrator
 
Join Date: Sep 2005
Posts: 16,818
Blog Entries: 145
newdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud of
It is necessary to see your EA to correct.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #196 (permalink)  
Old 02-09-2007, 10:01 AM
Member
 
Join Date: Sep 2006
Posts: 32
yossi1177 is on a distinguished road
i need help to code - trailing profit

someone can help me to do code or EA for trailing profit?

i think that it is very good idea
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #197 (permalink)  
Old 02-09-2007, 10:33 AM
Member
 
Join Date: Sep 2006
Posts: 32
yossi1177 is on a distinguished road
Quote:
Originally Posted by yossi1177
someone can help me to do code or EA for trailing profit?

i think that it is very good idea

exactly the opposite from trailing stop
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #198 (permalink)  
Old 02-09-2007, 04:28 PM
ryanklefas's Avatar
Senior Member
 
Join Date: Apr 2006
Location: USA
Posts: 439
ryanklefas is on a distinguished road
Quote:
Originally Posted by yossi1177
someone can help me to do code or EA for trailing profit?

i think that it is very good idea
Well, to call it a trailing profit is somewhat of a mis-nomer because it wouldn't trail price action. But I'll see what I can do.
__________________
"Don't work harder, work smarter." -- my Java professor

Coder for Hire:
http://www.firecell-fx.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #199 (permalink)  
Old 02-09-2007, 06:46 PM
Wackena's Avatar
Senior Member
 
Join Date: May 2006
Posts: 216
Wackena is on a distinguished road
Quote:
Originally Posted by yossi1177
someone can help me to do code or EA for trailing profit?

i think that it is very good idea
This is a simple 3 candles profit trailing (PT) code or more like a trailing stop. It is activated by GapPT=number of pips in profit. Attached is chart example of 3 candles method.

Wackena
Code:
extern int GapPT=10;

int c, n, p;
double LongPT, ShortPT;
c=0; p=0;
for(n=0;n<=6;n++)
{
   if(High[c+1]<High[c+2] && Low[c+1]>Low[c+2]) {n--;} 
   c++;
   p++;
   if(n==3) break;
}

ShortPT=NormalizeDouble(High[iHighest(Symbol(),0,MODE_HIGH,p,1)],Digits);
      
LongPT=NormalizeDouble(Low[iLowest(Symbol(),0,MODE_LOW,p,1)],Digits);

int total = OrdersTotal();
for(int cnt=0;cnt<total;cnt++) {
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);

if(OrderType()==OP_BUY && OrderClosePrice()-OrderOpenPrice() >= GapPT*Point)
  {
    OrderModify(OrderTicket(),OrderOpenPrice(),LongPT,OrderTakeProfit(),0,GreenYellow);
  }

if(OrderType()==OP_SELL && OrderOpenPrice()-OrderClosePrice() >= GapPT*Point)
  {
    OrderModify(OrderTicket(),OrderOpenPrice(),ShortPT,OrderTakeProfit(),0,Red);
  }
}
Attached Images
File Type: gif 3 candles profit trailing.gif (12.8 KB, 157 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #200 (permalink)  
Old 02-11-2007, 05:13 PM
Member
 
Join Date: Sep 2006
Posts: 32
yossi1177 is on a distinguished road
Quote:
Originally Posted by Wackena
This is a simple 3 candles profit trailing (PT) code or more like a trailing stop. It is activated by GapPT=number of pips in profit. Attached is chart example of 3 candles method.

Wackena
Code:
extern int GapPT=10;

int c, n, p;
double LongPT, ShortPT;
c=0; p=0;
for(n=0;n<=6;n++)
{
   if(High[c+1]<High[c+2] && Low[c+1]>Low[c+2]) {n--;} 
   c++;
   p++;
   if(n==3) break;
}

ShortPT=NormalizeDouble(High[iHighest(Symbol(),0,MODE_HIGH,p,1)],Digits);
      
LongPT=NormalizeDouble(Low[iLowest(Symbol(),0,MODE_LOW,p,1)],Digits);

int total = OrdersTotal();
for(int cnt=0;cnt<total;cnt++) {
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);

if(OrderType()==OP_BUY && OrderClosePrice()-OrderOpenPrice() >= GapPT*Point)
  {
    OrderModify(OrderTicket(),OrderOpenPrice(),LongPT,OrderTakeProfit(),0,GreenYellow);
  }

if(OrderType()==OP_SELL && OrderOpenPrice()-OrderClosePrice() >= GapPT*Point)
  {
    OrderModify(OrderTicket(),OrderOpenPrice(),ShortPT,OrderTakeProfit(),0,Red);
  }
}

thank you very much !!!!

1. how to i exerts it on transactions that i am incipit in the manual way? or automiticly

2.i need that it is convene to act her just when he enter to the defeat
exenple: if trailing profit 20 just the order thesis -20 trailing profit beginner to work

(forgiveness on my english i hope that you are understands me)

and again thank you very much!!!!!
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, expert advisor, forex, how to code, I_XO_A_H, mechanical trading, 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 12:23 PM.



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