|
|
@@ -24,6 +24,8 @@ int index_of_low = 0;
|
|
|
int index_of_high = 0;
|
|
|
int high_index=0;
|
|
|
double high,low,low1,high1;
|
|
|
+
|
|
|
+bool choch = false;
|
|
|
//+------------------------------------------------------------------+
|
|
|
//| Expert initialization function |
|
|
|
//+------------------------------------------------------------------+
|
|
|
@@ -109,28 +111,52 @@ void foo(int index)
|
|
|
{
|
|
|
// print("hi");
|
|
|
double close = iClose(Symbol(),PERIOD_CURRENT,l);
|
|
|
+ double low3 = iLow(Symbol(),PERIOD_CURRENT,l);
|
|
|
|
|
|
if(close < low)
|
|
|
{
|
|
|
double price_low = iLow(Symbol(),PERIOD_CURRENT,l+1);
|
|
|
- double time = iTime(Symbol(),PERIOD_CURRENT,l+1);
|
|
|
- double time1 = iTime(Symbol(),PERIOD_CURRENT,l-1);
|
|
|
- ObjectCreate(0,"tline1",OBJ_TREND,0,time,price_low,time1,price_low);
|
|
|
+ datetime time = iTime(Symbol(),PERIOD_CURRENT,l+1);
|
|
|
+ datetime time1 = iTime(Symbol(),PERIOD_CURRENT,l-1);
|
|
|
+ //ObjectCreate(0,"tline1",OBJ_TREND,0,time,price_low,time1,price_low);
|
|
|
trend = "downtrend";
|
|
|
Print("choch");
|
|
|
index_of_last_high = i;
|
|
|
Print("close", close);
|
|
|
+ choch = true;
|
|
|
+ break;
|
|
|
+
|
|
|
+ }
|
|
|
+ if(low3 < low)
|
|
|
+ {
|
|
|
+ double price_low = iLow(Symbol(),PERIOD_CURRENT,l+1);
|
|
|
+ datetime time = iTime(Symbol(),PERIOD_CURRENT,l+1);
|
|
|
+ datetime time1 = iTime(Symbol(),PERIOD_CURRENT,l-1);
|
|
|
+ //ObjectCreate(0,"tline1",OBJ_TREND,0,time,price_low,time1,price_low);
|
|
|
+ trend = "downtrend";
|
|
|
+ Print("choch in condition 3");
|
|
|
+ index_of_last_high = i;
|
|
|
+ Print("close", close);
|
|
|
+ choch = true;
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- Print("index of last updated high is : ",index_of_last_high);
|
|
|
- hi = iHigh(Symbol(),PERIOD_CURRENT,index_of_last_high+1);
|
|
|
- lo = iLow(Symbol(),PERIOD_CURRENT,index_of_last_high+1);
|
|
|
+ if(choch == true)
|
|
|
+ {
|
|
|
+ hi = iHigh(Symbol(),PERIOD_CURRENT,index_of_last_high+1);
|
|
|
+ lo = iLow(Symbol(),PERIOD_CURRENT,index_of_last_high+1);
|
|
|
+
|
|
|
+ Print(" buy and sell high index is ",index_of_last_high+1);
|
|
|
+ Print(" high price is ", hi);
|
|
|
+ Print(" low price is ", lo);
|
|
|
+
|
|
|
+ hi = 0.0;
|
|
|
+ lo =0.0;
|
|
|
+ choch = false;
|
|
|
+ }
|
|
|
|
|
|
- Print("hy",hi, "index is : ",index_of_last_high+1);
|
|
|
- Print("ho",lo);
|
|
|
|
|
|
index = i;
|
|
|
|
|
|
@@ -197,7 +223,7 @@ void foo(int index)
|
|
|
{
|
|
|
|
|
|
high1 = iHigh(Symbol(),PERIOD_CURRENT,index - k);
|
|
|
- if(high1 > high)
|
|
|
+ if(high1 >= high)
|
|
|
{
|
|
|
//Print("here");
|
|
|
high = high1;
|
|
|
@@ -218,28 +244,64 @@ void foo(int index)
|
|
|
{
|
|
|
// print("hi");
|
|
|
double close = iClose(Symbol(),PERIOD_CURRENT,l);
|
|
|
+ double high3 = iHigh(Symbol(),PERIOD_CURRENT,l);
|
|
|
+
|
|
|
if(close > high)
|
|
|
{
|
|
|
|
|
|
double price_high = iLow(Symbol(),PERIOD_CURRENT,l+1);
|
|
|
- double time = iTime(Symbol(),PERIOD_CURRENT,l+1);
|
|
|
- double time1 = iTime(Symbol(),PERIOD_CURRENT,l-1);
|
|
|
- bool a = ObjectCreate(0,"tline2",OBJ_TREND,0,time,price_high,time1,price_high);
|
|
|
- Print("object created : ", a);
|
|
|
+ datetime time = iTime(Symbol(),PERIOD_CURRENT,l+1);
|
|
|
+ datetime time1 = iTime(Symbol(),PERIOD_CURRENT,l-1);
|
|
|
+ //ObjectCreate(0,"tline2",OBJ_TREND,0,time,price_high,time1,price_high);
|
|
|
+
|
|
|
|
|
|
trend = "uptrend";
|
|
|
Print("choch");
|
|
|
Print(l);
|
|
|
index_of_last_low = i;
|
|
|
Print("close", close);
|
|
|
+ choch = true;
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
+ if(high3 > high)
|
|
|
+ {
|
|
|
+
|
|
|
+ double price_high = iLow(Symbol(),PERIOD_CURRENT,l+1);
|
|
|
+ datetime time = iTime(Symbol(),PERIOD_CURRENT,l+1);
|
|
|
+ datetime time1 = iTime(Symbol(),PERIOD_CURRENT,l-1);
|
|
|
+ // ObjectCreate(0,"tline2",OBJ_TREND,0,time,price_high,time1,price_high);
|
|
|
+
|
|
|
+
|
|
|
+ trend = "uptrend";
|
|
|
+ Print("choch in condition 3");
|
|
|
+ Print(l);
|
|
|
+ index_of_last_low = i;
|
|
|
+ Print("close", close);
|
|
|
+ choch = true;
|
|
|
+ break;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
- hi = iHigh(Symbol(),PERIOD_CURRENT,index_of_last_low+1);
|
|
|
- lo = iLow(Symbol(),PERIOD_CURRENT,index_of_last_low+1);
|
|
|
+ if(choch == true)
|
|
|
+ {
|
|
|
+
|
|
|
+ hi = iHigh(Symbol(),PERIOD_CURRENT,index_of_last_low+1);
|
|
|
+ lo = iLow(Symbol(),PERIOD_CURRENT,index_of_last_low+1);
|
|
|
+
|
|
|
+ Print(" buy and sell high index is ",index_of_last_low+1);
|
|
|
+ Print(" high price is ", hi);
|
|
|
+ Print(" low price is ", lo);
|
|
|
|
|
|
+ hi = 0.0;
|
|
|
+ lo =0.0;
|
|
|
+ choch = false;
|
|
|
+ }
|
|
|
index = i;
|
|
|
|
|
|
}
|
|
|
@@ -266,10 +328,10 @@ int OnInit()
|
|
|
|
|
|
datetime time_of_candle = (datetime)ObjectGetInteger(0,"line",OBJPROP_TIME,0);
|
|
|
|
|
|
- Print("line time: ",time_of_candle);
|
|
|
+ // Print("line time: ",time_of_candle);
|
|
|
int index = iBarShift(Symbol(), PERIOD_CURRENT, time_of_candle, false);
|
|
|
- Print(index);
|
|
|
- Print(index);
|
|
|
+ //Print(index);
|
|
|
+ // Print(index);
|
|
|
|
|
|
// datetime time_of_candle = (datetime)ObjectGetInteger(0,"line",OBJPROP_TIME,0);
|
|
|
// Print("time is " , time_of_candle);
|
|
|
@@ -285,8 +347,6 @@ int OnInit()
|
|
|
Print("Object Not Found");
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
return(INIT_SUCCEEDED);
|
|
|
}
|
|
|
//+------------------------------------------------------------------+
|
|
|
@@ -312,7 +372,6 @@ void OnTick()
|
|
|
|
|
|
}
|
|
|
|
|
|
-
|
|
|
//+------------------------------------------------------------------+
|
|
|
//| |
|
|
|
//+------------------------------------------------------------------+
|
|
|
@@ -365,53 +424,3 @@ string checkCandle(int i) // to check the candle is bullish or bearish
|
|
|
//+------------------------------------------------------------------+
|
|
|
|
|
|
//+------------------------------------------------------------------+
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-/////////////////////////////////////
|
|
|
-//void third condition()
|
|
|
-// {
|
|
|
-// if(checkCandle(index) == "Bearish")
|
|
|
-// {
|
|
|
-//
|
|
|
-// trend = "downtrend";
|
|
|
-//
|
|
|
-// // double high,low = 0.0;
|
|
|
-//
|
|
|
-// // to store high and low of the value after the object
|
|
|
-// low = iLow(Symbol(),PERIOD_CURRENT,index);
|
|
|
-//
|
|
|
-// //low = iLow(Symbol(),PERIOD_CURRENT,index-1);
|
|
|
-//
|
|
|
-// if(trend == "downtrend")
|
|
|
-// {
|
|
|
-//
|
|
|
-// low1 = iLow(Symbol(),PERIOD_CURRENT,i);
|
|
|
-//
|
|
|
-//
|
|
|
-// if(low1 < low)
|
|
|
-// {
|
|
|
-// low = low1;
|
|
|
-// for(int l=i; l > 0; l--)
|
|
|
-// {
|
|
|
-// // print("hi");
|
|
|
-// double high2 = iHigh(Symbol(),PERIOD_CURRENT,l);
|
|
|
-// if(high2 > high)
|
|
|
-// {
|
|
|
-//
|
|
|
-// high = high2;
|
|
|
-//
|
|
|
-// }
|
|
|
-//
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// }
|
|
|
-// //
|
|
|
-// }
|
|
|
-//
|
|
|
-// }
|
|
|
-//+------------------------------------------------------------------+
|