Hey, sorry for making so many post regarding MetaTrader, but I am just learning the language, and am doing it by making an indicator that I could use.
The problem I am having now is this:
I want to take the current close of this 5 minute bar and compare it to the close of the last 5 minute bar.
For Example, if the last 5 minute bar was 1.9000 and this 5 minute bar ENDED at 1.9005 I want it to go to function A (if the current close is > the last close) and if its less go to function b and if it is the same go to function c etc etc
The problem I am having is, it is comparing the the first tick (up or down) to the last close and going straight to its function. How can I make it wait until this bar ends and the compare closes and go to its function.
The code I have is as follows.
dCurrentClose = Is suppose to be the close of this current bar
Start = is a boolean variable just to check if this function has ran
dReferenceClose = Is suppose to be the last bar's close
dRecentClose = should equal the close of this bar that is being analyzed and then sent to the properfunction
TLBHigh = equals the new high (if the close was higher than the reference)
TLBLow = equals the new low (if the close was lower than the reference
^^Both are used to compare at a later time in the code
DrawPostiveBlock() Is the function it should go to if dCurrentClose>dReferenceClose
DrawNegativeBlock() Is the function it should go to if dCurrentClose<dReferenceClose
ReferenceContinue is a bool variable just to see if the closes were the same
Remember the problem i am having is its is comparing the first tick of this bar instead of waiting on its close then doing the condition checking
Thanks for all the help!
The problem I am having now is this:
I want to take the current close of this 5 minute bar and compare it to the close of the last 5 minute bar.
For Example, if the last 5 minute bar was 1.9000 and this 5 minute bar ENDED at 1.9005 I want it to go to function A (if the current close is > the last close) and if its less go to function b and if it is the same go to function c etc etc
The problem I am having is, it is comparing the the first tick (up or down) to the last close and going straight to its function. How can I make it wait until this bar ends and the compare closes and go to its function.
The code I have is as follows.
dCurrentClose = Is suppose to be the close of this current bar
Start = is a boolean variable just to check if this function has ran
dReferenceClose = Is suppose to be the last bar's close
dRecentClose = should equal the close of this bar that is being analyzed and then sent to the properfunction
TLBHigh = equals the new high (if the close was higher than the reference)
TLBLow = equals the new low (if the close was lower than the reference
^^Both are used to compare at a later time in the code
DrawPostiveBlock() Is the function it should go to if dCurrentClose>dReferenceClose
DrawNegativeBlock() Is the function it should go to if dCurrentClose<dReferenceClose
ReferenceContinue is a bool variable just to see if the closes were the same
Inserted Code
//Check to see if it is the start of a new bar if (Volume[0] == 1){ double dCurrentClose=iClose(NULL,PERIOD_M5,0); if (Start==True){//This should only run 1 time //Get the previous bar's Close double dReferenceClose = iClose(NULL,PERIOD_M5,1); if (dCurrentClose>dReferenceClose){ dRecentClose=dCurrentClose; TLBLow=dReferenceClose; TLBHigh=dCurrentClose; DrawPositiveBlock(Time[0],dReferenceClose,dRecentClose); firstbar=true; } else if (dCurrentClose<dReferenceClose){ dRecentClose=dCurrentClose; TLBLow=dCurrentClose; TLBHigh=dReferenceClose; DrawNegativeBlock(Time[0],dReferenceClose,dRecentClose); firstbar=true; } else if (dCurrentClose==dReferenceClose){ //if it equals the reference close, set the qualifying high and low to the reference close TLBHigh=dReferenceClose; TLBLow=dReferenceClose; ReferenceContinue=True; } Start=false;//Turns off the varible that indicates if the indicator is being ran for the first time }
Remember the problem i am having is its is comparing the first tick of this bar instead of waiting on its close then doing the condition checking
Thanks for all the help!
Nothing is hard, some things just take more time and discipline.