Thanks!
Why is it:
start_bar-end_bar+1
Why is there a plus 1, shouldn't it be a minus 1 instead?
Why is it:
start_bar-end_bar+1
Why is there a plus 1, shouldn't it be a minus 1 instead?
Code question: How to detect a string end postion? 3 replies
Symbol Suffix Auto-Detect Code for an EA 4 replies
Fibonacci lines - Please explain it 41 replies
Numbered Fibonacci Lines on MT4 1 reply
Fibonacci lines and price 4 replies
DislikedI would like to find the highest high and lowest low between start_time and end_time but EXCLUDING the start_time and end_time bars. I only want to find out the bars BETWEEN the two timings. Is the above code correct?Ignored
datetime start_time = [color="Blue"](whatever time you like: StrToTime("YYYY.MM.DD HH:II:SS"))[/color]; datetime end_time = [color="blue"](whatever time you like: StrToTime("YYYY.MM.DD HH:II:SS"))[/color]; int start_bar = iBarShift(Symbol(),Period(),start_time,0); int end_bar = iBarShift(Symbol(),Period(),end_time,0); double high = High[iHighest(Symbol(),Period(),MODE_HIGH, start_bar-end_bar-1, end_bar+1)]; double low = Low [iLowest (Symbol(),Period(),MODE_LOW, start_bar-end_bar-1, end_bar+1)];
#define SIGNAL_NONE 0 #define SIGNAL_BUY 1 #define SIGNAL_SELL 2 #define SIGNAL_CLOSEBUY 3 #define SIGNAL_CLOSESELL 4 extern int MagicNumber = 0; extern double Lots = 0.1; bool SignalMail = True; bool EachTickMode = True; int Slippage = 100; bool UseStopLoss = False; int StopLoss = 30; bool UseTakeProfit = False; int TakeProfit = 60; bool UseTrailingStop = False; int TrailingStop = 30; int BarCount; int Current; bool TickCheck = False; bool buyFlag = false, sellFlag = false; datetime barStart = 0, FiboEndTime; bool nomoretrades = false, fibocalset = false; bool retrace23 = false, retrace38 = false, retrace50 = false, fibotime1 = false, fibotime2 = false; int backshift1, backshift2, backshift3; bool retrace23time1 = false, retrace38time1 = false, retrace50time1 = false, retrace61time1 = false, retrace38time2 = false, retrace50time2 = false, retrace76time2 = false; bool fiboup = false, fibodown = false, flag0 = false, flag100 = false, TradingTime = false; bool heikenred = false, heikenblue = false; double highest, lowest, takeprofit1, mingap = 0.00010, mingaptp = 0.00020; double fibo38, fibo61, fibo100, fibo76, fibo0, fibo113, fibo113inv, fibo161, fibo150, fibo261, fibo23, fibo161inv, fibo150inv, fibo261inv, fibo50, fiborange; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { BarCount = Bars; if (EachTickMode) Current = 0; else Current = 1; return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { int Order = SIGNAL_NONE; int Total, Ticket; double StopLossLevel, TakeProfitLevel; if (EachTickMode && Bars != BarCount) TickCheck = False; Total = OrdersTotal(); Order = SIGNAL_NONE; //+------------------------------------------------------------------+ //| Variable Begin | //+------------------------------------------------------------------+ int cnt, timecount; double FractalsUpper2 = iFractals(NULL, 0, MODE_UPPER, Current + 2); double FractalsLower2 = iFractals(NULL, 0, MODE_LOWER, Current + 2); double FractalsUpper3 = iFractals(NULL, 0, MODE_UPPER, Current + 3); double FractalsLower3 = iFractals(NULL, 0, MODE_LOWER, Current + 3); //+------------------------------------------------------------------+ //| Variable End | //+------------------------------------------------------------------+ if (barStart < Time[0]) //start of new bar { barStart = Time[0]; buyFlag = false; sellFlag = false; if(StringFind(Symbol(), "JPY", 0) != -1) { mingap = 0.010; } double TrendUp1 = iCustom(NULL,0,"SuperTrend",10,3,0,1); double TrendDown1 = iCustom(NULL,0,"SuperTrend",10,3,1,1); double TrendUp2 = iCustom(NULL,0,"SuperTrend",10,3,0,2); double TrendDown2 = iCustom(NULL,0,"SuperTrend",10,3,1,2); double Buffer0Shift1 = iCustom(NULL,0,"Heiken_Ashi_Smoothed",2,6,3,2,0,1); double Buffer1Shift1 = iCustom(NULL,0,"Heiken_Ashi_Smoothed",2,6,3,2,1,1); double Buffer2Shift1 = iCustom(NULL,0,"Heiken_Ashi_Smoothed",2,6,3,2,2,1); double Buffer3Shift1 = iCustom(NULL,0,"Heiken_Ashi_Smoothed",2,6,3,2,3,1); double Buffer0Shift2 = iCustom(NULL,0,"Heiken_Ashi_Smoothed",2,6,3,2,0,2); double Buffer1Shift2 = iCustom(NULL,0,"Heiken_Ashi_Smoothed",2,6,3,2,1,2); double Buffer2Shift2 = iCustom(NULL,0,"Heiken_Ashi_Smoothed",2,6,3,2,2,2); double Buffer3Shift2 = iCustom(NULL,0,"Heiken_Ashi_Smoothed",2,6,3,2,3,2); for (int object=0; object<ObjectsTotal(); object++) { // for each object on the chart...... string objname = ObjectName(object); // get the name of the object // once you have the name, you can use ObjectGet() to retrieve all of the other properties...... if (ObjectType(objname) == OBJ_FIBO) { datetime fibtime1 = ObjectGet(objname,OBJPROP_TIME1); // swing high date/time datetime fibtime2 = ObjectGet(objname,OBJPROP_TIME2); // swing low date/time double fibprice1 = ObjectGet(objname,OBJPROP_PRICE1); // swing high price double fibprice2 = ObjectGet(objname,OBJPROP_PRICE2); // swing low price } } datetime FiboTime1 = ObjectGet("Fib1Drawing",OBJPROP_TIME1); datetime FiboTime2 = ObjectGet("Fib2Drawing",OBJPROP_TIME1); if(TimeCurrent() >= FiboTime1) { fibotime1 = true; } if(TimeCurrent() >= FiboTime2) { fibotime2 = true; } if(fibocalset == false) { if(fibtime1 > fibtime2) { if(fibprice1 > fibprice2) { fiboup = true; fibodown = false; highest = fibprice1; lowest = fibprice2; } else{ fibodown = true; fiboup = false; highest = fibprice2; lowest = fibprice1; } FiboEndTime = fibtime1; } if(fibtime2 > fibtime1) { if(fibprice2 > fibprice1) { fiboup = true; fibodown = false; highest = fibprice2; lowest = fibprice1; } else{ fibodown = true; fiboup = false; highest = fibprice1; lowest = fibprice2; } FiboEndTime = fibtime2; } //------------------------- fiborange = (highest - lowest); fibo38 = (lowest + (fiborange*0.382)); fibo61 = (lowest + (fiborange*0.618)); fibo50 = (lowest + (fiborange*0.5)); fibo113 = (highest + (fiborange*0.13)); fibo161 = (highest + (fiborange*0.618)); fibo150 = (highest + (fiborange*0.5)); fibo261 = (highest + (fiborange*1.618)); fibo76 = (lowest + (fiborange*0.764)); fibo23 = (lowest + (fiborange*0.236)); fibo113inv = (lowest - (fiborange*0.13)); fibo161inv = (lowest - (fiborange*0.618)); fibo150inv = (lowest - (fiborange*0.5)); fibo261inv = (lowest - (fiborange*1.618)); fibo100 = highest; fibo0 = lowest; fibocalset = true; } if (Buffer3Shift1 > Buffer2Shift1) { heikenblue = true; heikenred = false; } if (Buffer3Shift1 < Buffer2Shift1) { heikenred = true; heikenblue = false; } backshift1 = (iBarShift( Symbol(), Period(), FiboEndTime) -1); double low = Low[iLowest(NULL,0,MODE_LOW,backshift1,1)]; double high = High[iHighest(NULL,0,MODE_HIGH,backshift1,1)]; if (fiboup == true && low <= fibo76) { retrace23 = true; } if (fibodown == true && high >= fibo23) { retrace23 = true; } if (fiboup == true && low < fibo61) { retrace38 = true; } if (fibodown == true && high > fibo38) { retrace38 = true; } if (fiboup == true && low < fibo50) { retrace50 = true; } if (fibodown == true && high > fibo50) { retrace50 = true; } backshift1 = (iBarShift( Symbol(), Period(), FiboEndTime) -1); backshift2 = (iBarShift( Symbol(), Period(), FiboTime1) +1); double low2 = Low[iLowest(NULL,0,MODE_LOW, backshift1, backshift2)]; double high2 = High[iHighest(NULL,0,MODE_HIGH,backshift1,backshift2)]; if (fiboup == true && low2 <= fibo76) { retrace23time1 = true; } if (fibodown == true && high2 >= fibo23) { retrace23time1 = true; } if (fiboup == true && low2 < fibo61) { retrace38time1 = true; } if (fibodown == true && high2 > fibo38) { retrace38time1 = true; } if (fiboup == true && low2 < fibo50) { retrace50time1 = true; } if (fibodown == true && high2 > fibo50) { retrace50time1 = true; } backshift2 = (iBarShift( Symbol(), Period(), FiboTime1) -1); backshift3 = (iBarShift( Symbol(), Period(), FiboTime2) +1); int low3 = Low[iLowest(NULL,0,MODE_LOW,backshift2,backshift3)]; int high3 = High[iHighest(NULL,0,MODE_HIGH,backshift2,backshift3)]; if (fiboup == true && low3 < fibo61) { retrace38time2 = true; } if (fibodown == true && high3 > fibo38) { retrace38time2 = true; } if (fiboup == true && low3 < fibo50) { retrace50time2 = true; } if (fibodown == true && high3 > fibo50) { retrace50time2 = true; } }
DislikedHi, I have a problem with the retrace23time1, retrace38time1, retrace50time1, retrace61time1, retrace38time2, retrace50time2 and retrace76time2 flags in my EA. They are not working correctly. The function of each of those flags are to check the retracement level between a certain timing to a certain timing. I use the fibonacci retracement tool and the FiboTime indicator for these flags. "retrace23time1 == true" means that there is a 23% retracement before FiboTime1. "retrace23time2 == true" means that there is a 23% retracement between FiboTime1...Ignored