Eurozo:
I need assistance in using the function from one indicator to use it in another indicator to display the same results at the left top edge of the main chart. I copied and pasted the entire indicators source code below because I do not know what part of the code computes and displays these results.
<CODE REMOVED>
Please edit your post . . . if your code is too big to add using the SRC button please attach it as a file.
Eurozo: to display the same results at the left top edge of the main chart. what part of the code computes and displays these results.
Play videoPlease edit your post.
For large amounts of code, attach it.
Comment ( "Highest = ", HHighest, " Lowest = ", LLowest, " Range = ", (HHighest - LLowest) / Point , " Bid = ", Bid, " Ask = ", Ask, " Lots = ", Lots );
extern int MagicNumber = 123987; extern double Lots = 0.1; extern bool AutoMoneyManagement = true; // percent of accout to risk based on the extern bool extern double PercentToRisk = 1; extern int Stop_Loss = 30; extern int Take_Profit = 90; extern int CancelHour = 23; extern int EndHour = 9; extern int LookBack = 7; // periods to look back to the highest and the lowest range. double HHighest = 0; double LLowest = 0; int StartMinute= 0; int PeriodCounter = 60; // Time frame to look back in. int OrderZone = 5; // this is the zone price can be at maximum and still get a fill. must be larger than TestZone. int Slippage = 5; double TestZone = 1; // this is the zone above and below the range for a trade double TestRange = 1000; bool Buying = true; bool Selling = true; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert start function | //+----------------------------------------------------------------------------------------------------------------------+ int start() { //---- // Cancels all pending orders //+------------------------------------------------------------------+ double Range, Spread = Ask - Bid, temph, templ, LotTest, StopLossH, TakeProfitH, StopLossL, TakeProfitL; bool result, OkToBuy = true, OkToSell = true; string Currency; int i, type, total = 0, StartHour = EndHour + 1; // allows for the full previous hour to be counted and // makes the new hour available for orders fro the open. total = OrdersTotal(); if ( Hour() == CancelHour ) { OkToBuy = true; OkToSell = true; for(i=total-1;i>=0;i--) { OrderSelect(i, SELECT_BY_POS); type = OrderType(); result = false; switch(type) { //Close opened long positions case OP_BUY : result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, CLR_NONE ); break; //Close opened short positions case OP_SELL : result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 5, CLR_NONE ); break; //Close pending orders case OP_BUYLIMIT : case OP_BUYSTOP : case OP_SELLLIMIT : case OP_SELLSTOP : result = OrderDelete( OrderTicket() ); } } } // Order placing and Lots size are done here //+------------------------------------------------------------------+ for(i=total-1;i>=0;i--) { OrderSelect(i, SELECT_BY_POS); type = OrderType(); Currency = OrderSymbol(); if ( Currency == Symbol() ) { if ( type == OP_BUY ) { OkToBuy = false; } if ( type == OP_SELL ) { OkToSell = false; } } } if ( Hour() == StartHour && (Minute() >= StartMinute && Hour() < StartHour + 1) ) { HHighest = 0; LLowest = 9999999; for (i=1; i <= LookBack; i++ ) { temph = iHigh(NULL, PeriodCounter, i); templ = iLow(NULL, PeriodCounter, i); if ( temph > HHighest ) HHighest = temph; if ( templ < LLowest ) LLowest = templ; } } Range = HHighest - LLowest; LotTest = Stop_Loss; StopLossH = Bid - (Stop_Loss * Point); StopLossL = Ask + (Stop_Loss * Point); TakeProfitH = Ask + (Take_Profit * Point); TakeProfitL = Bid - (Take_Profit * Point); if ( AutoMoneyManagement ) Lots = NormalizeDouble(AccountBalance() * (PercentToRisk / 100) / (LotTest) / 10,2); Comment ( "Highest = ", HHighest, " Lowest = ", LLowest, " Range = ", (HHighest - LLowest) / Point , " Bid = ", Bid, " Ask = ", Ask, " Lots = ", Lots ); if ( Bid < HHighest + (TestZone*Point) ) Buying = true; if ( Bid > LLowest - (TestZone*Point) ) Selling = true; if ( (Hour() >= StartHour && Minute() >= StartMinute) || Hour() > StartHour && Hour() < CancelHour ) { if ( Range <= (TestRange*Point) && Range > 0 ) { if (Bid >= HHighest + (TestZone*Point) && Bid <= HHighest + (OrderZone*Point) && OkToBuy && Buying ) { OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, StopLossH, TakeProfitH, "BreakOut eagle Buy", MagicNumber, NULL, Blue); Buying = false; } if (Bid <= LLowest - (TestZone*Point) && Bid >= LLowest - (OrderZone*Point) && OkToSell && Selling ) { OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, StopLossL, TakeProfitL, "Breakout eagle Sell", MagicNumber, NULL, Red); Selling = false; } } } /* Notes: */ //---- return(0); } //+------------------------------------------------------------------+ Below is the indicator that I would like the Highest= Lowest= Range= Bid= Ask= Lots= function written into. I don't want anything is this indicator changed, only the function written in so that it computes this indicators code with the same results starting at the top left edge of the main chart. Thank you in advance. #property indicator_chart_window extern int NumberOfDays = 50; extern string periodBegin = "02:00"; extern string periodEnd = "09:00"; extern string BoxEnd = "23:00"; extern int BoxBreakOut_Offset = 0; extern color BoxHLColor = LightCyan; extern color BoxBreakOutColor = LightGray; extern color BoxPeriodColor = OrangeRed; extern int SlopeChartTimeFrame = 60; extern int SlopePeriod_Input1 = 30; extern int Slopemethod_Input2=3; extern int SlopePrice_Input3=0; extern int pipsbuffer=3; extern string sound_wav="alert2.wav"; bool long_breakout_sent=false; bool short_breakout_sent=false; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ void init() { DeleteObjects(); datetime dtTradeDate=TimeCurrent(); for (int i=0; i<NumberOfDays; i++) { DrawObjects(dtTradeDate, "BoxHL " + TimeToStr(dtTradeDate,TIME_DATE), periodBegin, periodEnd, BoxEnd, BoxHLColor, 0, 1); DrawObjects(dtTradeDate, "BoxBreakOut_High " + TimeToStr(dtTradeDate,TIME_DATE), periodBegin, periodEnd, BoxEnd, BoxBreakOutColor, BoxBreakOut_Offset,2); DrawObjects(dtTradeDate, "BoxBreakOut_Low " + TimeToStr(dtTradeDate,TIME_DATE), periodBegin, periodEnd, BoxEnd, BoxBreakOutColor, BoxBreakOut_Offset,3); DrawObjects(dtTradeDate, "BoxPeriod " + TimeToStr(dtTradeDate,TIME_DATE), periodBegin, periodEnd, periodEnd, BoxPeriodColor, BoxBreakOut_Offset,4); dtTradeDate=decrementTradeDate(dtTradeDate); while (TimeDayOfWeek(dtTradeDate) > 5) dtTradeDate = decrementTradeDate(dtTradeDate); } } //+------------------------------------------------------------------+ //| Custor indicator deinitialization function | //+------------------------------------------------------------------+ void deinit() { DeleteObjects(); return(0); } //+------------------------------------------------------------------+ //| Remove all Rectangles | //+------------------------------------------------------------------+ void DeleteObjects() { ObjectsDeleteAll(0,OBJ_RECTANGLE); return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ void start() { datetime dtTradeDate=TimeCurrent(); static int prev_day; if(Day()!=prev_day) { // next day started. reset sent variables. long_breakout_sent=false; short_breakout_sent=false; } prev_day=Day(); CheckforBreakout(); int counted_bars=IndicatorCounted(); if(counted_bars < 0) return(-1); int limit = Bars - counted_bars; if(limit<=1) return; DrawObjects(dtTradeDate, "BoxHL " + TimeToStr(dtTradeDate,TIME_DATE), periodBegin, periodEnd, BoxEnd, BoxHLColor, 0, 1); DrawObjects(dtTradeDate, "BoxBreakOut_High " + TimeToStr(dtTradeDate,TIME_DATE), periodBegin, periodEnd, BoxEnd, BoxBreakOutColor, BoxBreakOut_Offset,2); DrawObjects(dtTradeDate, "BoxBreakOut_Low " + TimeToStr(dtTradeDate,TIME_DATE), periodBegin, periodEnd, BoxEnd, BoxBreakOutColor, BoxBreakOut_Offset,3); DrawObjects(dtTradeDate, "BoxPeriod " + TimeToStr(dtTradeDate,TIME_DATE), periodBegin, periodEnd, periodEnd, BoxPeriodColor, BoxBreakOut_Offset,4); } //+------------------------------------------------------------------+ //| Create Rectangles | //+------------------------------------------------------------------+ void DrawObjects(datetime dtTradeDate, string sObjName, string sTimeBegin, string sTimeEnd, string sTimeObjEnd, color cObjColor, int iOffSet, int iForm) { datetime dtTimeBegin, dtTimeEnd, dtTimeObjEnd; double dPriceHigh, dPriceLow; int iBarBegin, iBarEnd; dtTimeBegin = StrToTime(TimeToStr(dtTradeDate, TIME_DATE) + " " + sTimeBegin); dtTimeEnd = StrToTime(TimeToStr(dtTradeDate, TIME_DATE) + " " + sTimeEnd); dtTimeObjEnd = StrToTime(TimeToStr(dtTradeDate, TIME_DATE) + " " + sTimeObjEnd); iBarBegin = iBarShift(NULL, 0, dtTimeBegin); iBarEnd = iBarShift(NULL, 0, dtTimeEnd); dPriceHigh = High[Highest(NULL, 0, MODE_HIGH, iBarBegin-iBarEnd, iBarEnd)]; dPriceLow = Low [Lowest (NULL, 0, MODE_LOW, iBarBegin-iBarEnd, iBarEnd)]; ObjectCreate(sObjName, OBJ_RECTANGLE, 0, 0, 0, 0, 0); ObjectSet(sObjName, OBJPROP_TIME1, dtTimeBegin); ObjectSet(sObjName, OBJPROP_TIME2, dtTimeObjEnd); //---- High-Low Rectangle if(iForm==1){ ObjectSet(sObjName, OBJPROP_PRICE1, dPriceHigh); ObjectSet(sObjName, OBJPROP_PRICE2, dPriceLow); ObjectSet(sObjName, OBJPROP_STYLE, STYLE_SOLID); ObjectSet(sObjName, OBJPROP_COLOR, cObjColor); ObjectSet(sObjName, OBJPROP_BACK, True); } //---- Upper Rectangle if(iForm==2){ ObjectSet(sObjName, OBJPROP_PRICE1, dPriceHigh); ObjectSet(sObjName, OBJPROP_PRICE2, dPriceHigh + iOffSet*Point); ObjectSet(sObjName, OBJPROP_STYLE, STYLE_SOLID); ObjectSet(sObjName, OBJPROP_COLOR, cObjColor); ObjectSet(sObjName, OBJPROP_BACK, True); } //---- Lower Rectangle if(iForm==3){ ObjectSet(sObjName, OBJPROP_PRICE1, dPriceLow - iOffSet*Point); ObjectSet(sObjName, OBJPROP_PRICE2, dPriceLow); ObjectSet(sObjName, OBJPROP_STYLE, STYLE_SOLID); ObjectSet(sObjName, OBJPROP_COLOR, cObjColor); ObjectSet(sObjName, OBJPROP_BACK, True); } //---- Period Rectangle if(iForm==4){ ObjectSet(sObjName, OBJPROP_PRICE1, dPriceHigh + iOffSet*Point); ObjectSet(sObjName, OBJPROP_PRICE2, dPriceLow - iOffSet*Point); ObjectSet(sObjName, OBJPROP_STYLE, STYLE_SOLID); ObjectSet(sObjName, OBJPROP_COLOR, cObjColor); ObjectSet(sObjName, OBJPROP_WIDTH, 2); ObjectSet(sObjName, OBJPROP_BACK, False); } string sObjDesc = StringConcatenate("High: ",dPriceHigh," Low: ", dPriceLow, " OffSet: ",iOffSet); ObjectSetText(sObjName, sObjDesc,10,"Times New Roman",Black); } //+------------------------------------------------------------------+ //| Decrement Date to draw objects in the past | //+------------------------------------------------------------------+ datetime decrementTradeDate (datetime dtTimeDate) { int iTimeYear=TimeYear(dtTimeDate); int iTimeMonth=TimeMonth(dtTimeDate); int iTimeDay=TimeDay(dtTimeDate); int iTimeHour=TimeHour(dtTimeDate); int iTimeMinute=TimeMinute(dtTimeDate); iTimeDay--; if (iTimeDay==0) { iTimeMonth--; if (iTimeMonth==0) { iTimeYear--; iTimeMonth=12; } // Thirty days hath September... if (iTimeMonth==4 || iTimeMonth==6 || iTimeMonth==9 || iTimeMonth==11) iTimeDay=30; // ...all the rest have thirty-one... if (iTimeMonth==1 || iTimeMonth==3 || iTimeMonth==5 || iTimeMonth==7 || iTimeMonth==8 || iTimeMonth==10 || iTimeMonth==12) iTimeDay=31; // ...except... if (iTimeMonth==2) if (MathMod(iTimeYear, 4)==0) iTimeDay=29; else iTimeDay=28; } return(StrToTime(iTimeYear + "." + iTimeMonth + "." + iTimeDay + " " + iTimeHour + ":" + iTimeMinute)); } //+------------------------------------------------------------------+ void CheckforBreakout() { datetime dtTradeDate=TimeCurrent(); datetime dtTimeBegin = StrToTime(TimeToStr(dtTradeDate, TIME_DATE) + " " + periodBegin); datetime dtTimeEnd = StrToTime(TimeToStr(dtTradeDate, TIME_DATE) + " " + periodEnd); int iBarBegin, iBarEnd; double dPriceHigh, dPriceLow; if(!(dtTradeDate > dtTimeEnd) ) { return; } int spread=MarketInfo(Symbol(),MODE_SPREAD); iBarBegin = iBarShift(NULL, 0, dtTimeBegin); iBarEnd = iBarShift(NULL, 0, dtTimeEnd); dPriceHigh = High[Highest(NULL, 0, MODE_HIGH, iBarBegin-iBarEnd, iBarEnd)]; dPriceLow = Low [Lowest (NULL, 0, MODE_LOW , iBarBegin-iBarEnd, iBarEnd)]; string body="Time: " + TimeToStr(TimeCurrent(),TIME_DATE | TIME_MINUTES | TIME_SECONDS) + "\nspread :"+ DoubleToStr(spread,4)+ "\npipsbuffer :"+ DoubleToStr(pipsbuffer,4); if( Low[1] < dPriceHigh && Ask > dPriceHigh+ (spread*Point) + (pipsbuffer*Point) && long_breakout_sent==false) { double base_uptrend=iCustom(NULL, SlopeChartTimeFrame, "Slope Direction Line", SlopePeriod_Input1, Slopemethod_Input2, SlopePrice_Input3, 0, 1); if(base_uptrend==EMPTY_VALUE) return; Alert(Symbol() + " BOX LONG BREAKOUT"); body=body+ "\nBOX High :" + DoubleToStr(dPriceHigh,4)+ "\nPrice : " + DoubleToStr(Ask,4); SendMail(Symbol() + " BOX LONG BREAKOUT",body); PlaySound(sound_wav); string filename=Symbol() + "_" + "BOX_LONG" + "_"+ Month() + "-" + Day() + ".gif"; WindowScreenShot(filename,600,600); SendFTP(filename); long_breakout_sent=true; } if( High[1] > dPriceLow && Bid < dPriceLow-(spread*Point)-(pipsbuffer*Point) && short_breakout_sent==false ) { double base_dntrend=iCustom(NULL, SlopeChartTimeFrame, "Slope Direction Line", SlopePeriod_Input1, Slopemethod_Input2, SlopePrice_Input3, 1, 1); if(base_dntrend==EMPTY_VALUE) return; Alert(Symbol()+ " BOX SHORT BREAKOUT"); body=body+ "\nBOX Low :" + DoubleToStr(dPriceLow,4)+ "\nPrice : " + DoubleToStr(Bid,4); SendMail(Symbol() + " BOX SHORT BREAKOUT",body); filename=Symbol() + "_" + "BOX_SHORT" + "_"+ Month() + "-" + Day() + ".gif"; WindowScreenShot(filename,600,600); SendFTP(filename); PlaySound(sound_wav); short_breakout_sent=true; } }
RaptorUK:
Thank you for your assistance
Please edit your post . . . if your code is too big to add using the SRC button please attach it as a file.
WHRoeder:
Play videoPlease edit your post.
For large amounts of code, attach it.
- Comment ( "Highest = ", HHighest, " Lowest = ", LLowest, " Range = ", (HHighest - LLowest) / Point
, " Bid = ", Bid, " Ask = ", Ask, " Lots = ", Lots ); Thank you WHRoeder. I added this to my indicator. I was able to get the indicator to display this but it does not provide the values for the Highest, Lowest or Range. Do I have to make the indicator an EA to get these values displayed??
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I need assistance in using the function from one indicator to use it in another indicator to display the same results at the left top edge of the main chart. I copied and pasted the entire indicators source code below because I do not know what part of the code computes and displays these results.
<CODE DELETED>
Below is the indicator that I would like the Highest= Lowest= Range= Bid= Ask= Lots= function written into. I don't want anything is this indicator changed, only the function written in so that it computes this indicators code with the same results starting at the top left edge of the main chart. Thank you in advance.
<CODE DELETED>