|
@@ -22,9 +22,14 @@ double lo;
|
|
|
|
|
|
|
|
int index_of_low = 0;
|
|
int index_of_low = 0;
|
|
|
int index_of_high = 0;
|
|
int index_of_high = 0;
|
|
|
|
|
+
|
|
|
int high_index=0;
|
|
int high_index=0;
|
|
|
double high,low,low1,high1;
|
|
double high,low,low1,high1;
|
|
|
|
|
|
|
|
|
|
+int Store_last_index_of_high = 0;
|
|
|
|
|
+int Store_last_index_of_low = 0;
|
|
|
|
|
+//int ind = 0;
|
|
|
|
|
+
|
|
|
bool choch = false;
|
|
bool choch = false;
|
|
|
//+------------------------------------------------------------------+
|
|
//+------------------------------------------------------------------+
|
|
|
//| Expert initialization function |
|
|
//| Expert initialization function |
|
|
@@ -35,281 +40,534 @@ void foo(int index)
|
|
|
for(int i=index; i > 0; i--)
|
|
for(int i=index; i > 0; i--)
|
|
|
{
|
|
{
|
|
|
|
|
|
|
|
- if(checkCandle(index) == "Bullish")
|
|
|
|
|
|
|
+ //ind = index;
|
|
|
|
|
+
|
|
|
|
|
+ if(trend == "uptrend")
|
|
|
{
|
|
{
|
|
|
|
|
+ high = iHigh(Symbol(),PERIOD_CURRENT,index);
|
|
|
|
|
|
|
|
- trend = "uptrend";
|
|
|
|
|
|
|
+ high1 = iHigh(Symbol(),PERIOD_CURRENT,i);
|
|
|
|
|
|
|
|
- //double high,low = 0.0;
|
|
|
|
|
|
|
+ if(high1 > high)
|
|
|
|
|
+ {
|
|
|
|
|
+ Store_last_index_of_high = i;
|
|
|
|
|
|
|
|
- // to store high and low of the value after the object
|
|
|
|
|
- high = iHigh(Symbol(),PERIOD_CURRENT,index);
|
|
|
|
|
|
|
+ high = high1;
|
|
|
|
|
|
|
|
- //low = iLow(Symbol(),PERIOD_CURRENT,index-1);
|
|
|
|
|
|
|
|
|
|
|
|
+ int count = (index-1) - i;
|
|
|
|
|
|
|
|
- if(trend == "uptrend")
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ //Print("count",count);
|
|
|
|
|
|
|
|
- high1 = iHigh(Symbol(),PERIOD_CURRENT,i);
|
|
|
|
|
|
|
+ for(int j=1; j < count; j++)
|
|
|
|
|
+ {
|
|
|
|
|
|
|
|
- //double low1 = iLow(Symbol(),PERIOD_CURRENT,i);
|
|
|
|
|
|
|
+ if(checkCandle(index-j) == "Bearish")
|
|
|
|
|
+ {
|
|
|
|
|
|
|
|
- if(high1 > high)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ low = iLow(Symbol(),PERIOD_CURRENT,index-j);
|
|
|
|
|
+ bearish_found = true;
|
|
|
|
|
|
|
|
- high = high1;
|
|
|
|
|
|
|
+ //Print("bearish is found at index ",index-j);
|
|
|
|
|
|
|
|
- // Print("high break at index value",i);
|
|
|
|
|
- // Print("index is ",index);
|
|
|
|
|
|
|
|
|
|
- int count = (index-1) - i;
|
|
|
|
|
- Print("index is : : ", i);
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- // Print("index updated ",index);
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- // Print("count",count);
|
|
|
|
|
|
|
+ if(bearish_found == true)
|
|
|
|
|
+ {
|
|
|
|
|
|
|
|
- for(int j=1; j <= count; j++)
|
|
|
|
|
|
|
+ for(int k=1; k <= count; k++)
|
|
|
{
|
|
{
|
|
|
|
|
|
|
|
- if(checkCandle(index-j) == "Bearish")
|
|
|
|
|
|
|
+ low1 = iLow(Symbol(),PERIOD_CURRENT,index - k);
|
|
|
|
|
+ if(low1 <= low)
|
|
|
{
|
|
{
|
|
|
- low = iLow(Symbol(),PERIOD_CURRENT,index-j);
|
|
|
|
|
- bearish_found = true;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ //Print("here");
|
|
|
|
|
+ low = low1;
|
|
|
|
|
+ index_of_low =index- k;
|
|
|
|
|
+ Print("low update due to 2 condition : ",index- k);
|
|
|
|
|
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
+ bearish_found = false;
|
|
|
|
|
|
|
|
- if(bearish_found == true)
|
|
|
|
|
- {
|
|
|
|
|
- //double low1 ;
|
|
|
|
|
- //Print("where");
|
|
|
|
|
- for(int k=1; k <= count; k++)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- low1 = iLow(Symbol(),PERIOD_CURRENT,index - k);
|
|
|
|
|
- if(low1 <= low)
|
|
|
|
|
- {
|
|
|
|
|
- //Print("here");
|
|
|
|
|
- low = low1;
|
|
|
|
|
- index_of_low = index - k;
|
|
|
|
|
- Print("low is updated at index : ",index - k);
|
|
|
|
|
|
|
+ Print(" high price is ", high);
|
|
|
|
|
+ Print("low price is ", low);
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- bearish_found = false;
|
|
|
|
|
|
|
+ Print("index of last updated low is ", index_of_low);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ Print("index value is re", index);
|
|
|
|
|
+ Print("ith value is ",i);
|
|
|
|
|
+ index = i;
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
- Print(" high price is ", high);
|
|
|
|
|
|
|
+ // Print("index is ", i);
|
|
|
|
|
|
|
|
- Print("low price is ", low);
|
|
|
|
|
- Print("index of last updated low is ", index_of_low);
|
|
|
|
|
|
|
+ for(int l=index_of_low; l > 0; l--)
|
|
|
|
|
+ {
|
|
|
|
|
+ // Print(l);
|
|
|
|
|
+ // Print("index of low ", index_of_low," to check ", index);
|
|
|
|
|
+
|
|
|
|
|
+ double close = iClose(Symbol(),PERIOD_CURRENT,l);
|
|
|
|
|
+ double low3 = iLow(Symbol(),PERIOD_CURRENT,l);
|
|
|
|
|
|
|
|
- for(int l=index_of_low; l > 0; l--)
|
|
|
|
|
|
|
+ if(close < low)
|
|
|
{
|
|
{
|
|
|
- // 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);
|
|
|
|
|
- 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;
|
|
|
|
|
|
|
+ //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);
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
- 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;
|
|
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
- if(choch == true)
|
|
|
|
|
- {
|
|
|
|
|
- hi = iHigh(Symbol(),PERIOD_CURRENT,index_of_last_high+1);
|
|
|
|
|
- lo = iLow(Symbol(),PERIOD_CURRENT,index_of_last_high+1);
|
|
|
|
|
|
|
+ low = iLow(Symbol(),PERIOD_CURRENT,l);
|
|
|
|
|
+ trend = "downtrend";
|
|
|
|
|
+
|
|
|
|
|
+ index_of_last_high = Store_last_index_of_high;
|
|
|
|
|
+ Print("choch at index --------------------------------------------------------------------------------------- ", l);
|
|
|
|
|
|
|
|
- Print(" buy and sell high index is ",index_of_last_high+1);
|
|
|
|
|
- Print(" high price is ", hi);
|
|
|
|
|
- Print(" low price is ", lo);
|
|
|
|
|
|
|
+ choch = true;
|
|
|
|
|
+ break;
|
|
|
|
|
|
|
|
- hi = 0.0;
|
|
|
|
|
- lo =0.0;
|
|
|
|
|
- choch = false;
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ if(low3 < low)
|
|
|
|
|
+ {
|
|
|
|
|
+ low = low3;
|
|
|
|
|
+ Print("low update due to third condition",low);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ if(choch == true)
|
|
|
|
|
+ {
|
|
|
|
|
+ Print("here we are",index_of_last_high+1);
|
|
|
|
|
+ hi = iHigh(Symbol(),PERIOD_CURRENT,index_of_last_high+1);
|
|
|
|
|
+ datetime ti = iTime(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);
|
|
|
|
|
+ ObjectCreate(0,"line111"+iTime(Symbol(),PERIOD_CURRENT,index_of_last_high+1),OBJ_HLINE,0,ti,hi);
|
|
|
|
|
+ ObjectCreate(0,"line12"+iTime(Symbol(),PERIOD_CURRENT,index_of_last_high+1),OBJ_HLINE,0,ti,lo);
|
|
|
|
|
|
|
|
- index = i;
|
|
|
|
|
|
|
|
|
|
|
|
+ hi = 0.0;
|
|
|
|
|
+ lo =0.0;
|
|
|
|
|
+ choch = false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
- //
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
- if(checkCandle(index) == "Bearish")
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- trend = "downtrend";
|
|
|
|
|
|
|
|
|
|
- // double high,low = 0.0;
|
|
|
|
|
|
|
+ if(trend == "downtrend")
|
|
|
|
|
+ {
|
|
|
|
|
|
|
|
- // to store high and low of the value after the object
|
|
|
|
|
low = iLow(Symbol(),PERIOD_CURRENT,index);
|
|
low = iLow(Symbol(),PERIOD_CURRENT,index);
|
|
|
|
|
|
|
|
- //low = iLow(Symbol(),PERIOD_CURRENT,index-1);
|
|
|
|
|
|
|
+ low1 = iLow(Symbol(),PERIOD_CURRENT,i);
|
|
|
|
|
|
|
|
- if(trend == "downtrend")
|
|
|
|
|
|
|
+ if(low1 < low)
|
|
|
{
|
|
{
|
|
|
|
|
+ Store_last_index_of_low = i;
|
|
|
|
|
|
|
|
|
|
+ low = low1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ int count = (index-1) - i;
|
|
|
|
|
|
|
|
- low1 = iLow(Symbol(),PERIOD_CURRENT,i);
|
|
|
|
|
|
|
+ //Print("count",count);
|
|
|
|
|
|
|
|
- //double low1 = iLow(Symbol(),PERIOD_CURRENT,i);
|
|
|
|
|
-
|
|
|
|
|
- if(low1 < low)
|
|
|
|
|
|
|
+ for(int j=1; j < count; j++)
|
|
|
{
|
|
{
|
|
|
- low = low1;
|
|
|
|
|
|
|
|
|
|
- // Print("high break at index value",i);
|
|
|
|
|
- // Print("index is ",index);
|
|
|
|
|
|
|
+ if(checkCandle(index-j) == "Bullish")
|
|
|
|
|
+ {
|
|
|
|
|
|
|
|
- int count = (index-1) - i;
|
|
|
|
|
- Print("count is ", count);
|
|
|
|
|
|
|
+ high = iHigh(Symbol(),PERIOD_CURRENT,index-j);
|
|
|
|
|
+ bullish_found = true;
|
|
|
|
|
|
|
|
- // Print("index updated ",index);
|
|
|
|
|
|
|
+ //Print("bearish is found at index ",index-j);
|
|
|
|
|
|
|
|
- // Print("count",count);
|
|
|
|
|
|
|
|
|
|
- for(int j=1; j <= count; j++)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- if(checkCandle(index-j) == "Bullish")
|
|
|
|
|
- {
|
|
|
|
|
- high = iHigh(Symbol(),PERIOD_CURRENT,index-j);
|
|
|
|
|
- bullish_found = true;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if(bullish_found == true)
|
|
|
|
|
+ {
|
|
|
|
|
|
|
|
- if(bullish_found == true)
|
|
|
|
|
|
|
+ for(int k=1; k <= count; k++)
|
|
|
{
|
|
{
|
|
|
- high1;
|
|
|
|
|
- //Print("where");
|
|
|
|
|
- for(int k=1; k <= count; k++)
|
|
|
|
|
- {
|
|
|
|
|
|
|
|
|
|
- high1 = iHigh(Symbol(),PERIOD_CURRENT,index - k);
|
|
|
|
|
- if(high1 >= high)
|
|
|
|
|
- {
|
|
|
|
|
- //Print("here");
|
|
|
|
|
- high = high1;
|
|
|
|
|
- index_of_high = index - k;
|
|
|
|
|
- Print("high is updated at index : ",index - k);
|
|
|
|
|
|
|
+ high1 = iHigh(Symbol(),PERIOD_CURRENT,index - k);
|
|
|
|
|
+ if(high1 >= high)
|
|
|
|
|
+ {
|
|
|
|
|
+ //Print("here");
|
|
|
|
|
+ high = high1;
|
|
|
|
|
+ index_of_high =index- k;
|
|
|
|
|
+ Print("high update due to 2 condition : ",index- k);
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|
|
|
- bullish_found = false;
|
|
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+ bearish_found = false;
|
|
|
|
|
|
|
|
- Print(" high price is ", high);
|
|
|
|
|
- Print("low price is ", low);
|
|
|
|
|
- Print("index of last updated high is ", index_of_high);
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- for(int l=index_of_high; l > 0; l--)
|
|
|
|
|
- {
|
|
|
|
|
- // print("hi");
|
|
|
|
|
- double close = iClose(Symbol(),PERIOD_CURRENT,l);
|
|
|
|
|
- double high3 = iHigh(Symbol(),PERIOD_CURRENT,l);
|
|
|
|
|
|
|
+ Print(" high price is ", high);
|
|
|
|
|
+ Print("low price is ", low);
|
|
|
|
|
|
|
|
- if(close > high)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ Print("index of last updated high is ", index_of_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);
|
|
|
|
|
|
|
|
|
|
|
|
+ Print("index value is re", index);
|
|
|
|
|
+ Print("ith value is ",i);
|
|
|
|
|
+ index = i;
|
|
|
|
|
|
|
|
- trend = "uptrend";
|
|
|
|
|
- Print("choch");
|
|
|
|
|
- Print(l);
|
|
|
|
|
- index_of_last_low = i;
|
|
|
|
|
- Print("close", close);
|
|
|
|
|
- choch = true;
|
|
|
|
|
- break;
|
|
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // Print("index is ", i);
|
|
|
|
|
|
|
|
- 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);
|
|
|
|
|
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ for(int l=index_of_high; l > 0; l--)
|
|
|
|
|
+ {
|
|
|
|
|
+ //Print(l);
|
|
|
|
|
+ //Print("index of low ", index_of_high," to check ", index);
|
|
|
|
|
|
|
|
- trend = "uptrend";
|
|
|
|
|
- Print("choch in condition 3");
|
|
|
|
|
- Print(l);
|
|
|
|
|
- index_of_last_low = i;
|
|
|
|
|
- Print("close", close);
|
|
|
|
|
- choch = true;
|
|
|
|
|
- break;
|
|
|
|
|
|
|
+ double close = iClose(Symbol(),PERIOD_CURRENT,l);
|
|
|
|
|
+ double high3 = iHigh(Symbol(),PERIOD_CURRENT,l);
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if(close > high)
|
|
|
|
|
+ {
|
|
|
|
|
|
|
|
|
|
+ //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);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ high = iHigh(Symbol(),PERIOD_CURRENT,l);
|
|
|
|
|
+ trend = "uptrend";
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
- if(choch == true)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ index_of_last_low = Store_last_index_of_low;
|
|
|
|
|
+ Print("choch at index ", l);
|
|
|
|
|
|
|
|
- hi = iHigh(Symbol(),PERIOD_CURRENT,index_of_last_low+1);
|
|
|
|
|
- lo = iLow(Symbol(),PERIOD_CURRENT,index_of_last_low+1);
|
|
|
|
|
|
|
+ choch = true;
|
|
|
|
|
+ break;
|
|
|
|
|
|
|
|
- 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;
|
|
|
|
|
|
|
+ if(high3 > high)
|
|
|
|
|
+ {
|
|
|
|
|
|
|
|
|
|
+ high = high3;
|
|
|
|
|
+ Print("high update due to third condition",high);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
- //
|
|
|
|
|
|
|
+ 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;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ // if(trend == "downtrend")
|
|
|
|
|
+ // {
|
|
|
|
|
+ // low = iLow(Symbol(),PERIOD_CURRENT,index);
|
|
|
|
|
+ //
|
|
|
|
|
+ // low1 = iLow(Symbol(),PERIOD_CURRENT,i);
|
|
|
|
|
+ //
|
|
|
|
|
+ // if(low1 < low)
|
|
|
|
|
+ // {
|
|
|
|
|
+ // Store_last_index_of_low = i;
|
|
|
|
|
+ //
|
|
|
|
|
+ // low = low1;
|
|
|
|
|
+ //
|
|
|
|
|
+ //
|
|
|
|
|
+ // int count = (index-1) - i;
|
|
|
|
|
+ //
|
|
|
|
|
+ // //Print("count",count);
|
|
|
|
|
+ //
|
|
|
|
|
+ // for(int j=1; j < count; j++)
|
|
|
|
|
+ // {
|
|
|
|
|
+ //
|
|
|
|
|
+ // if(checkCandle(index-j) == "Bullish")
|
|
|
|
|
+ // {
|
|
|
|
|
+ //
|
|
|
|
|
+ // high = iHigh(Symbol(),PERIOD_CURRENT,index-j);
|
|
|
|
|
+ // bullish_found = true;
|
|
|
|
|
+ //
|
|
|
|
|
+ // //Print("bearish is found at index ",index-j);
|
|
|
|
|
+ //
|
|
|
|
|
+ //
|
|
|
|
|
+ // }
|
|
|
|
|
+ //
|
|
|
|
|
+ // }
|
|
|
|
|
+ //
|
|
|
|
|
+ // if(bullish_found == true)
|
|
|
|
|
+ // {
|
|
|
|
|
+ //
|
|
|
|
|
+ // for(int k=1; k < count; k++)
|
|
|
|
|
+ // {
|
|
|
|
|
+ //
|
|
|
|
|
+ // high1 = iHigh(Symbol(),PERIOD_CURRENT,index - k);
|
|
|
|
|
+ // if(high1 >= high)
|
|
|
|
|
+ // {
|
|
|
|
|
+ //
|
|
|
|
|
+ // high = high1;
|
|
|
|
|
+ // index_of_high =index- k;
|
|
|
|
|
+ // Print(" high update due to 2 condition : ",index- k);
|
|
|
|
|
+ //
|
|
|
|
|
+ // }
|
|
|
|
|
+ // }
|
|
|
|
|
+ // bullish_found = false;
|
|
|
|
|
+ //
|
|
|
|
|
+ // }
|
|
|
|
|
+ //
|
|
|
|
|
+ // Print(" high price is ", high);
|
|
|
|
|
+ // Print("low price is ", low);
|
|
|
|
|
+ //
|
|
|
|
|
+ // Print("index of last updated high is ", index_of_high);
|
|
|
|
|
+ //
|
|
|
|
|
+ //
|
|
|
|
|
+ //
|
|
|
|
|
+ // index = i;
|
|
|
|
|
+ //
|
|
|
|
|
+ //
|
|
|
|
|
+ // // Print("index is ", i);
|
|
|
|
|
+ //
|
|
|
|
|
+ //
|
|
|
|
|
+ //
|
|
|
|
|
+ //
|
|
|
|
|
+ // }
|
|
|
|
|
+ //
|
|
|
|
|
+ //
|
|
|
|
|
+ // for(int l=index_of_high; l >= index; l--)
|
|
|
|
|
+ // {
|
|
|
|
|
+ // // print("hi");
|
|
|
|
|
+ // double close = iClose(Symbol(),PERIOD_CURRENT,l);
|
|
|
|
|
+ // double high3 = iHigh(Symbol(),PERIOD_CURRENT,l);
|
|
|
|
|
+ //
|
|
|
|
|
+ // if(close > high)
|
|
|
|
|
+ // {
|
|
|
|
|
+ //
|
|
|
|
|
+ // //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);
|
|
|
|
|
+ //
|
|
|
|
|
+ //
|
|
|
|
|
+ // high = iHigh(Symbol(),PERIOD_CURRENT,l);
|
|
|
|
|
+ // trend = "uptrend";
|
|
|
|
|
+ //
|
|
|
|
|
+ // index_of_last_low = Store_last_index_of_low;
|
|
|
|
|
+ //
|
|
|
|
|
+ //
|
|
|
|
|
+ // choch = true;
|
|
|
|
|
+ // break;
|
|
|
|
|
+ //
|
|
|
|
|
+ // }
|
|
|
|
|
+ //
|
|
|
|
|
+ // if(high3 > high)
|
|
|
|
|
+ // {
|
|
|
|
|
+ // high = high3;
|
|
|
|
|
+ // Print("high update due to third condition",high);
|
|
|
|
|
+ // }
|
|
|
|
|
+ //
|
|
|
|
|
+ // }
|
|
|
|
|
+ //
|
|
|
|
|
+ // 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;
|
|
|
|
|
+ // }
|
|
|
|
|
+ //
|
|
|
|
|
+ //
|
|
|
|
|
+ //
|
|
|
|
|
+ //
|
|
|
|
|
+ //
|
|
|
|
|
+ // }
|
|
|
|
|
+
|
|
|
|
|
+ // 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);
|
|
|
|
|
+ //
|
|
|
|
|
+ // //double low1 = iLow(Symbol(),PERIOD_CURRENT,i);
|
|
|
|
|
+ //
|
|
|
|
|
+ // if(low1 < low)
|
|
|
|
|
+ // {
|
|
|
|
|
+ // low = low1;
|
|
|
|
|
+ //
|
|
|
|
|
+ // // Print("high break at index value",i);
|
|
|
|
|
+ // // Print("index is ",index);
|
|
|
|
|
+ //
|
|
|
|
|
+ // int count = (index-1) - i;
|
|
|
|
|
+ // Print("count is ", count);
|
|
|
|
|
+ //
|
|
|
|
|
+ // // Print("index updated ",index);
|
|
|
|
|
+ //
|
|
|
|
|
+ // // Print("count",count);
|
|
|
|
|
+ //
|
|
|
|
|
+ // for(int j=1; j <= count; j++)
|
|
|
|
|
+ // {
|
|
|
|
|
+ //
|
|
|
|
|
+ // if(checkCandle(index-j) == "Bullish")
|
|
|
|
|
+ // {
|
|
|
|
|
+ // high = iHigh(Symbol(),PERIOD_CURRENT,index-j);
|
|
|
|
|
+ // bullish_found = true;
|
|
|
|
|
+ // }
|
|
|
|
|
+ //
|
|
|
|
|
+ // }
|
|
|
|
|
+ //
|
|
|
|
|
+ // if(bullish_found == true)
|
|
|
|
|
+ // {
|
|
|
|
|
+ // high1;
|
|
|
|
|
+ // //Print("where");
|
|
|
|
|
+ // for(int k=1; k <= count; k++)
|
|
|
|
|
+ // {
|
|
|
|
|
+ //
|
|
|
|
|
+ // high1 = iHigh(Symbol(),PERIOD_CURRENT,index - k);
|
|
|
|
|
+ // if(high1 >= high)
|
|
|
|
|
+ // {
|
|
|
|
|
+ // //Print("here");
|
|
|
|
|
+ // high = high1;
|
|
|
|
|
+ // index_of_high = index - k;
|
|
|
|
|
+ // Print("high is updated at index : ",index - k);
|
|
|
|
|
+ //
|
|
|
|
|
+ // }
|
|
|
|
|
+ // }
|
|
|
|
|
+ // bullish_found = false;
|
|
|
|
|
+ //
|
|
|
|
|
+ // }
|
|
|
|
|
+ //
|
|
|
|
|
+ // Print(" high price is ", high);
|
|
|
|
|
+ // Print("low price is ", low);
|
|
|
|
|
+ // Print("index of last updated high is ", index_of_high);
|
|
|
|
|
+ //
|
|
|
|
|
+ // for(int l=index_of_high; l > 0; l--)
|
|
|
|
|
+ // {
|
|
|
|
|
+ // // 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);
|
|
|
|
|
+ // 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;
|
|
|
|
|
+ //
|
|
|
|
|
+ // }
|
|
|
|
|
+ //
|
|
|
|
|
+ //
|
|
|
|
|
+ //
|
|
|
|
|
+ //
|
|
|
|
|
+ // }
|
|
|
|
|
+ // 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;
|
|
|
|
|
+ //
|
|
|
|
|
+ // }
|
|
|
|
|
+ //
|
|
|
|
|
+ // }
|
|
|
|
|
+ // //
|
|
|
|
|
+ //
|
|
|
|
|
+ // }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
@@ -328,10 +586,19 @@ int OnInit()
|
|
|
|
|
|
|
|
datetime time_of_candle = (datetime)ObjectGetInteger(0,"line",OBJPROP_TIME,0);
|
|
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);
|
|
int index = iBarShift(Symbol(), PERIOD_CURRENT, time_of_candle, false);
|
|
|
|
|
+ checkCandle(index);
|
|
|
|
|
+ if(checkCandle(index) == "Bullish")
|
|
|
|
|
+ {
|
|
|
|
|
+ trend = "uptrend";
|
|
|
|
|
+ }
|
|
|
|
|
+ if(checkCandle(index) == "Bearish")
|
|
|
|
|
+ {
|
|
|
|
|
+ trend = "downtrend";
|
|
|
|
|
+ }
|
|
|
//Print(index);
|
|
//Print(index);
|
|
|
- // Print(index);
|
|
|
|
|
|
|
+ // Print(index);
|
|
|
|
|
|
|
|
// datetime time_of_candle = (datetime)ObjectGetInteger(0,"line",OBJPROP_TIME,0);
|
|
// datetime time_of_candle = (datetime)ObjectGetInteger(0,"line",OBJPROP_TIME,0);
|
|
|
// Print("time is " , time_of_candle);
|
|
// Print("time is " , time_of_candle);
|