How would I go about Programming this?

Discussion in 'Programming' started by GuyM, Sep 15, 2011.

  1. GuyM


    Hi just a quick programming question as I am new to programming and I am trying to program a FOREX strategy which I have come up with.

    I am using ProRealTime software for my programming as this is my charting package.

    How do I create a condition that a candle must touch a certain horizontal support/resistance line to qualify for entry (which will have been identified by me manually before hand)?

    I have already programmed the type of candle but I just need this further condition of touching a certain price level.

    I can't seem to work out how to integrate price levels into my coding, any help would be very much appreciated.


  2. You use an if/else statement. The correct syntax would depend on the programming language you are using.

    if (
    $test >= 40) {
    "Yes, $test is greater than 40.";
       } else {
    "No, $test is less than 40.";
    No, 32 is less than 40
  3. You need to make your code accept an input number, then check if the Close (this is assuming the code is being processed on every tick) = the input number.


    InputNumber = 500;

    if (Close[0] == InputNumber) .<....Do something>;
  4. GuyM


    ForexForex, thanks for the reply, I tried doing what you said but I didn't work, probably because I didn't really understand the coding of that. Prorealtime didn't understand a few symbols like $ etc.

    The level im trying to work is 63.47 on NZDJPY if you can change the code to suit that? I might need to find someone to code this for me instead of trying it myself.

    Thanks for your interst!
  5. GuyM


    MarketMasher, Thanks for your reply, I really appreciate it.

    I just tryed what you said and I put in the following code:

    InputNumber= 63.47

    IF Close[0] = inputnumber THEN





    RETURN structure as "level hit"

    This worked well and the indicator returned the value when the price closed at the level, however I'm wanting the indicator to return the value if the candle's range hits the level, not just a close at the level.

    Do you know how I can change this code to allow for this?

    Thanks for the help

  6. I'm not familiar with the coding language you are using, but I assume Close[0] could be Bid[0] or Ask[0]. And instead of = try >=, the statement will be TRUE if the level is equal to or greater than your input number. Just equal to (=) could be bypassed if the level jumps above your input number. Example: IF Close[0] >= inputnumber THEN

    The manual should have more on Close[0], Bid[0] and Ask[0]
  7. GuyM



    I think that could work but Prorealtime doesn't have functions that include bid and ask etc. There seems to be no function to track actual price, theres just high, low, open and close etc which is pretty frustrating.

    It seems silly that theres not a simple function that tracks price. All i want is a function that recognises that price has got to a certain price level which seems pretty straightforward.

    Thanks for your help. Any other suggestions would be appreciated.
  8. What is the time frame of each bar? I had a quick look through the manual and Close[1] will give you the closing price of the previous bar. If you can select a 5 minute bar then that might be OK.
  9. GuyM


    The time frame I'm wanting is 15minute candles, I could use the close but I don't want to limit the touch of the level to the close of bars because then I will miss out on many level touches.

    There has to be a way though because the software can track when price hits a price level with its alerts you can set to go if if price touches a level.

    Thanks for the help forexforex.
  10. If the code is being processed on every incoming tick (every change in price), the Close[0] MUST at some point equal (different times) the High AND Low of the individual bar at some point - otherwise how do you get a High or a Low?

    That is why you can use Close[0] to check if your price is hit - the most current price of the bar (the "Close[0]") must at some point create the bar's high and low.

    HOWEVER - if you are using static data when you make the comparison, then you would need something like

    if (InputNumber <= High[0] AND InputNumber >= Low[0]) <do something....>

    I use AND in the example rather than && since it looks kinda Pascal-ish....
    #10     Sep 18, 2011