Help! Simple indicator to plot 3 lines... =(

If you don't know where to start, start here! Don't be afraid to ask questions.

Moderator: moderators

User avatar
ajaymein
rank: 500+ posts
rank: 500+ posts
Posts: 885
Joined: Sun Nov 09, 2008 6:34 am
Reputation: 1
Gender: None specified

Help! Simple indicator to plot 3 lines... =(

Postby ajaymein » Wed Jan 14, 2009 9:01 pm

Hello,

I cannot figure out how to code indicators. I have been working on EAs but I need an indicator that will plot 3 basic lines:

1) The Open price of the day
2) (Open price of the day) - 0.0030
3) (Open price of the day) + 0.0030

This is soo extremely simple...yet I can't figure it out! Someone pleeaassee help!

Thanks!

Please add www.kreslik.com to your ad blocker white list.
Thank you for your support.

User avatar
TheRumpledOne
rank: 10000+ posts
rank: 10000+ posts
Posts: 15561
Joined: Sun May 14, 2006 9:31 pm
Reputation: 3035
Location: Oregon
Real name: Avery T. Horton, Jr.
Gender: None specified
Contact:

Postby TheRumpledOne » Wed Jan 14, 2009 9:09 pm

The BuyZone has that code in it.
IT'S NOT WHAT YOU TRADE, IT'S HOW YOU TRADE IT!

Please do NOT PM me with trading or coding questions, post them in a thread.

User avatar
ajaymein
rank: 500+ posts
rank: 500+ posts
Posts: 885
Joined: Sun Nov 09, 2008 6:34 am
Reputation: 1
Gender: None specified

Postby ajaymein » Thu Jan 15, 2009 1:09 am

Hmm...I am looking at the BZ Hourly History indicator code and honestly I cannot tell which parts of the code to modify to show the 3 lines I want. Could you please lead me in the right direction?

Thanks!

User avatar
ajaymein
rank: 500+ posts
rank: 500+ posts
Posts: 885
Joined: Sun Nov 09, 2008 6:34 am
Reputation: 1
Gender: None specified

Postby ajaymein » Thu Jan 15, 2009 1:22 am

Ahh never mind TRO...I was messing with the code and figured out how to show the Daily...now I just need to delete some sections of the code so I only get 3 lines, not the double lines that the Buy Zone has.

Thanks!

User avatar
ajaymein
rank: 500+ posts
rank: 500+ posts
Posts: 885
Joined: Sun Nov 09, 2008 6:34 am
Reputation: 1
Gender: None specified

Postby ajaymein » Thu Jan 15, 2009 3:08 am

Hey actually, I got it to work on a Daily chart, but when I change to other time frames the 3 lines start moving to the open of the current bar...I need the indicator to plot 3 lines according to the Daily Open regardless of the time frame the chart is in...I put the code below, please point out what I am doing wrong!


//+------------------------------------------------------------------+
//| MTC.mq4 |
//| Copyright ? 2007, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright ? 2007, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"


/*
Constant Value Description
DRAW_LINE 0 Drawing line.
DRAW_SECTION 1 Drawing sections.
DRAW_HISTOGRAM 2 Drawing histogram.
DRAW_ARROW 3 Drawing arrows (symbols).
DRAW_ZIGZAG 4 Drawing sections between even and odd indicator buffers.
DRAW_NONE 12 No drawing.

Drawing style. Valid when width=1. It can be any of the following values:

Constant Value Description
STYLE_SOLID 0 The pen is solid.
STYLE_DASH 1 The pen is dashed.
STYLE_DOT 2 The pen is dotted.
STYLE_DASHDOT 3 The pen has alternating dashes and dots.
STYLE_DASHDOTDOT 4 The pen has alternating dashes and double dots.

*/

#property indicator_chart_window

#property indicator_buffers 5
#property indicator_color1 Blue
#property indicator_color2 Blue
#property indicator_color3 White
#property indicator_color4 Red
#property indicator_color5 Red
//---- input parameters

extern int myWingDingL = 250 ;
extern int myWingDingO = 250 ;
extern int myWingDingS = 250 ;

extern int myLine = DRAW_LINE ;
extern int myStyle = STYLE_SOLID ;

extern string session_name = "Day open";

extern int straddle_width=30;
extern int channel=0;

double lgb[];
double opn[];
double shb[];
double open_price;
double rates_d1[2][6];
string OP, BZ, BZW, SZ, SZW;

//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{

SetIndexBuffer(1, lgb);
SetIndexBuffer(2, opn);
SetIndexBuffer(4, shb);


//---- indicators

SetIndexStyle(1,myLine, myStyle);
SetIndexArrow(1,myWingDingL);
SetIndexBuffer(1,lgb);
SetIndexEmptyValue(1,0.0);
SetIndexStyle(2,myLine, myStyle);
SetIndexArrow(2,myWingDingO);
SetIndexBuffer(2,opn);
SetIndexEmptyValue(2,0.0);
SetIndexStyle(4,myLine, myStyle);
SetIndexArrow(4,myWingDingS);
SetIndexBuffer(4,shb);
SetIndexEmptyValue(4,0.0);

//----
//---- indicators


OP = "Open " + session_name;
BZ = "Buy zone " + session_name;
BZW = "Buy zone width " + session_name;
SZ = "Sell zone " + session_name;
SZW = "Sell zone width " + session_name;
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----


//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{

//----
int i, dayi, counted_bars = IndicatorCounted();
//---- check for possible errors
if(counted_bars < 0)
return(-1);
//---- last counted bar will be recounted
if(counted_bars > 0)
counted_bars--;
int limit = Bars - counted_bars;
//----
for(i = limit - 1; i >= 0; i--)
{

if( TimeDay(Time[i]) != TimeDay(Time[i+1]) ) { int t = i ; }

opn[i] = iOpen(NULL,PERIOD_D1,i);


lgb[i] = opn[i]+(straddle_width+channel)*Point ;


shb[i] = opn[i]-(straddle_width+channel)*Point ;

}

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

Please add www.kreslik.com to your ad blocker white list.
Thank you for your support.

User avatar
ajaymein
rank: 500+ posts
rank: 500+ posts
Posts: 885
Joined: Sun Nov 09, 2008 6:34 am
Reputation: 1
Gender: None specified

Postby ajaymein » Thu Jan 15, 2009 11:58 pm

Case closed I figured it out. Thx

Please add www.kreslik.com to your ad blocker white list.
Thank you for your support.


Return to “beginners forum”