How to know output from indicator when programming?

Forums ProRealTime English forum ProRealTime platform support How to know output from indicator when programming?

  • This topic has 51 replies, 7 voices, and was last updated 2 months ago by avatarJS.
Viewing 15 posts - 31 through 45 (of 52 total)
  • #234576

    Hello @Haidar ail, can you please post your request for translation in its own dedicated topic ? (make new topic) – Thank you !

    #234577

    A second one was, having a constant of a closed value for each instrument with a date/ time reference

    Very nice !

    #234578

    Thanks for the ideas everyone.

    I was going to do a heavy post but it’s not really necessary. There’s no fitting of anything fwiw and I’m not a HFT type but am being corrupted due to the session times I’m looking at as a set and forget*cough* process, maybe.

    I’ll look at calls again I think.

    The wall I’m looking at (10k 1min bar count aside) is how bars are read on the closing on the default TF and actioned on the next open. I understand if you run a strat w/o ‘updateonclose’ you can leverage a ‘realtime w/in bar event’ to trigger market orders or est. pending (depending on how borkers (intended) set min. limits). I maybe wrong here but there was discussion that rolling w/o ‘updateonclose’ allowed for some ‘flexibility’ and was a YMMV option (@GraHal). If so, this could be a way of triggering realtime w/o running on the shortest TF.

    I can run my ‘dash’ lets call it on 5min but also need some LTF metrics (this puts me in the doghouse).

    Perhaps I might be able to ‘call’ those LTF metrics in, unsure as they’re a menagerie of:

    IF x and y and z and a and b then ‘draw I’ve gone fishing’ ……

    With the little reading I’ve done PRT likes (appreciates) instrat-code and calls to be at a min., so this might be unappreciated load. Don’t know.

     

    Thanks druby and Peter.

    Hope the above makes sense, might have me Joker hat on  …. hope not .. 🙂

    #234579

    I maybe wrong here but there was discussion that rolling w/o ‘updateonclose’ allowed for some ‘flexibility’ and was a YMMV option (@GraHal). If so, this could be a way of triggering realtime w/o running on the shortest TF.

    You’re implying Indicator code here (that operates at the tick level) but notice that you can’t do anything with that for trading. Net it is so that you only can look at it by eyes, but you can’t do anything with it in code.
    UpdateOnClose only applies to Indicator code.
    Sorry …

    #234581

    Thanks Peter.

    So there’s NO way to trigger opening a position, from w/in an auto-trader, when started on the Default TF on anything other than the DF TF, not lower – it must open at MKT or set Limit upon the opening of the next bar, given metrics are met on xTF within the strategy.

    But you can run HTF metrics on a LTF (MTF) system, so long as you execute on the default TF. If so then the qu. remains on what can be ‘called’ and used and /or whether someone might choose to if it’s a means to overcome X. Needs more thought on my part.

    Yes, you’re correct on the Indicator, now I remember because that’s what I do, and after reading it I thought, ah ok, that’s why I was happy with the prints ….. then I went along the thought pattern of well, if I can print it, surely I can trade it ….. some of which might be possible but not all of it perhaps. Okay.

    I take it you’re strats are mostly single TF. Not a fan of MTF?

    I challenge that re: but you can’t do anything with it in code. Why is it that what’s printable mightn’t be of any use or you can not use it in code, if what’s printable is founded on pre-canned PRT metrics in part. Can you explain why an indicator that prints to screen can not be used in an auto-trader? I think I’ve misunderstood what you’re implying here, even though it didn’t read as an implied opinion, ha … 🙂

    I’m sure that I’ve seen strategies posted that include TIMEFRAME (x x, updateonclose) when defining metrics contained w/in the strategy. Roberto’s Cowabunga Dax as interpreted from Babypips is one I can think of.

    Perhaps you never see it or use it because of <10s systems you employ.

    Bit confused here.

    https://www.prorealcode.com/topic/mtf-with-or-without-updateonclose/

    #234584

    I think its written somewhere in one of the manuals that, the code only executes once per bar. What I didn’t see is, the definition of what a bar was. It wasn’t until I came across various comments, that it started to fall into place.

    PRT, appears to be, an action triggered system, that is to say nothing changes until a tick comes in from the market, the action, for you displayed instrument. Depending on what timeframe your using, the time period is not a bar, its only a bar if a tick is in the time period. This can be proved by plotting the barindex variable. What you will see is it’s value increments by one only when there’s a tick present in the time period. On smaller timeframes, and/or low market action, there can be time periods without candles. When this happens barindex is not incremented.

    It can be confusing because, bar, is generally used as a period of time on the timeframe. However there an operation difference between both.

    Now at the default timeframe level, its not until a tick is received that the new bar starts. At the close of the bar the code is run. At this point any orders will be sent to the broker.

    This is why a market order is set for the open of the next bar period. And there must be a small time delay between close; code run; order sent and order executed.

    Once the orders have been sent to the broker, they will be executed independent of the code. I think some order types life span means they need refreshing every bar.

    If you need to modify, the frequency the code executes, for a trailing stop or something else, the only way is to move to a lower default timeframe.

    This solves the execution problem, but now you conditions are  calculated at the  default timeframe values and periods.

    So the code needs modifying to get the higher timeframe values for the conditions back. The shorter way to do this is with the ‘TIMEFRAME’ instruction.

    Without the ‘UPPDATEONCLOSE’, the higher timeframe values update with the default timeframe updates. With ‘UPDATEONCLOSE’ the higher time frame updates at its close.

    Recently I’ve become aware that, using Timeframe without updateonclose in  a called file,  acts as if were using it, and update only at the close of the higher timeframe close. With it, delays result by another higher time frame period.

    Additionally, moving to back test can cause an error message. Having the timeframe command in the main program and calling from with in it avoids issue.

    What you will find is that you need to run on the lower timeframe, and use the Timeframe instruction for the higher ones. This could be done in one file, however you can call other files from within Timeframe instruction block to avoid back test error message.

    Now, don’t take everything as 100%, because there can be exceptions depending on what your doing and how your doing it. And I have not checked at every point in the system and verified that execution is bar or time. These are some of the guidelines I keep in mind to avoid problems.

     

     

    1 user thanked author for this post.
    #234589

    The simple answer to Inv’s question :

    Your program code (Strategy code !) will not be executed (called) upon the occurrence of a tick (which is Bid, Ask or Trade). It can only be called on timed events (like 1 second, which is the smallest time possible for PRT).


    The confusing will lie in the fact that Indicators and Indicator code do act upon ticks (though ticks for Trades only – not per Bid and Ask). So we can nicely visualize what happens at the tick level be that Trades, but we can not act upon it in anyway (yea, manually – press Buy or Sell).

     

    1 user thanked author for this post.
    #234590

     

    Thanks druby.

    I’m spending a bit of time reading here and there, realising the hole I’m in and how I can string it together, while keeping a family member upright. The thing I find most disappointing is that early 90’s I looked at neural networks to do a few things lets say, 30yrs later I see all the negative comments on interop between providers (brokers etc) and I’m wondering if I’ll ever see a day where ‘normal retail’ investors can access very good DMA tools that are easy to use. Now PRT is a darned sight easier to manipulate than early days ML even for a hack like me but it comes down to the exceptions as you say. Work in progress. Nuances … 🙂

    I was thinking about IB too but I’ve read that APAC (or AUS) customers won’t / don’t have ProOrder capability. Could be a good thing /s

    I’ll take onboard what you’ve said – I’ve found your feedback intuitive, to the point. Thankyou.


    @PeterSt
    , I think I read where you’re coming from. Bit of a conundrum then we have here lol….

     

    #234591

    The answer which requires somewhat more insight is this :

    Yes, I sure use multi TFs in one Strategy. And this is not related at all to where you want to trade per se. Sure, I may use a one second system so I can act as close as I want, BUT this would not allow for nice Trailing systems. So try to grasp this :

    Entries can very well be on the smallest TimeFrame possible (1 second).
    Exits can do that too, but if you want trailing you will need to use a longer TF to give a Pending Order the opportunity to run into your set price. Mind you, I always talk about elf-created trailing here – not any trailing provided by PRT (which exists for IF but does not exist for IB).

    Once you grasp the above, you can hop over to the next step :

    Which TF is used for what is thus up to you. Notice though, that the longer TF is commonly used to to the math on averages etc. Like 1 hour or 15 minutes (or days, whatever).
    Meanwhile you can trade at the 1 minute level; same as I explained above (though above differentiated between Entry and Exit).
    This now enters the realm of “shall I thus use a longer TF for the averages and such ?” … my answer : yes, but only *if* you still have the opportunity to trade at the shorter TF and still have sufficient backtest data. And there it goes wrong;

    I said it more often, people tend to propose the trading at the 1s level as the one all be all solution, but that is no solution at all and people should stop proposing it. Thus :
    If I’d use a 1s TF for trading, I’d have 12 days of backtesting data (eh, with Premium that is – otherwise 1/5 of that). If that copes with your averages calculations, then fine, but forget about e.g. an average for 30 days with a (multi) TF of 1 day, because it’s just not there (because only 12 days are there).

    Now you know all, right ?
    😉

     

    1 user thanked author for this post.
    #234592

    I can probably live with 10-12days 1min (but that’s >10k preload).

    I think I’ve landed on this:

    This now enters the realm of “shall I thus use a longer TF for the averages and such ?” … my answer : yes, but only *if* you still have the opportunity to trade at the shorter TF and still have sufficient backtest data. And there it goes wrong;

    And;

    If I’d use a 1s TF for trading, I’d have 12 days of backtesting data (eh, with Premium that is – otherwise 1/5 of that). If that copes with your averages calculations, then fine, but forget about e.g. an average for 30 days with a (multi) TF of 1 day, because it’s just not there (because only 12 days are there).

    So today I moved to 5min (10K bars, needs much less than this) where so far I’ve been able to scale it where I want it – less the entry LTF, and so round we go again. Going backwards here (shakes head) … I could maybe generate an event at a LTF easily enough but it’d be superfluous given while it’d trigger the condition ‘sooner’, it will not send the order sooner. I will look at what @druby said and perhaps I could ‘call’ conditions however would need to be aware of what they said above in it’s entirety (needs going over by me).

    The challenge is there.

     

     

    #234595
    JS

    If I back test 1 million units (RTH) with a time frame of 1 second, then I have 3,5 months of (back test) data at IB… (screenshot) and 2 months (back test) data at IG…(screenshot)

    I use a “Trailing Stop” with (1 second pending) Stop orders in both cases and for IB and IG this is no problem at all …

    1 user thanked author for this post.
    #234614

     

    That’s good to know JS. You’ve taken pity on me … thankyou … and jogged my memory …  🙂

    So at IG (I’ll assume you’re on Premium) and from what Peter has said above (Complete = 1/5 of Premium re: available data (unless I have that wrong re: backtest)) and that’d give me ~12days @ 1s. Okay. There is the 10k preload but given those numbers marry with me needing another ~2k bars it could workout ok.

    From memory I started this journey on 1s and then wound it up to 1/5m because of the chart load times, so I might need to revisit it at 1s again. This all came about when v12 was made available and the platform had become almost unusable at one point. Quite a bit has changed since then and maybe, just maybe, the process will run ok in 1s but because it’s run on server-side and I was giving too much attention to client side performance and I got caught in the spin cycle of attempting to find a ‘faster’ way to POC. Oh Dear…..

    Well there you go, just loaded two one bundled metrics on 1s and the prints marry across TF 1s, 1m and 5m. 200k ‘units’ 1s, will see if I can reel that in a little. APAC open will prove how this reacts, so to EU – bit of US noise about this week so should drive the setup pretty hard.

    Then there’s is issue of whether it can be read w/in the TF in an auto-trader. For the most part they’re static states that are leveraged by other metrics nothing heavy.

    If I could get it to rock n roll on a much lower bar count that would also be a bonus and I’ll have to see what I can learn over the journey. I also read a post/blog maybe somewhere where there’s some benefits to be had with dirty code, specifically how it can improve PRT read/exec time, I think related to server side.

    Thanks again for posting JS, you managed to trigger ‘old’ memories ….

     

     

    #234615

     


    @druby
    going over your comment re: bar vs tick vs my lack of IP, yes, I can see what you mean here, a bar isn’t considered that until ticks register (which makes sense and PRTs use of units) however because of this, there are then, lets call them, periods of inactivity when no ticks have registered and the effect is we’ve not incremented barindex but time has elapsed. This then perhaps leans into some of the data padding comments from Peter too. How does this affect preload in a system I wonder, with respect to what a 10k bar preload at 1s looks like in terms of time elapsed – re: when the bar is created vs time gaps in creation vs the dataset and what it constitutes? Could be it’s all sanitised somehow, capped at 10k units no doubt but what does that mean, padded or else. Sexy concepts (for me) … thanks for the clued-in posts!

    #234616

    In my printing indicator journey :), I’ve seen exactly what you mean druby just now gaps in time vs barindex on 1s.

    #234617

    Well, if one uses RTH as the basis, then you’d have more trading days. But who is going to do that ?
    With ETH – which IMO would be the normal thing to do – it’s 1000000 / 86400 = 11.57 trading days which I round up to 12 because a trading day comprises of 23 hours and not 24.

     

    I use a “Trailing Stop” with (1 second pending) Stop orders in both cases and for IB and IG this is no problem at all …

    a. it won’t bring a thing when you trail at one second because at the first bar the Exit will be there (you can’t trail with one second at one second bars);
    b. With IG that will be fine but with IB it won’t run for an hour before your system is kicked out because of communicati0n error with the broker.

    Both reasons are easily debunked by showing it. But mind you, in Live because #b will be fine in Demo.
    Thus, show it ?

     

     

Viewing 15 posts - 31 through 45 (of 52 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login