I used this code to draw a horizontal line where Ichimoku SpanB goes flat :
//--- input parameters of the scriptinputstring InpName="HLine"; // Line nameinputint InpPrice=25; // Line price, %inputcolor InpColor=clrRed; // Line colorinputENUM_LINE_STYLE InpStyle=STYLE_SOLID;// Line styleinputint InpWidth=2; // Line widthinputbool InpBack=false; // Background lineinputbool InpSelection=false; // Highlight to moveinputbool InpHidden=true; // Hidden in the object listinputlong InpZOrder=0; // Priority for mouse click//+------------------------------------------------------------------+//| Create the horizontal line |//+------------------------------------------------------------------+bool HLineCreate(constlong chart_ID=0, // chart's IDconststring name="HLine", // line nameconstint sub_window=0, // subwindow indexdouble price=0, // line priceconstcolor clr=clrRed, // line colorconstENUM_LINE_STYLE style=STYLE_SOLID, // line styleconstint width=2, // line widthconstbool back=false, // in the backgroundconstbool selection=false, // highlight to moveconstbool hidden=true, // hidden in the object listconstlong z_order=0) // priority for mouse click
{
//--- if the price is not set, set it at the current Bid price levelif(!price)
price=SymbolInfoDouble(Symbol(),SYMBOL_BID);
//--- reset the error valueResetLastError();
//--- create a horizontal lineif(!ObjectCreate(chart_ID,name,OBJ_HLINE,sub_window,0,price))
{
Print(__FUNCTION__,
": failed to create a horizontal line! Error code = ",GetLastError());
return(false);
}
//--- set line colorObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr);
//--- set line display styleObjectSetInteger(chart_ID,name,OBJPROP_STYLE,style);
//--- set line widthObjectSetInteger(chart_ID,name,OBJPROP_WIDTH,width);
//--- display in the foreground (false) or background (true)ObjectSetInteger(chart_ID,name,OBJPROP_BACK,back);
//--- enable (true) or disable (false) the mode of moving the line by mouse//--- when creating a graphical object using ObjectCreate function, the object cannot be//--- highlighted and moved by default. Inside this method, selection parameter//--- is true by default making it possible to highlight and move the objectObjectSetInteger(chart_ID,name,OBJPROP_SELECTABLE,selection);
ObjectSetInteger(chart_ID,name,OBJPROP_SELECTED,selection);
//--- hide (true) or display (false) graphical object name in the object listObjectSetInteger(chart_ID,name,OBJPROP_HIDDEN,hidden);
//--- set the priority for receiving the event of a mouse click in the chartObjectSetInteger(chart_ID,name,OBJPROP_ZORDER,z_order);
//--- successful executionreturn(true);
}
//+------------------------------------------------------------------+//| Move horizontal line |//+------------------------------------------------------------------+bool HLineMove(constlong chart_ID=0, // chart's IDconststring name="HLine", // line namedouble price=0) // line price
{
//--- if the line price is not set, move it to the current Bid price levelif(!price)
price=SymbolInfoDouble(Symbol(),SYMBOL_BID);
//--- reset the error valueResetLastError();
//--- move a horizontal line
price = PR;
if(!ObjectMove(chart_ID,name,0,0,price))
{
Print(__FUNCTION__,
": failed to move the horizontal line! Error code = ",GetLastError());
return(false);
}
//--- successful executionreturn(true);
}
//+------------------------------------------------------------------+//| Delete a horizontal line |//+------------------------------------------------------------------+bool HLineDelete(constlong chart_ID=0, // chart's IDconststring name="HLine") // line name
{
//--- reset the error valueResetLastError();
//--- delete a horizontal lineif(!ObjectDelete(chart_ID,name))
{
Print(__FUNCTION__,
": failed to delete a horizontal line! Error code = ",GetLastError());
return(false);
}
//--- successful executionreturn(true);
}
datetime alert[4];
int sendb,sends;
double Spread = MarketInfo(_Symbol, MODE_SPREAD);
double SLB,SLS,TPB,TPS;
//+------------------------------------------------------------------+//| Expert initialization function |//+------------------------------------------------------------------+intOnInit()
{
alert[0]= 0;
alert[1]= 0;
alert[2]= 0;
alert[3]= 0;
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+//| |//+------------------------------------------------------------------+voidOnTick()
{
double SenkouspanBH126 = iIchimoku(NULL,PERIOD_H1,9,26,52,MODE_SENKOUSPANB,-26);
double SenkouspanBH125 = iIchimoku(NULL,PERIOD_H1,9,26,52,MODE_SENKOUSPANB,-25);
if(SenkouspanBH126 == SenkouspanBH125)
{
PR = SenkouspanBH126;
}
else
{
PRN = SenkouspanBH126;
}
//--- check correctness of the input parametersif(InpPrice<0 || InpPrice>100)
{
Print("Error! Incorrect values of input parameters!");
return;
}
//--- price array sizeint accuracy=1000;
//--- array for storing the price values to be used//--- for setting and changing line anchor point's coordinatesdouble price[];
//--- memory allocationArrayResize(price,accuracy);
//--- fill the array of prices//--- find the highest and lowest values of the chartdouble max_price=ChartGetDouble(0,CHART_PRICE_MAX);
double min_price=ChartGetDouble(0,CHART_PRICE_MIN);
//--- define a change step of a price and fill the arraydouble step=(max_price-min_price)/accuracy;
for(int i=0; i<accuracy; i++)
price[i]=min_price+i*step;
//--- define points for drawing the lineint p=InpPrice*(accuracy-1)/100;
//--- create a horizontal lineif(!HLineCreate(0,InpName,0,price[p],InpColor,InpStyle,InpWidth,InpBack,
InpSelection,InpHidden,InpZOrder))
{
return;
}
//--- redraw the chart and wait for 1 secondChartRedraw();
Sleep(1000);
//--- now, move the line//--- loop counterint v_steps=accuracy/2;
//--- move the linefor(int i=0; i<v_steps; i++)
{
//--- use the following valueif(p < accuracy-1)
p+=1;
//--- move the pointif(!HLineMove(0,InpName,price[p]))
return;
//--- check if the script's operation has been forcefully disabledif(IsStopped())
return;
//--- redraw the chartChartRedraw();
}
//--- 1 second of delaySleep(1000);
//--- delete from the chart
HLineDelete(0,InpName);
ChartRedraw();
//--- 1 second of delaySleep(1000);
//---
I don't know how to make it work in all time frames. I mean I need it to recognize last flats in all time frames and draw the price line that you can see all 9 lines (M1,M5,M15,M30,H1,H4,D1,W1,MN1) on every opened chart. I used :
to determine if the SpanB is flat or not. In backtest and fastest mode, I can see that it works fine but when I change the speed to slower,the line is deleted.
Hello guys
I used this code to draw a horizontal line where Ichimoku SpanB goes flat :
I don't know how to make it work in all time frames. I mean I need it to recognize last flats in all time frames and draw the price line that you can see all 9 lines (M1,M5,M15,M30,H1,H4,D1,W1,MN1) on every opened chart. I used :
if(SenkouspanBH126 == SenkouspanBH125) { PR = SenkouspanBH126; }to determine if the SpanB is flat or not. In backtest and fastest mode, I can see that it works fine but when I change the speed to slower,the line is deleted.
Please someone help me
I am amateur.
Thanks