fxDreema

    • Register
    • Login
    • Search
    • Back to the main page
    • Categories
    • Recent
    • Tags
    • Popular
    • Search

    what's wrong in here?

    Questions & Answers
    2
    2
    707
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • D
      damsiboko last edited by

      //!!! I must define all input properties here, because they are not automatically defined.
      	// This function is not global prototype, one new function is created for each case. This is because % iCustom % must be unique
      	
      	string symbol = Symbol;
      	ENUM_TIMEFRAMES timeframe = Period;
      	int buffer    = 1;
      	int shift     = Shift + FXD_MORE_SHIFT;
      	
      	double retval = EMPTY_VALUE;
      	int i;
      	double ival;
      	
      	if (ModeOutput == "id")
      	{
      		retval = iCustom(symbol, timeframe, "ccf1p-value" , buffer, shift);
      		
      	}
      	else if (ModeOutput == "time")
      	{
      		datetime time;
      		
      		if (0 && StringFind(TimeStamp, ":") == -1)
      		{	
      			time = (datetime)StringToInteger(TimeStamp); // hangs in MQL4!!!
      		}
      		else
      		{
      			time = StringToTime(TimeStamp);
      		}
      		
      		shift = iCandleID(symbol, timeframe, time);
      		retval = iCustom(symbol, timeframe, "ccf1p-value" , buffer, shift);
      	}
      	else if (ModeOutput == "visible" || ModeOutput == "id_by_visible")
      	{
      		if (VisibleLimit == 0) {VisibleLimit = iBars(symbol, timeframe);}
      		
      		int vid = 0;
      		
      		for (i = shift; i <= VisibleLimit; i++)
      		{
      			ival = iCustom(symbol, timeframe, "ccf1p-value" , buffer, shift + i);
      			
      			if (ival == EMPTY_VALUE || ival == 0) {continue;}
      			if (vid >= VisibleID) {
      				if (ModeOutput == "visible") {retval = ival;}
      				else {retval = i;}
      				break;	
      			}
      				
      			vid++;
      		}
      	}
      	else if (ModeOutput == "range")
      	{
      		int cstart = RangeCandleStart;
      		int cend   = RangeCandleEnd;
      		//string RangeValue = RangeValue;
      		
      		// reverse values, if needed
      		if (RangeCandleStart > RangeCandleEnd) {
      			int ctmp = RangeCandleEnd;
      			RangeCandleEnd = RangeCandleStart;
      			RangeCandleStart = ctmp;
      		}
      	
      		if (RangeValue == "max")
      		{
      			retval = -EMPTY_VALUE;
      			
      			for (i = RangeCandleStart; i <= RangeCandleEnd; i++)
      			{
      				ival = iCustom(symbol, timeframe, "ccf1p-value" , buffer, shift + i);
      				if (ival == EMPTY_VALUE || ival == 0) {continue;}
      				if (ival > retval) {retval = ival;}
      			}
      			
      			if (retval == -EMPTY_VALUE) {retval = EMPTY_VALUE;}
      		}
      		else if (RangeValue == "min")
      		{
      			retval = EMPTY_VALUE;
      			
      			for (i = RangeCandleStart; i <= RangeCandleEnd; i++)
      			{
      				ival = iCustom(symbol, timeframe, "ccf1p-value" , buffer, shift + i);
      				if (ival == EMPTY_VALUE || ival == 0) {continue;}
      				if (ival < retval) {retval = ival;}
      			}
      		}
      	}
      	else if (ModeOutput == "range_time")
      	{
      		datetime offset = 0;
      		if (RangeTimeSource == "gmt") {offset = (int)(TimeCurrent() - TimeLocal() + TimeGMTOffset());}
      		else if (RangeTimeSource == "server") {offset = (int)(TimeCurrent() - TimeLocal());}
      		
      		datetime time1 = StringToTime(RangeTimeStart)-(datetime)(86400*RangeDayOffset) + offset;
      		datetime time2 = StringToTime(RangeTimeEnd)-(datetime)(86400*RangeDayOffset) + offset;
      		
      		int x1 = iBarShift(symbol, timeframe, time1, false);
      		int x2 = iBarShift(symbol, timeframe, time2, false);
      		if (x1<x2) {x1=iBarShift(symbol,timeframe,(time1-86400),false);}
      		
      		if (RangeValue == "max")
      		{
      			retval = -EMPTY_VALUE;
      			
      			for (i=x2; i<=x1; i++)
      			{
      				ival = iCustom(symbol, timeframe, "ccf1p-value" , buffer, shift + i);
      				if (ival == EMPTY_VALUE || ival == 0) {continue;}
      				if (ival > retval) {retval = ival;}
      			}
      			
      			if (retval == -EMPTY_VALUE) {retval = EMPTY_VALUE;}
      		}
      		else if (RangeValue == "min")
      		{
      			retval = EMPTY_VALUE;
      			
      			for (i=x2; i<=x1; i++)
      			{
      				ival = iCustom(symbol, timeframe, "ccf1p-value" , buffer, shift + i);
      				if (ival == EMPTY_VALUE || ival == 0) {continue;}
      				if (ival < retval) {retval = ival;}
      			}
      		}
      	}
      	
      	return (retval);
      }
      
      1 Reply Last reply Reply Quote 0
      • fxDreema
        fxDreema last edited by

        If you are asking about the comments on the top, I probably placed them for the future me, for me to know what is going on If I touch this code in the future.

        1 Reply Last reply Reply Quote 0
        • 1 / 1
        • First post
          Last post

        Online Users

        A
        H
        H

        7
        Online

        146.7k
        Users

        22.4k
        Topics

        122.6k
        Posts

        Powered by NodeBB Forums | Contributors