Please help with this quick bit of coding... - page 2

 

what TF do u looking at

 

I use throughout the day 5min, 10min, 15min and 1 hour chart, that inage is just from an e book I have but it was just to demonstrate what I am trying to achieve.

Thanks

Antony

 

Basically, the red line is what I am trying to achieve and the black line is what the indicator is currently doing :(

Thanks

 

look @ the daily chart (it's not supposed to be a daily HL)

 

ah now I see :(

I think maybe I need to get a new indicator made? at the moment I manually adjust horizontal lines each time the price has made a new high or low for that particular day, I go of the close of the lowest or highest candle.

I am trying to automate this with that indicator.

Unless you have any ideas?

Sorry I am useless with coding :(

Thanks again

Antony

 

Hi again,

I came accross this indicator:

//+------------------------------------------------------------------+
//| Igrok.mq4 |
//| Andrei Andreev |
//| http://www.andand.ru/ |
//+------------------------------------------------------------------+

// BASED ON:
//+------------------------------------------------------------------+
//| ^X_Sensors.mq4 |
//| Version 2.0.1 |
//|------------------------------------------------------------------|
//| Copyright © 2007, Mr.WT, Senior Linux Hacker |
//| http://w-tiger.narod.ru/wk2/ |
//+------------------------------------------------------------------+
#property copyright "Andrei Andreev"
#property link "http://www.andand.ru/"

#property indicator_chart_window
extern int ForDays=10;
extern int _Shift = 20;
extern color _R_Color = Crimson;
extern color _S_Color = Gold;


int _N_Time, _My_Period, ObjectId;
string OBJECT_PREFIX = "LEVELS";
//-------------------------------------------------------------------------------------------
int init() {

_My_Period=PERIOD_D1;

_N_Time = 0;

ObjectCreate("S1 line", OBJ_TREND, 0, Time[_Shift], 0, Time[0], 0);

ObjectCreate("R1 line", OBJ_TREND, 0, Time[_Shift], 0, Time[0], 0);
ObjectCreate("R2 line", OBJ_TREND, 0, Time[_Shift], 0, Time[0], 0);

ObjectSet("S1 line", OBJPROP_RAY, 1);
ObjectSet("S1 line", OBJPROP_STYLE, STYLE_DASH);
ObjectSet("S1 line", OBJPROP_COLOR, _S_Color);


ObjectSet("R1 line", OBJPROP_RAY, 1);
ObjectSet("R1 line", OBJPROP_STYLE, STYLE_DASH);
ObjectSet("R1 line", OBJPROP_COLOR, _R_Color);

ObjectSet("R2 line", OBJPROP_RAY, 1);
ObjectSet("R2 line", OBJPROP_STYLE, STYLE_DASH);
ObjectSet("R2 line", OBJPROP_COLOR, _R_Color);


ObjectCreate("R1 label", OBJ_TEXT, 0, Time[0], 0);
ObjectCreate("R2 label", OBJ_TEXT, 0, Time[0], 0);

ObjectCreate("S1 label", OBJ_TEXT, 0, Time[0], 0);

ObjectId = 0;
return(0);
}
//-------------------------------------------------------------------------------------------
int deinit() {


ObjectDelete("R1 label");
ObjectDelete("R1 line");
ObjectDelete("R2 label");
ObjectDelete("R2 line");

ObjectDelete("S1 label");
ObjectDelete("S1 line");


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

if ( _N_Time == Time[0] ) return(0);

double open,close, high, low, koeff1, koeff2,P, R1, R2, S1;
double _rates[][6];
double AverageRange;

ArrayCopyRates(_rates, NULL, _My_Period);
int err = GetLastError();
if(err == 4066) {
Sleep(1000);
if(iClose(NULL, _My_Period, 0) != Close[0]) {
Sleep(1000);
return(0);
}
}
close = _rates[1][4];
high = _rates[0][3];
low = _rates[0][2];
open = _rates[0][1];

AverageRange=0;
for (int i=1;i<ForDays+1;i++)
{
AverageRange=AverageRange+(_rates[i][3]-_rates[i][2])/Point;
}
AverageRange=NormalizeDouble(AverageRange/ForDays,0);

Comment("\nÄèàïàçîí:",
"\nÑåãîäíÿ: ",(high-low)/Point,
"\nÂ÷åðà: ",(_rates[1][3]-_rates[1][2])/Point,
"\nÑðåäíèé: ",AverageRange," çà ",ForDays," äíåé");

S1 =open;
R1 =low;
R2 =high;

string s1,r1,r2;

s1 = DoubleToStr(S1, Digits);

r1 = DoubleToStr(R1, Digits);
r2 = DoubleToStr(R2, Digits);


//---- Pivot Lines
ObjectSetText("R1 label", " Min "+r1+"", 8, "Fixedsys", _R_Color);
ObjectSetText("R2 label", " Max "+r2+"", 8, "Fixedsys", _R_Color);
ObjectSetText("S1 label", " Open "+s1+"", 8, "Fixedsys", _S_Color);

ObjectMove("R1 label", 0, Time[0], R1);
ObjectMove("R2 label", 0, Time[0], R2);


ObjectMove("S1 label", 0, Time[0], S1);


ObjectMove("S1 line", 0, Time[_Shift], S1);
ObjectMove("S1 line", 1, Time[0], S1);


ObjectMove("R1 line", 0, Time[_Shift], R1);
ObjectMove("R1 line", 1, Time[0], R1);

ObjectMove("R2 line", 0, Time[_Shift], R2);
ObjectMove("R2 line", 1, Time[0], R2);


//====

_N_Time = Time[0];
//---- End Of Program
return(0);
}
//+------------------------------------------------------------------+

void ObDeleteObjectsByPrefix(string Prefix)
{
int L = StringLen(Prefix);
int i = 0;
while(i < ObjectsTotal())
{
string ObjName = ObjectName(i);
if(StringSubstr(ObjName, 0, L) != Prefix)
{
i++;
continue;
}
ObjectDelete(ObjName);
}
}
//-------------------------------------------------------------------------------------------

 

You could try using the fractal indicator to tell you the High and low points and then use the line draw through the close on a low and line draw through the open on a high.

The fractal indicator need not be displayed. I have only glanced at this discussion and not interested in going further sorry.

 

It does almost exactly what I require, but it using the full movement of the candle, I am only interested in the close of the candles to plot the lowest and highest price of the day. I need the indicator to disregard the shadow of the candle.

Thanks

Antony

 

i send u a PM

 

You only need to adjust what the fractal indicator code uses for its calculations. I will leave it to the capable mind of qjol