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
05-22-2008, 10:11 AM
Member
Join Date: May 2006
Location: Germany
Posts: 38
Quote:
Originally Posted by
FerruFx
I sent you a PM 2 days ago.
FerruFx
oh yes, i havent noticed that until now.... sorry, i will answer @ weekend, could you look into the EA because of the "position switch" problem ?
05-22-2008, 10:23 AM
Member
Join Date: May 2006
Location: Germany
Posts: 38
Quote:
Originally Posted by
FerruFx
I sent you a PM 2 days ago.
FerruFx
you got mail ;-)
Last edited by clarc; 05-22-2008 at 05:37 PM .
05-22-2008, 06:06 PM
Junior Member
Join Date: Dec 2006
Posts: 3
How to append a prefix to an int declaration after it is created?
Is it possible to:
// from include file
…
#define CP1 “GBPJPY”
Int iMyInt = 10;
…
// end include file
Then….
Append CP1 as a prefix to the int declaration of iMyInt
So that…
GBPJPYiMyInt = = 10
Resulting in…
//library file
…
Void MyFunction(string sSymbol)
{
If (sSymbol = = CP1 )
iMyInt becomes GBPJPYiMyInt ;
}
…
//end library file
// script
…
Myfunction( CP1 );
…
//end script
Thank you very much!
05-22-2008, 10:44 PM
Senior Member
Join Date: Jan 2006
Posts: 818
Hello everyone,
This is a stupid coding question, and I know I've seen it somewhere before, but I need help.
I'm coding a custom indicator, and all I want it to do is read the current bid price at ONLY THE BEGINNING of a NEW bar. I can't just use Open[0] because every time a new tick comes in it will keep returning the open value for the current bar. I want the value to be returned only once, until a new bar is formed.
I know I'm missing something quite simple here, but am having a bit of trouble figuring it out. Could someone help me?
Thanks,
-wolfe
05-23-2008, 03:24 AM
Senior Member
Join Date: Jan 2006
Posts: 1,119
Quote:
Originally Posted by
wolfe
Hello everyone,
This is a stupid coding question, and I know I've seen it somewhere before, but I need help.
I'm coding a custom indicator, and all I want it to do is read the current bid price at ONLY THE BEGINNING of a NEW bar. I can't just use Open[0] because every time a new tick comes in it will keep returning the open value for the current bar. I want the value to be returned only once, until a new bar is formed.
I know I'm missing something quite simple here, but am having a bit of trouble figuring it out. Could someone help me?
Thanks,
-wolfe
Just store the current bar time (Time[0]) - when this value changes, you have a new bar, so get your price, store new value and repeat...
05-23-2008, 03:54 AM
Senior Member
Join Date: Jan 2006
Posts: 818
Quote:
Originally Posted by
omelette
Just store the current bar time (Time[0]) - when this value changes, you have a new bar, so get your price, store new value and repeat...
Thanks omelette,
I should have thought of that, kinda disappointed in myself!
Thanks for the help!
05-25-2008, 06:23 AM
Senior Member
Join Date: Jul 2007
Location: Malaysia
Posts: 258
Can someone else show me what im doing wrong to this code?
I would like to add more timeframe into it like timeframe Daily,but i do not know what wrong
Quote:
//+---------------------------------------------------------+
//| #MTF_Hi_Low_Middle.mq4
//| Base from spudfibo.Upgrade by Darkkiller
//: Thanks to Mladen for helping me to make some correction
//+------------------------------------------------------------------+
#property indicator_chart_window
extern string note1 = "H4 Higher,Middle,Lower colors";
extern color H4HigherColor = DeepSkyBlue;
extern color H4MiddleColor = Yellow;
extern color H4LowerColor = HotPink;
extern string note2 = "Draw H4 Higher,Lower and Middle?";
extern bool H4HiLow = true;
extern bool H4Mid = true;
extern string note3 = "D1 Higher,Middle,Lower colors";
extern color D1HigherColor = DeepSkyBlue;
extern color D1MiddleColor = Yellow;
extern color D1LowerColor = HotPink;
extern string note4 = "Draw D1 Higher,Lower and Middle?";
extern bool D1HiLow = true;
extern bool D1Mid = true;
double HiPrice, LoPrice, Range, D1HiPrice, D1LoPrice, D1Range;
datetime StartTime;
int init()
{
return(0);
}
int deinit()
{
ObjectDelete("H4Higher");
ObjectDelete("H4Lower");
ObjectDelete("H4Middle");
ObjectDelete("D1Higher");
ObjectDelete("D1Lower");
ObjectDelete("D1Middle");
return(0);
}
//+------------------------------------------------------------------+
//| Draw Fibo
//+------------------------------------------------------------------+
int DrawFibo()
{
///////////////////////////////////////////HILO/////
if(H4HiLow)
{
if(ObjectFind("H4Higher") == -1)
ObjectCreate("H4Higher", OBJ_FIBO, 0, StartTime, HiPrice+Range, StartTime, HiPrice);
else
{
ObjectSet("H4Higher",OBJPROP_TIME2, StartTime);
ObjectSet("H4Higher",OBJPROP_TIME1, StartTime);
ObjectSet("H4Higher",OBJPROP_PRICE1,HiPrice+Range) ;
ObjectSet("H4Higher",OBJPROP_PRICE2,HiPrice);
}
ObjectSet("H4Higher", OBJPROP_LEVELCOLOR, H4HigherColor);
ObjectSet("H4Higher", OBJPROP_FIBOLEVELS,1);
ObjectSet("H4Higher", OBJPROP_FIRSTLEVEL+0,0.0); ObjectSetFiboDescription("H4Higher", 0, "H4 HIGHER- %$");
ObjectSet("H4Higher", OBJPROP_RAY,true);
ObjectSet("H4Higher", OBJPROP_BACK,true);
ObjectSet("H4Higher", OBJPROP_COLOR,EMPTY);
if(ObjectFind("H4Lower") == -1)
ObjectCreate("H4Lower", OBJ_FIBO, 0, StartTime, LoPrice-Range, StartTime, LoPrice);
else
{
ObjectSet("H4Lower", OBJPROP_TIME2, StartTime);
ObjectSet("H4Lower", OBJPROP_TIME1, StartTime);
ObjectSet("H4Lower", OBJPROP_PRICE1,LoPrice-Range);
ObjectSet("H4Lower", OBJPROP_PRICE2,LoPrice);
}
ObjectSet("H4Lower", OBJPROP_LEVELCOLOR, H4LowerColor);
ObjectSet("H4Lower", OBJPROP_FIBOLEVELS, 1);
ObjectSet("H4Lower", OBJPROP_FIRSTLEVEL+0,0.0); ObjectSetFiboDescription("H4Lower", 0, "H4 LOWER - %$");
ObjectSet("H4Lower", OBJPROP_RAY, true);
ObjectSet("H4Lower", OBJPROP_BACK, true);
ObjectSet("H4Lower", OBJPROP_COLOR, EMPTY);
}
if(D1HiLow)
{
if(ObjectFind("D1Higher") == -1)
ObjectCreate("D1Higher", OBJ_FIBO, 0, D1StartTime, D1HiPrice+D1Range, D1StartTime, D1HiPrice);
else
{
ObjectSet("D1Higher", OBJPROP_TIME2, D1StartTime);
ObjectSet("D1Higher", OBJPROP_TIME1, D1StartTime);
ObjectSet("D1Higher", OBJPROP_PRICE1, D1HiPrice+D1Range);
ObjectSet("D1Higher", OBJPROP_PRICE2, D1HiPrice);
}
ObjectSet("D1Higher", OBJPROP_LEVELCOLOR, D1HigherColor);
ObjectSet("D1Higher", OBJPROP_FIBOLEVELS,1);
ObjectSet("D1Higher", OBJPROP_FIRSTLEVEL+0,0.0); ObjectSetFiboDescription("D1Higher", 0, "H4 HIGHER- %$");
ObjectSet("D1Higher", OBJPROP_RAY, true);
ObjectSet("D1Higher", OBJPROP_BACK, true);
ObjectSet("D1Higher", OBJPROP_COLOR, EMPTY);
if(ObjectFind("D1Lower") == -1)
ObjectCreate("D1Lower", OBJ_FIBO, 0, D1StartTime, D1LoPrice-D1Range, D1StartTime, 1LoPrice);
else
{
ObjectSet("D1Lower", OBJPROP_TIME2, D1StartTime);
ObjectSet("D1Lower", OBJPROP_TIME1, D1StartTime);
ObjectSet("D1Lower", OBJPROP_PRICE1, D1LoPrice-D1Range);
ObjectSet("D1Lower", OBJPROP_PRICE2, D1LoPrice);
}
ObjectSet("D1Lower", OBJPROP_LEVELCOLOR, D1LowerColor);
ObjectSet("D1Lower", OBJPROP_FIBOLEVELS,1);
ObjectSet("D1Lower", OBJPROP_FIRSTLEVEL+0,0.0); ObjectSetFiboDescription("D1Lower", 0, "H4 LOWER - %$");
ObjectSet("D1Lower", OBJPROP_RAY, true);
ObjectSet("D1Lower", OBJPROP_BACK, true);
ObjectSet("D1Lower", OBJPROP_COLOR, EMPTY);
}
/////////////////////////////////////////HILO////////
/////////////////////////////////////////MIDDLE////
if(H4Mid)
if(ObjectFind("H4Middle") == -1)
ObjectCreate("H4Middle", OBJ_FIBO, 0, StartTime, HiPrice, StartTime+PERIOD_H4*60, LoPrice);
else
{
ObjectSet("H4Middle", OBJPROP_TIME2, StartTime);
ObjectSet("H4Middle", OBJPROP_TIME1, StartTime+PERIOD_H4*60);
ObjectSet("H4Middle", OBJPROP_PRICE1, HiPrice);
ObjectSet("H4Middle", OBJPROP_PRICE2, LoPrice);
}
ObjectSet("H4Middle", OBJPROP_LEVELCOLOR, H4MiddleColor);
ObjectSet("H4Middle", OBJPROP_FIBOLEVELS,1);
ObjectSet("H4Middle", OBJPROP_FIRSTLEVEL+0,0.500); ObjectSetFiboDescription("H4Middle", 0, "H4 MIDDLE - %$");
ObjectSet("H4Middle", OBJPROP_RAY, true);
ObjectSet("H4Middle", OBJPROP_BACK, true);
ObjectSet("H4Middle", OBJPROP_COLOR, EMPTY);
}
if(D1Mid)
if(ObjectFind("D1Middle") == -1)
ObjectCreate("D1Middle", OBJ_FIBO, 0, D1StartTime, D1HiPrice, D1StartTime+PERIOD_D1*60, D1LoPrice);
else
{
ObjectSet("D1Middle", OBJPROP_TIME2, D1StartTime);
ObjectSet("D1Middle", OBJPROP_TIME1, D1StartTime+PERIOD_D1*60);
ObjectSet("D1Middle", OBJPROP_PRICE1, D1HiPrice);
ObjectSet("D1Middle", OBJPROP_PRICE2, D1LoPrice);
}
ObjectSet("D1Middle", OBJPROP_LEVELCOLOR, D1MiddleColor);
ObjectSet("D1Middle", OBJPROP_FIBOLEVELS,1);
ObjectSet("D1Middle", OBJPROP_FIRSTLEVEL+0,0.500); ObjectSetFiboDescription("D1Middle", 0, "D1 MIDDLE - %$");
ObjectSet("D1Middle", OBJPROP_RAY, true);
ObjectSet("D1Middle", OBJPROP_BACK, true);
ObjectSet("D1Middle", OBJPROP_COLOR, EMPTY);
}
/////////////////////////////////////////MIDDLE////
//+-----------------------------------------------+
//| Indicator start function
//+-----------------------------------------------+
int start()
{
int shift = iBarShift(NULL, PERIOD_D1, Time[0]) + 1; // H4
HiPrice = iHigh(NULL, PERIOD_H4, shift);
LoPrice = iLow (NULL, PERIOD_H4, shift);
StartTime = iTime(NULL, PERIOD_H4, shift);
D1HiPrice = iHigh(NULL, PERIOD_D1, shift);
D1LoPrice = iLow (NULL, PERIOD_D1, shift);
D1StartTime = iTime(NULL, PERIOD_D1, shift);
if(TimeDayOfWeek(StartTime) == 0/*Sunday*/)
{//Add fridays high and low
HiPrice = MathMax(HiPrice, iHigh(NULL,PERIOD_H4, shift+1));
LoPrice = MathMin(LoPrice, iLow(NULL,PERIOD_H4, shift+1));
D1HiPrice = MathMax(D1HiPrice, iHigh(NULL, PERIOD_D1, shift+1));
D1LoPrice = MathMin(D1LoPrice, iLow(NULL, PERIOD_D1, shift+1));
}
Range = HiPrice - LoPrice;
D1Range = D1HiPrice - D1LoPrice;
DrawFibo();
return(0);
}
//+------------------------------+
Bellow this i attach the original for H4 high low mid
Last edited by newdigital; 05-25-2008 at 08:00 AM .
05-26-2008, 01:53 PM
Senior Member
Join Date: Aug 2006
Location: London
Posts: 516
I would like some help please I am trying to use the delta-stop as a stop loss
and trailing stop. Attached is the EA.
Is it posible to do this.
05-26-2008, 04:52 PM
Banned
Join Date: Nov 2006
Posts: 802
highlower.gif
Quote:
//+------------------------------------------------------------------+
//| MODIFIED BY Avery T. Horton, Jr. aka TheRumpledOne |
//| |
//| |
//|
//
// google search "therumpledone mt4"
//
//+------------------------------------------------------------------+
//| _Fibo_Hi_Low_Middle.mq4
//| Base from spudfibo.Upgrade by Darkkiller
//: Thanks to Mladen for helping me to make some correction
//+------------------------------------------------------------------+
#property indicator_chart_window
extern int myChartPeriod = 0 ;
extern string note1 = "Higher,Middle,Lower colors";
extern color HigherColor = DeepSkyBlue;
extern color MiddleColor = Yellow;
extern color LowerColor = HotPink;
extern string note2 = "Draw middle?";
extern bool HiLow = true;
extern bool Mid = true;
double HiPrice, LoPrice, Range;
datetime StartTime;
string tChartPeriod, tHigher, tLower, tMiddle ;
int init()
{
if(myChartPeriod == 0) { myChartPeriod = Period() ; }
tChartPeriod = TimeFrameToString(myChartPeriod) ;
tHigher = tChartPeriod + "H" ;
tLower = tChartPeriod + "L" ;
tMiddle = tChartPeriod + "M" ;
return(0);
}
int deinit()
{
ObjectDelete(tHigher);
ObjectDelete(tLower);
ObjectDelete(tMiddle);
return(0);
}
//+------------------------------------------------------------------+
//| Draw Fibo
//+------------------------------------------------------------------+
int DrawFibo()
{
if(HiLow)
{
if(ObjectFind(tHigher) == -1)
ObjectCreate(tHigher,OBJ_FIBO,0,StartTime,HiPrice+ Range,StartTime,HiPrice);
else
{
ObjectSet(tHigher,OBJPROP_TIME2, StartTime);
ObjectSet(tHigher,OBJPROP_TIME1, StartTime);
ObjectSet(tHigher,OBJPROP_PRICE1,HiPrice+Range);
ObjectSet(tHigher,OBJPROP_PRICE2,HiPrice);
}
ObjectSet(tHigher,OBJPROP_LEVELCOLOR,HigherColor);
ObjectSet(tHigher,OBJPROP_FIBOLEVELS,1);
ObjectSet(tHigher,OBJPROP_FIRSTLEVEL+0,0.0);
ObjectSetFiboDescription(tHigher,0,tChartPeriod+" HIGHER- %$");
ObjectSet(tHigher,OBJPROP_RAY,true);
ObjectSet(tHigher,OBJPROP_BACK,true);
ObjectSet(tHigher,OBJPROP_COLOR,EMPTY);
if(ObjectFind(tLower) == -1)
ObjectCreate(tLower,OBJ_FIBO,0,StartTime,LoPrice-Range,StartTime,LoPrice);
else
{
ObjectSet(tLower,OBJPROP_TIME2, StartTime);
ObjectSet(tLower,OBJPROP_TIME1, StartTime);
ObjectSet(tLower,OBJPROP_PRICE1,LoPrice-Range);
ObjectSet(tLower,OBJPROP_PRICE2,LoPrice);
}
ObjectSet(tLower,OBJPROP_LEVELCOLOR,LowerColor);
ObjectSet(tLower,OBJPROP_FIBOLEVELS,1);
ObjectSet(tLower,OBJPROP_FIRSTLEVEL+0,0.0);
ObjectSetFiboDescription(tLower,0,tChartPeriod+" LOWER - %$");
ObjectSet(tLower,OBJPROP_RAY,true);
ObjectSet(tLower,OBJPROP_BACK,true);
ObjectSet(tLower,OBJPROP_COLOR,EMPTY);
}
/////////////////////////////////////////MIDDLE///////////////////////////
if(Mid)
if(ObjectFind(tMiddle) == -1)
ObjectCreate(tMiddle,OBJ_FIBO,0,StartTime,HiPrice, StartTime+myChartPeriod*60,LoPrice);
else
{
ObjectSet(tMiddle,OBJPROP_TIME2, StartTime);
ObjectSet(tMiddle,OBJPROP_TIME1, StartTime+myChartPeriod*60);
ObjectSet(tMiddle,OBJPROP_PRICE1,HiPrice);
ObjectSet(tMiddle,OBJPROP_PRICE2,LoPrice);
}
ObjectSet(tMiddle,OBJPROP_LEVELCOLOR,MiddleColor);
ObjectSet(tMiddle,OBJPROP_FIBOLEVELS,1);
ObjectSet(tMiddle,OBJPROP_FIRSTLEVEL+0,0.500);
ObjectSetFiboDescription(tMiddle,0,tChartPeriod+" MIDDLE - %$");
ObjectSet(tMiddle,OBJPROP_RAY,true);
ObjectSet(tMiddle,OBJPROP_BACK,true);
ObjectSet(tMiddle,OBJPROP_COLOR,EMPTY);
}
//+------------------------------------------------------------------+
//| Indicator start function
//+------------------------------------------------------------------+
int start()
{
int shift = iBarShift(NULL,myChartPeriod,Time[0]) + 1; //
HiPrice = iHigh(NULL,myChartPeriod,shift);
LoPrice = iLow (NULL,myChartPeriod,shift);
StartTime = iTime(NULL,myChartPeriod,shift);
if(TimeDayOfWeek(StartTime)==0/*Sunday*/)
{//Add fridays high and low
HiPrice = MathMax(HiPrice,iHigh(NULL,myChartPeriod,shift+1)) ;
LoPrice = MathMin(LoPrice,iLow(NULL,myChartPeriod,shift+1));
}
Range = HiPrice-LoPrice;
DrawFibo();
// Comment( "Period_", tChartPeriod ) ;
return(0);
}
//+------------------------------------------------------------------+
string TimeFrameToString(int tf)
{
string tfs;
switch(tf) {
case PERIOD_M1: tfs="M1" ; break;
case PERIOD_M5: tfs="M5" ; break;
case PERIOD_M15: tfs="M15" ; break;
case PERIOD_M30: tfs="M30" ; break;
case PERIOD_H1: tfs="H1" ; break;
case PERIOD_H4: tfs="H4" ; break;
case PERIOD_D1: tfs="D1" ; break;
case PERIOD_W1: tfs="W1" ; break;
case PERIOD_MN1: tfs="MN";
}
return(tfs);
}
That's how I did it.
P.S. why are my attachments getting deleted?
05-27-2008, 03:15 AM
Senior Member
Join Date: Oct 2006
Posts: 1,218
MoveStopOnce
Hello, trying to get this MoveStopOnce code to work but the Sell trades don't seem to get modified by the code, just the Buys. Anything wrong?
Code:
//Buys
//MoveOnce
if(MoveStopOnce && MoveStopWhenPrice > 0) {
if(Bid - OrderOpenPrice() >= Point * MoveStopWhenPrice) {
if(OrderStopLoss() < OrderOpenPrice() + Point * MoveStopTo) {
OrderModify(OrderTicket(),OrderOpenPrice(), OrderOpenPrice() + Point * MoveStopTo, OrderTakeProfit(), 0, Red);
if (!EachTickMode) BarCount = Bars;
continue;
}
}
}
Code:
//Sells
//MoveOnce
if(MoveStopOnce && MoveStopWhenPrice > 0) {
if(OrderOpenPrice() - Ask >= Point * MoveStopWhenPrice) {
if(OrderStopLoss() > OrderOpenPrice() - Point * MoveStopTo) {
OrderModify(OrderTicket(),OrderOpenPrice(), OrderOpenPrice() - Point * MoveStopTo, OrderTakeProfit(), 0, Red);
if (!EachTickMode) BarCount = Bars;
continue;
}
}
}
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
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Thread Tools
Display Modes
Linear Mode
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
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:28 PM .