Download MetaTrader 5
To add comments, please log in or register
Carry on your private correspondence in your profile. It is secure!
Ernest Klokow
1069
Ernest Klokow 2015.11.01 13:04 
   if(BuyClose > BUYtrendlineValue + (Buffer * UsePoint) && NewBUYtime != OldBUYtime && (BuyClose1 < BUYtrendlineValue || BuyClose2 < BUYtrendlineValue))
ThreadHandle
105
ThreadHandle 2015.11.01 13:08  
Are you getting an error? brace anything that's relative, i always brace anything that are exclusively AND OR.....if((BuyClose > BUYtrendlineValue + (Buffer * UsePoint)) && (NewBUYtime != OldBUYtime) && ((BuyClose1 < BUYtrendlineValue) || (BuyClose2 < BUYtrendlineValue))) unless the OR is part of the expression x & y & (a | b).
Ernest Klokow
1069
Ernest Klokow 2015.11.01 14:29  
Keelan:
Are you getting an error? brace anything that's relative, i always brace anything that are exclusively AND OR.....if((BuyClose > BUYtrendlineValue + (Buffer * UsePoint)) && (NewBUYtime != OldBUYtime) && ((BuyClose1 < BUYtrendlineValue) || (BuyClose2 < BUYtrendlineValue))) unless the OR is part of the expression x & y & (a | b).

I have braced everything as you have shown, but still have the same problem. The last part starting from BuyClose1 is ignored.

In the attached screen image the first Buy transaction is according to the code, but the others should not happen, because the BuyClose1 and BuyClose2 values are not smaller than the BUYtrendlineValue (represented by the drawn trend line)

Ernest Klokow
1069
Ernest Klokow 2015.11.01 14:32  
Here is the screen shot
whroeder1
13596
whroeder1 2015.11.01 15:14  
if(BuyClose > BUYtrendlineValue + (Buffer * UsePoint) && NewBUYtime != OldBUYtime && (BuyClose1 < BUYtrendlineValue || BuyClose2 < BUYtrendlineValue))
Print out your variables, and find out why.
Print("BuyClose > BUYtrendlineValue + (Buffer * UsePoint) && NewBUYtime != OldBUYtime && (BuyClose1 < BUYtrendlineValue || BuyClose2 < BUYtrendlineValue)");

PrintFormat("%f > %f + (%f * %f) && '%s' != '%s' && (%f < %f || %f < %f)", BuyClose, BUYtrendlineValue, Buffer, UsePoint, TimeToStr(NewBUYtime, TIME_DATE|TIME_MINUTES|TIME_SECONDS), TimeToStr(OldBUYtime, TIME_DATE|TIME_MINUTES|TIME_SECONDS), BuyClose1, BUYtrendlineValue, BuyClose2, BUYtrendlineValue);

PrintFormat("%f > %f + %f && %i && (%i || %i)", BuyClose, BUYtrendlineValue, Buffer * UsePoint, TimeToStr(NewBUYtime, TIME_DATE|TIME_MINUTES|TIME_SECONDS) != TimeToStr(OldBUYtime, TIME_DATE|TIME_MINUTES|TIME_SECONDS), BuyClose1 < BUYtrendlineValue, BuyClose2 < BUYtrendlineValue);

PrintFormat("%f > %f && %i && %i", BuyClose, BUYtrendlineValue + Buffer * UsePoint, TimeToStr(NewBUYtime, TIME_DATE|TIME_MINUTES|TIME_SECONDS) != TimeToStr(OldBUYtime, TIME_DATE|TIME_MINUTES|TIME_SECONDS), BuyClose1 < BUYtrendlineValue || BuyClose2 < BUYtrendlineValue);

