Coding help - page 160

 
TEAMTRADER:
I downloaded this indicator from one of the threads and it is far better than the CCI-zones or Ma-zones indicators.

Can it be adapted to show on the screen as in a zone indicator?

It is set to CCI setting 13 but if it can be made into a variable setting indicator easily then that would be a bonus - but very much a secondary request.

It is a Forex-TSD indicator but no mq4 folder was with it.

Thanks

TEAMTRADER

As far as I see it is not a cci but a thv t3 trix. You should search some of the variations of thv trix

 

mladen, I have the indicator attached that plots a line for high and low of the previous day..but I need the same indicator that plots the 3 daily previous highs and lows, can you help me?thank s in advance

//+------------------------------------------------------------------+

//| Copyright © 2008, ledxep |

//| http://www.metaquotes.net/ |

//+------------------------------------------------------------------+

#property copyright "Copyright © 2008, ledzep"

#property link "http://www.metaquotes.net/"

#property indicator_chart_window

#property indicator_buffers 1

#property indicator_color1 Blue

//---- input parameters

double DayHigh,DayLow,DayHigh1,DayLow1;

int ObjectIdx;

int DayIdx;

int k;

string ObjName;

datetime StartTime;

//+------------------------------------------------------------------+

//| Custom indicator initialization function |

//+------------------------------------------------------------------+

int init()

{

return(0);

}

//+------------------------------------------------------------------+

//| Deinitialization function |

//+------------------------------------------------------------------+

int deinit()

{

ObjectsDeleteAll();

return(0);

}

//+------------------------------------------------------------------+

//| Start function |

//+------------------------------------------------------------------+

int start()

{

static bool first=true;

int i,counted_bars=IndicatorCounted();

double BarHour,BarMinute;

int WeekDay;

if(Bars<3) return(0);

i=Bars-3;

if(counted_bars==0 || first)

{

first=false;

while(i>=0)

{

TrendLine(StartTime,DayHigh1,Time,DayHigh1,Red);

TrendLine(StartTime,DayLow1,Time,DayLow1,Red);

if(High > DayHigh) DayHigh = High;

if(Low < DayLow) DayLow = Low;

if(TimeDay(Time) != TimeDay(Time))

{

DayHigh1=DayHigh;

DayLow1=DayLow;

DayHigh=Open;

DayLow=Open;

StartTime=Time;

}

i--;

}//while close

}

return(0);

}//start close

//+------------------------------------------------------------------+

void TrendLine(datetime x1, double y1, datetime x2, double y2, color col)

{

ObjectIdx++;

ObjName="Line" + DoubleToStr(ObjectIdx,0);

ObjectCreate(ObjName, OBJ_TREND, 0, x1, y1, x2, y2);

ObjectSet(ObjName,OBJPROP_COLOR,col);

ObjectSet(ObjName,OBJPROP_RAY,0);

}

 
k3rn3l:
mladen, I have the indicator attached that plots a line for high and low of the previous day..but I need the same indicator that plots the 3 daily previous highs and lows, can you help me?thank s in advance

//+------------------------------------------------------------------+

//| Copyright © 2008, ledxep |

//| http://www.metaquotes.net/ |

//+------------------------------------------------------------------+

#property copyright "Copyright © 2008, ledzep"

#property link "http://www.metaquotes.net/"

#property indicator_chart_window

#property indicator_buffers 1

#property indicator_color1 Blue

//---- input parameters

double DayHigh,DayLow,DayHigh1,DayLow1;

int ObjectIdx;

int DayIdx;

int k;

string ObjName;

datetime StartTime;

//+------------------------------------------------------------------+

//| Custom indicator initialization function |

//+------------------------------------------------------------------+

int init()

{

return(0);

}

//+------------------------------------------------------------------+

//| Deinitialization function |

//+------------------------------------------------------------------+

int deinit()

{

ObjectsDeleteAll();

return(0);

}

//+------------------------------------------------------------------+

//| Start function |

//+------------------------------------------------------------------+

int start()

{

static bool first=true;

int i,counted_bars=IndicatorCounted();

double BarHour,BarMinute;

int WeekDay;

if(Bars<3) return(0);

i=Bars-3;

if(counted_bars==0 || first)

{

first=false;

while(i>=0)

{

TrendLine(StartTime,DayHigh1,Time,DayHigh1,Red);

TrendLine(StartTime,DayLow1,Time,DayLow1,Red);

if(High > DayHigh) DayHigh = High;

if(Low < DayLow) DayLow = Low;

if(TimeDay(Time) != TimeDay(Time))

{

DayHigh1=DayHigh;

DayLow1=DayLow;

DayHigh=Open;

DayLow=Open;

StartTime=Time;

}

i--;

}//while close

}

return(0);

}//start close

//+------------------------------------------------------------------+

void TrendLine(datetime x1, double y1, datetime x2, double y2, color col)

{

ObjectIdx++;

ObjName="Line" + DoubleToStr(ObjectIdx,0);

ObjectCreate(ObjName, OBJ_TREND, 0, x1, y1, x2, y2);

ObjectSet(ObjName,OBJPROP_COLOR,col);

ObjectSet(ObjName,OBJPROP_RAY,0);

}

I am afraid I do not understand

That indicator draws the high and the low of previous day over the whole history (as many days as there are on the chart). What does exactly "plots the 3 daily previous highs and lows" mean?

 
mladen:
I am afraid I do not understand That indicator draws the high and the low of previous day over the whole history (as many days as there are on the chart). What does exactly "plots the 3 daily previous highs and lows" mean?

