
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I did not write 181 posts on there? That was a joint effort, some of which, from people who did not know how to do it themselves. That thread is now resolved on the final post I have put up... All thanks to everyone's help.
You have a funny way of deciding who is eligible and worthy enough for your help. Either way, I am sorry if you feel tired of threads where people are asking for questions to be answered. Maybe you should take a break from helping on here for a while?
Does anyone else have any time to share?
First, there are many coding styles, but the choice of a particular style (or combination of styles) is largely up to the individual programmer. However, I think there are three things that are important. In order of importance (at least in my opinion), they are:
If you want to determine whether the PullBack_Bar is greater in time than the triggerBarTime, which is what your comments suggest, you need to simply test whether the PullBack_Bar is greater than triggerBarTime.
Hey Thirteen, thanks for your kind post and stopping by!
I was under the impression that doing a straight ">" comparison, is not the most accurate? Then again, I think what I have done there is really stupid relative to datetime as I am not comparing price ("Point"). Thanks for pointing that out :)
What I have written does work. I did actually post that back to let everyone know that I think I had it sorted. Just didn't understand the other persons post saying what I have written is overly complex? Am curious to understand how else I would do it?
I was under the impression that doing a straight ">" comparison, is not the most accurate?
Hi this double comparison issue can get confusing. Generally I would advise the following (Others may have their own approach :) ).
- Avoid comparing doubles for equality or inequality, use < or > where feasible/logical in your code.
- However, Sometimes you do want >= or <= (rather than < or > ) to maximise pips etc, in which case ...
In the rare cases you specifically care about equality ( =, !=, >=, <= ) then compare using a tolerance, either
- round both numbers to nearest point and then compare with a small tolerance (eg Point/2 or even smaller)
- OR compare unrounded numbers with a bigger tolerance (which would be almost equal to your rounding size - eg just under 'Point' for prices) (ala Thirteen :) )
Eg if waiting for price to meet a MA, the MA is likely some arbitrary 'fluffy' number and unlikely to be a strict price (number of pips), so I would just use
if (price >= MA) ...
However if waiting for price to hit another specific price, eg previous candle OHLC or a Pivot line, then I think the Pivot Price is a better defined value than a MA (in terms of precise Pips/Points), I guess a lot of people may have pending orders sitting on them etc. and market may react at that price point, and in that case you may want to compare with a tolerance to be sure you dont miss the match, so in that case I might use:
if (ge(price,Pivot))...
Where ge() is a user defined 'greater or equal' function to compare price and Pivot within a tolerance. But then again I might still not care than much and just use (price >= Pivot). I would (in order of preference)
What I have written does work. I did actually post that back to let everyone know that I think I had it sorted.
If your code works for you, that is what is most important. Just have a few suggestions for your future consideration:
First, you have:
. . . given that ema21 and H1_low are doubles that represent price, I think you meant:
See WHRoeder's post here.
Second, you might consider using boolean or integer values for your "bias" variables, instead of string values. Using strings invites too many unacceptable typo errors (such as an extra space). Additionally, your current use of strings won't allow you to relate/compare one "bias" variable to another, if the need arises. See the following example (code compiles but not tested):
Third, you might consider grouping your current "SmallFish" and "BigFish" data into a more usable collection, such as an array, so you can possibly avoid such heavily nested IF statements. See an example here.
Great advice! Thank you very much for both of your help :)