Protecting the value of a bool?
Protecting the value of a bool?
31 Jan 2018, 15:46
Hi,
Is it possible to protect the value of a bool ?
Here's a simplified version of what I'm trying to achieve;
bool FirstFibLevel = false; { if (price < 7) { FirstFibLevel = true; } } if (FirstFibLevel == true) { Place order to enter trade at 10 Now when the price is below 7 the bool is true. If it rises from 7 to our desired level of 10 it becomes false again… but we want to remember that it has been below 7...
Is there a better alternative to using a bool?
Many thanks in advance,
Drummond
Replies
markae
01 Feb 2018, 09:27
RE:
Just check if it is still "false" and only then check the "price"-Value. Once it becomes true stop checking the price value
bool FirstFibLevel = false; if(!FirstFibLevel) { if (price < 7) { FirstFibLevel = true; } else { FirstFibLevel = false // not really necessary } } if (FirstFibLevel) { Place order to enter trade at 10 }
@markae
Drummond360
01 Feb 2018, 11:34
RE: RE:
Fantastic, thank you Markae...
markae said:
Just check if it is still "false" and only then check the "price"-Value. Once it becomes true stop checking the price value
bool FirstFibLevel = false; if(!FirstFibLevel) { if (price < 7) { FirstFibLevel = true; } else { FirstFibLevel = false // not really necessary } } if (FirstFibLevel) { Place order to enter trade at 10 }
@Drummond360
PanagiotisCharalampous
31 Jan 2018, 16:10
Hi Drummond,
If you provide the complete code sample then we can suggest you how to do it.
Best Regards,
Panagiotis
@PanagiotisCharalampous