Is there a problem with the logic of this statement?

 
   if(BuyClose > BUYtrendlineValue + (Buffer * UsePoint) && NewBUYtime != OldBUYtime && (BuyClose1 < BUYtrendlineValue || BuyClose2 < BUYtrendlineValue))
 
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).
 
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)

 
Here is the screen shot
 
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);
 
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.
 
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));
 
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.
Reason: