package jforex.converted;
import java.awt.Color;
import com.dukascopy.api.*;
import com.dukascopy.connector.engine.*; 
import com.dukascopy.connector.engine.Properties; 
import com.dukascopy.connector.engine.IndicatorBuffer;

@RequiresFullAccess 
@Library("C:/Users/FX1/Downloads/MQL4Connector-2.6.38.1.jar")

public class Rads_BZ_Skyline extends ConnectorIndicator {


protected void initProperties() {
if (properties == null) {
properties = new Properties();
}
properties.setProperty("indicator_color5","Red");
properties.setProperty("indicator_buffers","7");
properties.setProperty("indicator_chart_window","true");
properties.setProperty("indicator_color3","Red");
properties.setProperty("indicator_color4","Blue");
properties.setProperty("link","www.forexpertutti.it");
properties.setProperty("indicator_color2","Blue");
properties.setProperty("indicator_color1","White");
properties.setProperty("copyright","Skyline,2008");

}
protected Color indicator_color5 = Red;
protected Color indicator_color3 = Red;
protected Color indicator_color4 = Blue;
protected Color indicator_color2 = Blue;
protected Color indicator_color1 = White;
@Configurable("") public double myEntryTrigger=toDouble(1);
@Configurable("") public double myProfitTarget=toDouble(1);
@Configurable("") public double myStopLoss=toDouble(7);
@Configurable("") public Color myHourColor=toColor(DarkGray);
@Configurable("") public int myStyle=toInt(STYLE_SOLID);
@IndicatorBuffer ("") public double[] OpenLine = new double[0];
@IndicatorBuffer ("") public double[] BuyLine1 = new double[0];
@IndicatorBuffer ("") public double[] BuyLine2 = new double[0];
@IndicatorBuffer ("") public double[] SellLine1 = new double[0];
@IndicatorBuffer ("") public double[] SellLine2 = new double[0];
@IndicatorBuffer ("") public double[] TargetLine1 = new double[0];
@IndicatorBuffer ("") public double[] TargetLine2 = new double[0];

public int init() throws JFException {

SetIndexStyle(0,DRAW_LINE,STYLE_DOT);

SetIndexBuffer(0,OpenLine);

SetIndexStyle(1,DRAW_LINE,STYLE_DOT);

SetIndexBuffer(1,BuyLine1);

SetIndexStyle(2,DRAW_LINE,STYLE_DOT);

SetIndexBuffer(2,SellLine1);

SetIndexStyle(3,DRAW_LINE,STYLE_DOT);

SetIndexBuffer(3,TargetLine1);

SetIndexStyle(4,DRAW_LINE,STYLE_DOT);

SetIndexBuffer(4,TargetLine2);

if(true)return toInt(0);return 0;
}

public int deinit() throws JFException {

if(true)return toInt(0);return 0;
}

public int start() throws JFException {
int counted_bars = 0;
int limit = 0;
double level = 0.0;
int i=toInt(0);
int BarShift = 0;
double OpenH1 = 0.0;

counted_bars = toInt(IndicatorCounted());

if (TimeHour(Time(0))!=TimeHour(Time(1))){

level = toDouble((High(1)+Low(1)+Close(1))/3);

SetTimeLine("HourStart","Hour",0,White,level+10*Point);
}
if (counted_bars>0){

counted_bars--;
}
limit = toInt(Bars-counted_bars);

for(i=(int)0;i<limit;i++){

BarShift = toInt(iBarShift(null,PERIOD_H1,Time(i),true));

OpenH1 = toDouble(iOpen(null,PERIOD_H1,BarShift));

OpenLine[toInt(i)]=toDouble(OpenH1);

BuyLine1[toInt(i)]=toDouble(OpenH1+myEntryTrigger*Point);

SellLine1[toInt(i)]=toDouble(OpenH1-myEntryTrigger*Point);

TargetLine1[toInt(i)]=toDouble(OpenH1+myProfitTarget*Point);

TargetLine2[toInt(i)]=toDouble(OpenH1-myProfitTarget*Point);

}

DisplayText();

if(true)return toInt(0);return 0;
}

public void DisplayText() throws JFException {
double OpenH1 = 0.0;

OpenH1 = toDouble(iOpen(null,PERIOD_H1,0));

ObjectDelete("OpenText");

ObjectDelete("SellEntry");

ObjectDelete("BuyEntry");

ObjectDelete("ProfitTarget1");

ObjectDelete("ProfitTarget2");
return ;
}

public void SetTimeLine(Object objname, Object text, Number idx, Color col1, Number vleveltext) throws JFException {
 if(objname==null) {
objname=Instrument();
}

 if(text==null) {
text=Instrument();
}
SetTimeLine(objname.toString(), text.toString(), idx.intValue(), col1, vleveltext.doubleValue());}
public void SetTimeLine(Object objname, Object text, boolean idx, Color col1, Number vleveltext) throws JFException {
SetTimeLine(objname.toString(), text.toString(), toInt(idx), col1, vleveltext.doubleValue());}
public void SetTimeLine(Object objname, Object text, Number idx, Color col1, boolean vleveltext) throws JFException {
SetTimeLine(objname.toString(), text.toString(), idx.intValue(), col1, toDouble(vleveltext));}
public void SetTimeLine(Object objname, Object text, boolean idx, Color col1, boolean vleveltext) throws JFException {
SetTimeLine(objname.toString(), text.toString(), toInt(idx), col1, toDouble(vleveltext));}
public void SetTimeLine(String objname, String text, int idx, Color col1, double vleveltext) throws JFException {
String name = "";
int x = 0;

name = toString("[PIVOT] "+objname);

x = toInt(Time(idx));

if (ObjectFind(name)!=0){

ObjectCreate(name,OBJ_TREND,0,x,0,x,100);

} else {
ObjectMove(name,0,x,0);

ObjectMove(name,1,x,100);

}
ObjectSet(name,OBJPROP_STYLE,myStyle);

ObjectSet(name,OBJPROP_COLOR,myHourColor);

if (ObjectFind(name+" Label")!=0){

ObjectCreate(name+" Label",OBJ_TEXT,0,x,vleveltext);

} else {
ObjectMove(name+" Label",0,x,vleveltext);

}
ObjectSetText(name+" Label",text,8,"Arial",col1);
return ;
}


/**/};