Forex



Go Back   Forex Trading > Programming > Metatrader Programming
Forex Forum Register More recent Blogs Calendar Advertising Others Help






Register
Welcome to Forex-TSD!, one of the largest Forex forums worldwide, where you will be able to find the most complete and reliable Forex information imaginable.

From the list below, select the forum that you want to visit and register to post, as many times you want. It’s absolutely free. Click here for registering on Forex-TSD.

EXCLUSIVE FORUM
The Exclusive Forum is the only paid section. Once you subscribe, you will get free access to real cutting-edge Trading Systems (automated and not), Indicators, Signals, Articles, etc., that will help and guide you, in ways that you could only imagine, with your Forex trading.
  • Elite Section
    Get access to private discussions, specialized support, indicators and trading systems reported every week.
  • Advanced Elite Section
    For professional traders, trading system developers and any other member who may need to use and/or convert, the most cutting-edge exclusive indicators and trading systems for MT4 and MT5.
See more

Reply
 
Thread Tools Display Modes
  #201 (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, 205 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #202 (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!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #203 (permalink)  
Old 02-11-2007, 09:03 PM
Member
 
Join Date: Sep 2006
Posts: 32
yossi1177 is on a distinguished road
results my meantime in this method

8.2.07 -3 pips
+50 pips
9.2.07 + 50 pips


having big potential in this method profit they maximums and defeat they minimum because the trailing profit
all of them losers because psychology of commerce and it will method exactly the opposite from psychology this

meantime i am doing this is in the manual way

i will continue to update further

you knowledge that i am right

yossi1177
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #204 (permalink)  
Old 02-13-2007, 12:55 PM
Member
 
Join Date: Sep 2006
Posts: 32
yossi1177 is on a distinguished road
Quote:
Originally Posted by yossi1177
results my meantime in this method

8.2.07 -3 pips
+50 pips
9.2.07 + 50 pips


having big potential in this method profit they maximums and defeat they minimum because the trailing profit
all of them losers because psychology of commerce and it will method exactly the opposite from psychology this

meantime i am doing this is in the manual way

i will continue to update further

you knowledge that i am right

yossi1177

look this!!!!
Attached Images
File Type: gif 8.2.07-14.2.07.gif (4.6 KB, 153 views)
Attached Files
File Type: htm 8.2.07-14.2.07.htm (11.4 KB, 21 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #205 (permalink)  
Old 02-13-2007, 12:57 PM
Member
 
Join Date: Sep 2006
Posts: 32
yossi1177 is on a distinguished road
trailing profit

this code not work
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #206 (permalink)  
Old 02-14-2007, 10:56 AM
Senior Member
 
Join Date: Mar 2006
Location: La Verne,CA
Posts: 560
MrPip is on a distinguished road
trailing ea

I posted this on the yahoo MTE&I group.
I combined 7 different trailing stop ideas into a single ea.

I have not tested this for manual trades but I have used many of the functions in eas and they do work.

It will only trail positions entered for the currency pair where attached.

It also sounds like what you want is the type 2, delayed trailing stop.

Also try the type 3 with 3 levels,

First level moves stop by the setting for that level, second level for that level and thirrd level trails from there.

For example

First move is 20 pips. To move to breakeven set the first stop to 20.

Second move 30, lock in 15 by setting second stop to 15.

Third move 40 trail by 10 by setting trailling to 10.

Robert
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #207 (permalink)  
Old 03-02-2007, 05:36 PM
Member
 
Join Date: Mar 2007
Posts: 40
jerrydeng is on a distinguished road
Post Help! i need simple code

Hello!everybody

I found almost all indicators very good, BUT indicator-- "arrow" in this forum is always above or below the bar. Many times, when i see the arrow, the best entry time has passed. It confuses me, what and when did the arrow appear?? So, i want to see the arrow display at the price positon when the arrow come out, better with the comment "XX:XX open price XXXX" on the chart left-up corner so that i may know what happened just now and deside the next step. i'm not a programmer, so i dont know how to write the code. Who here can help me finish it? thanks very much first.

Sorry for poor english..
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #208 (permalink)  
Old 03-06-2007, 08:12 PM
Member
 
Join Date: Feb 2007
Posts: 30
justize is on a distinguished road
Open-Range-Breakout (Larry Williams)

Hi,

I cant go on with programming until i found that %$§!!€-error.

The EA analyse the last 3 days. After that, it has to send two stop-orders. Both got initial stops. Later There is a trailing-stop running, when break-even is reached.

Now my problem is, that it doesn t send the long order?! No idea why not...

Can someone help me?

Quote:
//+------------------------------------------------------------------+
//| Open-Range-Breakout.mq4 |
//| JustiZe |
//| |
//+------------------------------------------------------------------+
#property copyright "JustiZe"
#property link ""


extern string Set1 = "Trade-Zeitraum";
extern int MaxOrderTime_h= 24; // Zeit in Stunden-Bars
extern string Set2 = "Stopp-Parameter";
extern double Trailing_stop = 40;

datetime TradeTime;


//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
// Variablen für die letzten Hochs
double hoch1, hoch2, hoch3;
// Variablen für die letzten drei Tiefs
double tief1, tief2, tief3;
// Variablen für die Min/Max
double hoch, tief;
// Variable für Volatilität
double vola;
// Variablen für Kaufen/Verkaufen-Tag
int kauftag = 0;
int verkauftag = 0;
// Variablen für Stopp-Order-Preisbildung
double kauf_stopp_preis = 0;
double verkauf_stopp_preis = 0;
// Maß der durchschnittlichen Spanne
double spanne = 0;
// Variable für wahre Spanne
double wahre_spanne = 0;
// Variable für anfänglichen Stopp
double anfangs_stopp = 0;
// Variable zur Ermittlung der dreifachen Spanne
int go_bep_long = 0; //BEP in Long?
int go_bep_short = 0;//BEP in Short?
int bep_stopp = 0;
// Variable für nahen Stopp
double naher_stopp;

// Ordervariablen, Systemvariablen...
int ticket = 0;
int total = 0;
double lots = 0.1;
double take_profit = 100;
int magic_number1 = 1234;
int magic_number2 = 1235;
int cnt = 0;

//================================================== ==================
//Berechne das höchste Hoch und das tiefste Tief der letzten drei Tage
//und lege den Unterschied zwischen den beiden Punkten als Maß der
//Volatilität fest.
//================================================== ==================

// Variablen füllen
hoch1 = High[1];
hoch2 = High[2];
hoch3 = High[3];
tief1 = Low[1];
tief2 = Low[2];
tief3 = Low[3];
// Maximum / Minimum bestimmen
if(hoch1 >= hoch2 && hoch1 >= hoch3) hoch = hoch1;
if(hoch2 >= hoch1 && hoch2 >= hoch3) hoch = hoch2;
if(hoch3 >= hoch1 && hoch3 >= hoch2) hoch = hoch3;
if(tief1 <= tief2 && tief1 <= tief3) tief = tief1;
if(tief2 <= tief1 && tief2 <= tief3) tief = tief2;
if(tief3 <= tief1 && tief3 <= tief2) tief = tief3;
// Unterschied bestimmen
vola = hoch - tief;

//================================================== ===================
//Stelle fest, ob morgen ein Leichter kaufen- oder ein leichter Verkau-
//fen-Tag ist. Ist der heutige Schlusskurs gleich oder höher als der
//gestrige Schlusskurs, dann ist morgen ein leichter Verkaufen-Tag. Ist
//der heutige Schlusskurs tiefer als der gestrige, dann ist morgen ein
//leichter Kaufen-Tag
//---------------------------------------------------------------------
//Anmerkung:#
//Zeitreihe um eins verschoben!!!
//================================================== ===================
if(Close[1] >= Close[2]) verkauftag = 1;
if(Close[1] < Close[2]) kauftag = 1;

//================================================== ===================
//Ist heute ein leichter Kaufen-Tag, dann wird die Stopp-Order zum Kauf
//folgendermaßen berechnet: Teile das Maß der Volatilität durch zwei
//und addiere das Ergebnis zum Eröffnungskurs. Die Stopp-Order zum Ver-
//kauf an einem leichten Kaufen-Tag wird ermittelt, indem das Maß der
//Volatilität vom Eröffnungskurs abgezogen wird.
//================================================== ===================
if(verkauftag == 0 && kauftag == 1) // Kaufen-Tag?
{
kauf_stopp_preis = vola/2 + Open[0];
verkauf_stopp_preis = Open[0] - vola;
}

//================================================== ===================
//Ist heute ein leichter Verkaufen-Tag, dann wird die Stopp-Order zum
//Verkauf folgendermaßen berechnet: Teile das Maß der Volatilität durch
//zwei und ziehe das Ergebnis von Eröffnungskurs ab. Die Stopp-Order
//zum Kauf an einem leichten Verkaufen-Tag wird ermittelt, indem das
//Maß der Volatitilität zum Eröffnungskurs addiert wird.
//================================================== ===================
if(verkauftag == 1 && kauftag == 0) // Verkaufen-Tag?
{
verkauf_stopp_preis = Open[0] - vola/2;
kauf_stopp_preis = Open[0] + vola;
}
//================================================== ===================
//Anmerkung:
//Runden der Werte!
//================================================== ===================
verkauf_stopp_preis = MathRound(verkauf_stopp_preis);
kauf_stopp_preis = MathRound(kauf_stopp_preis);

//================================================== ===================
//Berechne die durchschnittliche wahre Spanne der letzten zehn Tage.
//================================================== ===================
wahre_spanne = iATR(NULL,0,10,0);

//================================================== ===================
//Setze die dreifache durchschnittliche Spanne als anfänglichen Stopp.
//================================================== ===================
anfangs_stopp = 3 * wahre_spanne;
//================================================== ===================
//Anmerkung:
//Runden des Wertes!
//================================================== ===================
anfangs_stopp = MathRound(anfangs_stopp);

//================================================== ===================
//Anmerkung:
//Wenn flat, dann Orders in den Markt stellen.
//Begrenzte Zeit für Order hinzugefügt
//================================================== ===================
// Überprüfung auf Signale und Handel
total = OrdersTotal(); //Anzahl momentaner Order
// Trade-Time-Management
TradeTime = iTime(NULL,PERIOD_D1,0);

// if-Block für Einstieg
if(total<2) //total=0 : flat
{
ticket = OrderSend(Symbol(),OP_BUYSTOP, lots,kauf_stopp_preis*Point, 3,kauf_stopp_preis*Point - anfangs_stopp*Point, 0,NULL,magic_number1,TradeTime+MaxOrderTime_h*60*6 0,Blue);
ticket = OrderSend(Symbol(),OP_SELLSTOP,lots,verkauf_stopp_ preis*Point,3,verkauf_stopp_preis*Point + anfangs_stopp*Point,0,NULL,magic_number2,TradeTime +MaxOrderTime_h*60*60,Red);
return(0);
}

//================================================== ===================
//Ist die Position um die dreifache durchschnittliche wahre Spanne in
//der Gewinnzone, ziehe den schützenden Stopp auf den Kostendeckungs-
//punkt nach.
//================================================== ===================
//Vergleiche den Trailing-Stop, den schützenden Stop und den Umkehrstop
//un wende immer den Stopp an, der momentan dem Kurs am nächsten liegt.
///================================================== ==================

for(cnt=0;cnt<total;cnt++)
{
wahre_spanne = iATR(NULL,0,10,0);

if(OrderSymbol()==Symbol() && OrderType() == OP_BUY)
{
if((Close[0]-OrderOpenPrice())>=3*wahre_spanne && OrderStopLoss() != OrderOpenPrice()) // Stopp muss auf BreakEvenPoint nachgezogen werden
{
OrderModify(OrderTicket(),OrderOpenPrice(),OrderOp enPrice()+(Ask-Bid),OrderTakeProfit(),0,Green);
return(0);
}
}

if(OrderSymbol()==Symbol() && OrderType() == OP_SELL)
{
if((OrderOpenPrice()-Close[0])>=3*wahre_spanne && OrderStopLoss() == OrderOpenPrice()) // Stopp muss auf BreakEvenPoint nachgezogen werden
{
OrderModify(OrderTicket(),OrderOpenPrice(),OrderOp enPrice()-(Ask-Bid),OrderTakeProfit(),0,Green);
return(0);
}
}


naher_stopp = 30;
//EDIT

}


return(0);
}
//+------------------------------------------------------------------+
Attached Files
File Type: mq4 Open-Range-Breakout.mq4 (8.2 KB, 93 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #209 (permalink)  
Old 03-10-2007, 02:53 PM
Senior Member
 
Join Date: Nov 2006
Posts: 237
teldon is on a distinguished road
code sought

how to write this code .....

i need to measure the height of a wave and make decision according to that.
For example ... I am looking at a 5 min chart. I see lots of up and down waves. I want to choose a wave which has a height of 40 pips or greater. How to write such a code?

Anyone?
thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #210 (permalink)  
Old 03-13-2007, 02:41 PM
SaxMan's Avatar
Member
 
Join Date: Mar 2006
Posts: 27
SaxMan is on a distinguished road
Question Programmer Help -- Code Logic help

Hi Programmers,

I'm programming my close order logic and I don't seem to have it right:

PHP Code:
bool LongClose()
   {
   if(
MAFastC<MASlowC && MAFastP>=MASlowP)
      {
       
CrossedUp=false;
       
CrossedDn=true;
       
BarCount=0;
      }
   else
   if(
MAFastC>MASlowC && MAFastP<=MASlowP)
      {
       
CrossedUp=true;
       
CrossedDn=false;
       
BarCount=0;
       
Alert("Crossed Down");
      }
   if(
CrossedDn==true && NewBar()==true && Candle3mP=="Bear"BarCount++;
      {
      if(
BarCount>=&& Candle3mC=="Bear")
         {
         
Alert("Close Long Position");
         return(
true);
         }
      else  return(
false);
      } 
CrossedUP/DN & BarCount are static variables.

My closing logic is: When Cross occurs it stimulates the Bar count which counts the bars since the cross. When that count reaches 2 (i.e. 2 bars after the cross) and if current bar is Bear it triggers a true return to the function.

Problem: Cross notifys ok but count doesn't occur and consequently never reaches "true" state.

Thanks for your help,
SaxMan
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
Reply

Bookmarks

Tags
#include, candle time, CHinGsMAroonCLK, code, coders guru, conditionally, dll, eli hayun, Eur_harvester.ex4, expert adviser, expert advisor, forex, higher high, how to code, indicator, I_XO_A_H, kehedge, mechanical trading, metatrader command line, mt4, MT4-LevelStop-Reverse, OrderReliable.mqh, programming, rectangle tool, trading, volty channel stop

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

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 04:28 AM.



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