Let me explain, I wish the indicator draws every day, the highs and lows of the previous 3 days

 
k3rn3l:
Let me explain, I wish the indicator draws every day, the highs and lows of the previous 3 days

Try something like this (this one does not use objects but buffers and you can set the number of days you wish to use for highest high and lowest low)

#property indicator_chart_window

#property indicator_buffers 2

#property indicator_color1 LimeGreen

#property indicator_color2 Red

extern int DaysForHighLow = 3;

double buffh[];

double buffl[];

//------------------------------------------------------------------

//

//------------------------------------------------------------------

int init()

{

SetIndexBuffer(0,buffh);

SetIndexBuffer(1,buffl);

return(0);

}

int start()

{

int counted_bars=IndicatorCounted();

if(counted_bars<0) return(-1);

if(counted_bars>0) counted_bars--;

int limit = MathMin(Bars-counted_bars,Bars-1);

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

{

int y = iBarShift(NULL,PERIOD_D1,Time);

buffh = iHigh(NULL,PERIOD_D1,iHighest(NULL,PERIOD_D1,MODE_HIGH,DaysForHighLow,y));

buffl = iLow(NULL,PERIOD_D1,iLowest(NULL,PERIOD_D1,MODE_LOW,DaysForHighLow,y));

}

return(0);

}
 
mladen:
Try something like this (this one does not use objects but buffers and you can set the number of days you wish to use for highest high and lowest low)
#property indicator_chart_window

#property indicator_buffers 2

#property indicator_color1 LimeGreen

#property indicator_color2 Red

extern int DaysForHighLow = 3;

double buffh[];

double buffl[];

//------------------------------------------------------------------

//

//------------------------------------------------------------------

int init()

{

SetIndexBuffer(0,buffh);

SetIndexBuffer(1,buffl);

return(0);

}

int start()

{

int counted_bars=IndicatorCounted();

if(counted_bars<0) return(-1);

if(counted_bars>0) counted_bars--;

int limit = MathMin(Bars-counted_bars,Bars-1);

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

{

int y = iBarShift(NULL,PERIOD_D1,Time);

buffh = iHigh(NULL,PERIOD_D1,iHighest(NULL,PERIOD_D1,MODE_HIGH,DaysForHighLow,y));

buffl = iLow(NULL,PERIOD_D1,iLowest(NULL,PERIOD_D1,MODE_LOW,DaysForHighLow,y));

}

return(0);

}

thank s mladen, sorry for my bad explanation...I meant the high and low of every 3 days previous..for example PreviousHighDaily[1],PreviuosHighDaily[2],PreviousHighDaily[3] and same for low...

 
k3rn3l:
thank s mladen, sorry for my bad explanation...I meant the high and low of every 3 days previous..for example PreviousHighDaily[1],PreviuosHighDaily[2],PreviousHighDaily[3] and same for low...

It is simpler to find than the previous (less function calls)

You can do it like this :

#property indicator_chart_window

#property indicator_buffers 6

#property indicator_color1 LimeGreen

#property indicator_color2 Red

#property indicator_color3 LimeGreen

#property indicator_color4 Red

#property indicator_color5 LimeGreen

#property indicator_color6 Red

#property indicator_width1 2

#property indicator_width2 2

#property indicator_style5 STYLE_DOT

#property indicator_style6 STYLE_DOT

double buffh1[];

double buffl1[];

double buffh2[];

double buffl2[];

double buffh3[];

double buffl3[];

//------------------------------------------------------------------

//

//------------------------------------------------------------------

int init()

{

SetIndexBuffer(0,buffh1);

SetIndexBuffer(1,buffl1);

SetIndexBuffer(2,buffh2);

SetIndexBuffer(3,buffl2);

SetIndexBuffer(4,buffh3);

SetIndexBuffer(5,buffl3);

return(0);

}

int start()

{

int counted_bars=IndicatorCounted();

if(counted_bars<0) return(-1);

if(counted_bars>0) counted_bars--;

int limit = MathMin(Bars-counted_bars,Bars-1);

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

{

int y = iBarShift(NULL,PERIOD_D1,Time);

buffh1 = iHigh(NULL,PERIOD_D1,y+1);

buffl1 = iLow(NULL,PERIOD_D1,y+1);

buffh2 = iHigh(NULL,PERIOD_D1,y+2);

buffl2 = iLow(NULL,PERIOD_D1,y+2);

buffh3 = iHigh(NULL,PERIOD_D1,y+3);

buffl3 = iLow(NULL,PERIOD_D1,y+3);

}

return(0);

}

PS: the thickest line is 1 day ago, the thiner line is 2 days ago and the dotted line is 3 days ago

 

Coding help pls...........

hello all of the expert here , can anyone help me to code the simple EA that will automatic modify last working order 's TP same as current order just open ? let say i have 1 or more working order and few pending order , when pending order become working order , i hope the EA will auto modify the prev working order's TP (target price) to current order just active .. thanks ....

 
jeffyap:
Coding help pls........... hello all of the expert here , can anyone help me to code the simple EA that will automatic modify last working order 's TP same as current order just open ? let say i have 1 or more working order and few pending order , when pending order become working order , i hope the EA will auto modify the prev working order's TP (target price) to current order just active .. thanks ....

Why don't you simply use a normal trailing stop on all orders? That way they will be equalized eventually (if you have multiple orders) without a need to open a new order

 

HI Mladen,

if I want count bars between 2 lows,how can avoid bar of sunday 23.00 p.m to 00.00?

because on 4h chart there is that bar and lasts only one hour.....and it appears also on daily chart.

thank's in advance

Reason: