Forex



Go Back   Forex Trading > Programming > MetaTrader
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
  #1891 (permalink)  
Old 07-07-2009, 09:29 AM
paradiseview's Avatar
Junior Member
 
Join Date: Sep 2006
Posts: 4
paradiseview is on a distinguished road
Quote:
Originally Posted by fosgate_r View Post
I don't understand this part "Trying to get the shift to have the london open price is impossible". Could you describe more? Maybe I can help.
hey fosgate,
let's say we're at 12:00 and london open is at 08:00. To get the open price of london open there are few ways to do that:
int open1= iMA(NULL,PERIOD_H1,4,test1,MODE_SMA,PRICE_OPEN,0);
other way to do that is:
double Open[4];
another way also:
iOpen(NULL,PERIOD_H1,4);

All of these methods would give me london open price. Now the problem is that once we're at 13:00 , they will give me the open price ay 09:00 and not 08:00 (which is what I want)
In other ways, at 13:00 the shift should change to 5 instead of 4.

Hope I was clear
tc
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
  #1892 (permalink)  
Old 07-07-2009, 11:57 AM
Senior Member
 
Join Date: Nov 2006
Posts: 308
luxinterior is on a distinguished road
Use iBarShift to get the correct shift then just use iOpen. The example in the help file shows you how to get the right bar...

Quote:
datetime some_time=D'2004.03.21 12:00';
int shift=iBarShift("EUROUSD",PERIOD_M1,some_time);
Print("shift of bar with open time ",TimeToStr(some_time)," is ",shift);
Just put this together to show you how to do it...

Code:
   string sDate = TimeToStr(TimeCurrent(), TIME_DATE);
   datetime dtTenToday = StrToTime(sDate + " 10:00");
   Print("Bar shift " + iBarShift(Symbol(), PERIOD_H1, dtTenToday) + " was the last 10:00 bar");
Lux
__________________
Build An Expert Advisor. FREE E-course As Seen On TV
ForexArea.com
Users of Gap Trader from 'Forex-Assistant' MUST Read This

Last edited by luxinterior; 07-07-2009 at 12:11 PM.
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
  #1893 (permalink)  
Old 07-07-2009, 01:42 PM
paradiseview's Avatar
Junior Member
 
Join Date: Sep 2006
Posts: 4
paradiseview is on a distinguished road
Quote:
Originally Posted by luxinterior View Post
Use iBarShift to get the correct shift then just use iOpen. The example in the help file shows you how to get the right bar...



Just put this together to show you how to do it...

Code:
   string sDate = TimeToStr(TimeCurrent(), TIME_DATE);
   datetime dtTenToday = StrToTime(sDate + " 10:00");
   Print("Bar shift " + iBarShift(Symbol(), PERIOD_H1, dtTenToday) + " was the last 10:00 bar");
Lux
Thank you Lux !
Could please tell what I'm doing wrong in this test indicator? The result I get is a price that do not change when I change "10:00" in the code. I don't know where that price came from .

Code:
  //+------------------------------------------------------------------+
//|                                                    ibarshift.mq4 |
//|                      Copyright © 2008, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#property indicator_chart_window
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
//----
         string sDate = TimeToStr(TimeCurrent(), TIME_DATE);
         datetime dtTenToday = StrToTime(sDate + " 10:00");
       
     //  Print("Bar shift " + iBarShift(Symbol(), PERIOD_H1, dtTenToday) + " was the last 10:00 bar");
   
 
        int NY_Open_Shift = iBarShift(Symbol(), PERIOD_H1, dtTenToday);   
        int NY_Open = iOpen(Symbol(),PERIOD_M30,NY_Open_Shift);

        ObjectCreate("NYOPENTITLE", OBJ_LABEL, 0, 0, 0);
        ObjectSetText("NYOPENTITLE","NY_Open:",10, "Arial", LightSteelBlue);
        ObjectSet("NYOPENTITLE", OBJPROP_CORNER, 1);
        ObjectSet("NYOPENTITLE", OBJPROP_XDISTANCE, 775);
        ObjectSet("NYOPENTITLE", OBJPROP_YDISTANCE, 30);
        
        ObjectCreate("NYOpen", OBJ_LABEL, 0, 0, 0);
        ObjectSetText("NYOpen",DoubleToStr(NY_Open,Digits),10, "Arial Bold", Orange);
        ObjectSet("NYOpen", OBJPROP_CORNER, 1);
        ObjectSet("NYOpen", OBJPROP_XDISTANCE, 725);
        ObjectSet("NYOpen", OBJPROP_YDISTANCE, 30);

//----
   return(0);
  }
//+------------------------------------------------------------------+
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
  #1894 (permalink)  
Old 07-07-2009, 05:17 PM
necrophantom's Avatar
Junior Member
 
Join Date: Jun 2007
Posts: 15
necrophantom is on a distinguished road
1hfib

Hi ND and all of my friends...this is my indi..i've been using for 1 year..but one thing that make me little disturb..i have to refresh every 1 hour ...
So, i will very very appreciate if someone can make this indi auto refresh..here is :
//+------------------------------------------------------------------+
//| Citromenggalan.mq4 |
//| Copyright © 2006, Archer Trading, LLC |
//| Archer Trading S.A. - Managed Forex Accounts | Forex Managed Account | Managed Forex |
//+------------------------------------------------------------------+
#property copyright "Sederhana"
#property link "http://www.gloriaedukasindo.co.cc/"

#property indicator_chart_window
#property indicator_buffers 7
#property indicator_color1 White
#property indicator_color2 Lime
#property indicator_color3 Lime
#property indicator_color4 Yellow
#property indicator_color5 Yellow
#property indicator_color6 Red
#property indicator_color7 Red


double PBuffer[];
double S1Buffer[];
double R1Buffer[];
double S2Buffer[];
double R2Buffer[];
double S3Buffer[];
double R3Buffer[];
double S0Buffer[];
double R0Buffer[];
string Pivot="Pivot Point",FibS1="S 1", FibR1="R 1";
string FibS2="S 2", FibR2="R 2", FibS3="S 3", FibR3="R 3";
int fontsize=10;
double P,R,S1,R1,S2,R2,S3,R3;
double LastHigh,LastLow,x;

//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{


ObjectDelete("Pivot");
ObjectDelete("FibS1");
ObjectDelete("FibR1");
ObjectDelete("FibS2");
ObjectDelete("FibR1");
ObjectDelete("FibS3");
ObjectDelete("FibR2");

//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
string short_name;


SetIndexStyle(0,DRAW_LINE,0,2,White);
SetIndexStyle(1,DRAW_LINE,0,1,Lime);
SetIndexStyle(2,DRAW_LINE,0,1,Lime);
SetIndexStyle(3,DRAW_LINE,0,1,Yellow);
SetIndexStyle(4,DRAW_LINE,0,1,Yellow);
SetIndexStyle(5,DRAW_LINE,0,1,Red);
SetIndexStyle(6,DRAW_LINE,0,1,Red);
SetIndexBuffer(0,PBuffer);
SetIndexBuffer(1,S1Buffer);
SetIndexBuffer(2,R1Buffer);
SetIndexBuffer(3,S2Buffer);
SetIndexBuffer(4,R2Buffer);
SetIndexBuffer(5,S3Buffer);
SetIndexBuffer(6,R3Buffer);


//---- name for DataWindow and indicator subwindow label
short_name="Fibonacci Pivot Points";
IndicatorShortName(short_name);
SetIndexLabel(0,short_name);

//----
SetIndexDrawBegin(0,1);
//----


//----
return(0);
}

//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()

{
int counted_bars=IndicatorCounted();

int limit, i;
//---- indicator calculation
if (counted_bars==0)
{
x=Period();
if (x>240) return(-1);
ObjectCreate("Pivot", OBJ_TEXT, 0, 0,0);
ObjectSetText("Pivot", "Pivot",fontsize,"Arial",White);
ObjectCreate("FibS1", OBJ_TEXT, 0, 0, 0);
ObjectSetText("FibS1", "Fib S1",fontsize,"Arial",Lime);
ObjectCreate("FibR1", OBJ_TEXT, 0, 0, 0);
ObjectSetText("FibR1", "Fib R1",fontsize,"Arial",Lime);
ObjectCreate("FibS2", OBJ_TEXT, 0, 0, 0);
ObjectSetText("FibS2", "Fib S2",fontsize,"Arial",Yellow);
ObjectCreate("FibR2", OBJ_TEXT, 0, 0, 0);
ObjectSetText("FibR2", "Fib R2",fontsize,"Arial",Yellow);
ObjectCreate("FibS3", OBJ_TEXT, 0, 0, 0);
ObjectSetText("FibS3", "Fib S3",fontsize,"Arial",Red);
ObjectCreate("FibR3", OBJ_TEXT, 0, 0, 0);
ObjectSetText("FibR3", "Fib R3",fontsize,"Arial",Red);
}
if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
// if(counted_bars>0) counted_bars--;
limit=(Bars-counted_bars)-1;



for (i=limit; i>=0;i--)
{

if (High[i+1]>LastHigh) LastHigh=High[i+1];
if (Low[i+1]<LastLow) LastLow=Low[i+1];
if (TimeHour(Time[i])!=TimeHour(Time[i+1]))
{
P=(LastHigh+LastLow+Close[i+1])/3;
R = LastHigh-LastLow;
R1 = P + (R * 1);
S1 = P - (R * 1);

LastLow=Open[i]; LastHigh=Open[i];

ObjectMove("Pivot", 0, Time[i],P);
ObjectMove("FibS1", 0, Time[i],S1);
ObjectMove("FibR1", 0, Time[i],R1);
ObjectMove("FibS2", 0, Time[i],S2);
ObjectMove("FibR2", 0, Time[i],R2);
ObjectMove("FibS3", 0, Time[i],S3);
ObjectMove("FibR3", 0, Time[i],R3);

}

PBuffer[i]=P;
S1Buffer[i]=S1;
R1Buffer[i]=R1;
S2Buffer[i]=S2;
R2Buffer[i]=R2;
S3Buffer[i]=S3;
R3Buffer[i]=R3;
}

//----
return(0);
}
//+------------------------------------------------------------------+
Attached Files
File Type: mq4 1hfib2.mq4 (4.7 KB, 14 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
  #1895 (permalink)  
Old 07-07-2009, 09:45 PM
nondisclosure007's Avatar
Senior Member
 
Join Date: Apr 2007
Posts: 125
nondisclosure007 is on a distinguished road
High and High[0]

Do
Code:
High
and
Code:
High[0]
both reference the same candle?
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
  #1896 (permalink)  
Old 07-07-2009, 11:44 PM
Senior Member
 
Join Date: Nov 2006
Posts: 308
luxinterior is on a distinguished road
Quote:
Originally Posted by paradiseview View Post
Thank you Lux !
Could please tell what I'm doing wrong in this test indicator? The result I get is a price that do not change when I change "10:00" in the code. I don't know where that price came from .
I haven't looked at it too closely but I do notice that you're mixing time frames which isn't a good idea. You're getting the shift of the right candle based on the 1HR time frame but then using that shift on the 30M timeframe.

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!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #1897 (permalink)  
Old 07-08-2009, 12:22 AM
ralph.ronnquist's Avatar
Senior Member
 
Join Date: Oct 2006
Posts: 297
ralph.ronnquist is on a distinguished road
Quote:
Originally Posted by necrophantom View Post
Hi ND and all of my friends...this is my indi..i've been using for 1 year..but one thing that make me little disturb..i have to refresh every 1 hour ...
So, i will very very appreciate if someone can make this indi auto refresh..
Removing the -1 on assigning limit might help.
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
  #1898 (permalink)  
Old 07-08-2009, 03:32 AM
Junior Member
 
Join Date: Jun 2008
Posts: 19
Pied Piper is an unknown quantity at this point
Pure Stop & Reverse EA

Sorry to digress a little guys. Pls, can any in-house programmer code an EA that operates purely based on a stop and reverse strategy? I'm willing to pay. Please PM me for more details if interested.


Thanks so much. I've been contacted.

Last edited by Pied Piper; 07-09-2009 at 01:46 AM. Reason: Found what I wanted
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
  #1899 (permalink)  
Old 07-08-2009, 04:19 AM
necrophantom's Avatar
Junior Member
 
Join Date: Jun 2007
Posts: 15
necrophantom is on a distinguished road
Quote:
Originally Posted by ralph.ronnquist View Post
Removing the -1 on assigning limit might help.
Ok..thanks ralph...let's see
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
  #1900 (permalink)  
Old 07-08-2009, 08:10 PM
SPACECHIMP's Avatar
Member
 
Join Date: Feb 2006
Location: West Michigan, USA.
Posts: 86
SPACECHIMP is on a distinguished road
opening a position

Position opening question for programming..

ALL I want is code for opening a single position ONE Time when conditions are true for entering. And NOT open any more positions in that direction.

Example
1. MA's cross
2. a BUY order is sent
3. CONFIRM Buy is opened (with magic number)
4. Don't open ANYMORE buys, even if above buy hits TP.
5. Do opposite when MA's cross in opposite direction.

I've tried my best to code something to do the above but I get NO positions when there should be one, then i get 1 sometimes, then I get 4 Sometimes.
So my code is Krap obviously. It has to 100% consistent

I ONLY need the code for opening, confirming **1** position only and not opening more
__________________
www.LiveTeamTrading.com
The FIRST LIVE Team trading Network Community for FOREX TRADERS! Ask me about Getting an Invite!
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


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 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 09:12 PM.



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