PrintFormat("%i && %i && %i", BuyClose > BUYtrendlineValue + Buffer * UsePoint, TimeToStr(NewBUYtime, TIME_DATE|TIME_MINUTES|TIME_SECONDS) != TimeToStr(OldBUYtime, TIME_DATE|TIME_MINUTES|TIME_SECONDS), BuyClose1 < BUYtrendlineValue || BuyClose2 < BUYtrendlineValue);
ThreadHandle
105
ThreadHandle 2015.11.01 15:38  
Whats the trend line? a mean of open + close / 2? if so they could be, an actual line will be stored in an array given your intercept and slope using whatever formula. And if that "mean" for the trendline doesn't end on that specific date, its value will start to climb, but i don't know what formula your using. By the way when you say the ByClose1 and BuyClose2 are not smaller than the trendline that would mean this expression would result in false. if(true && true && true && (50 < 20 || 30 < 20)) result as false.
Ernest Klokow
1069
Ernest Klokow 2015.11.01 16:45  
Keelan:
Whats the trend line? a mean of open + close / 2? if so they could be, an actual line will be stored in an array given your intercept and slope using whatever formula. And if that "mean" for the trendline doesn't end on that specific date, its value will start to climb, but i don't know what formula your using. By the way when you say the ByClose1 and BuyClose2 are not smaller than the trendline that would mean this expression would result in false. if(true && true && true && (50 < 20 || 30 < 20)) result as false.

It should give false but do not and a trade is wrongly executed.

Here is my code for getting the value of the trend line at the specific bar:


           BUYtrendlineValue = ObjectGetValueByTime(0,BUYtrendlineName,TimeCurrent(),0);
           BUYtrendlineValue = NormalizeDouble(BUYtrendlineValue,MarketInfo(OrderSymbol(),MODE_DIGITS));
Ernest Klokow
1069
Ernest Klokow 2015.11.02 05:51  
WHRoeder:
if(BuyClose > BUYtrendlineValue + (Buffer * UsePoint) && NewBUYtime != OldBUYtime && (BuyClose1 < BUYtrendlineValue || BuyClose2 < BUYtrendlineValue))
Print out your variables, and find out why.
Print("BuyClose > BUYtrendlineValue + (Buffer * UsePoint) && NewBUYtime != OldBUYtime && (BuyClose1 < BUYtrendlineValue || BuyClose2 < BUYtrendlineValue)");

PrintFormat("%f > %f + (%f * %f) && '%s' != '%s' && (%f < %f || %f < %f)", BuyClose, BUYtrendlineValue, Buffer, UsePoint, TimeToStr(NewBUYtime, TIME_DATE|TIME_MINUTES|TIME_SECONDS), TimeToStr(OldBUYtime, TIME_DATE|TIME_MINUTES|TIME_SECONDS), BuyClose1, BUYtrendlineValue, BuyClose2, BUYtrendlineValue);

PrintFormat("%f > %f + %f && %i && (%i || %i)", BuyClose, BUYtrendlineValue, Buffer * UsePoint, TimeToStr(NewBUYtime, TIME_DATE|TIME_MINUTES|TIME_SECONDS) != TimeToStr(OldBUYtime, TIME_DATE|TIME_MINUTES|TIME_SECONDS), BuyClose1 < BUYtrendlineValue, BuyClose2 < BUYtrendlineValue);

PrintFormat("%f > %f && %i && %i", BuyClose, BUYtrendlineValue + Buffer * UsePoint, TimeToStr(NewBUYtime, TIME_DATE|TIME_MINUTES|TIME_SECONDS) != TimeToStr(OldBUYtime, TIME_DATE|TIME_MINUTES|TIME_SECONDS), BuyClose1 < BUYtrendlineValue || BuyClose2 < BUYtrendlineValue);

PrintFormat("%i && %i && %i", BuyClose > BUYtrendlineValue + Buffer * UsePoint, TimeToStr(NewBUYtime, TIME_DATE|TIME_MINUTES|TIME_SECONDS) != TimeToStr(OldBUYtime, TIME_DATE|TIME_MINUTES|TIME_SECONDS), BuyClose1 < BUYtrendlineValue || BuyClose2 < BUYtrendlineValue);
Thanks a lot WHRoeder. This is quite impressive! Know only the plain "Print" statement. Did not know one could do this kind of thing.
/
To add comments, please log in or register