Am I over-simplifying your question (and missing the point? : ) ) … why not include times in your Algo codes so that trading occurs ONLY during the Cash Session?
Hi GraHal
Thank you for idea – I tried that but does not address issue. When I write an algo that says if close < close[1] or an indicator that derive it value from close, this is where the problem is. Close price on IG at midnight, not 22:00. Values are always different, introduce creep into prices which over time erode performance.
If I draw RSI[14] it take close price from IG, which is at midnight again, not 22:00. So even RSI value different to that of cash session.
What timeframe are you using on your Platform.
If you use 1 Hour timeframe then time can be to nearest hour, if you use 5 min timeframe then time can be to nearest 5 mins etc.
Timeframe(1 Hour, updateonclose)
If Time = 220000 and close < close[1] Then
Sell at Market
Ensdif
Thanks GraHal
In code you show, would close[1] just be close of last 1 hour candle? So close at 21:00 same day?
Yes
My code suggestion won’t work if you are using ‘end of day data’ … are you??
Most of us with IG have full data (i.e. not end of day only)
Hi GraHal
I have full data. That not the issue. I can run algos on full data (continuously priced CFDs from IG 24/7 from Monday to Saturday) but performance worse than if I run same algo on actual stock market times (15:00 to 22:00).
Seems to be no way to reflect real market, or store market price at time of open (15:00) and close (22:00) each day to refer to instead.
Ok, I go back to other platform / broker for these algos
I am grateful for everyone help and quick ideas, thank you
Seems to be no way to reflect real market, or store market price at time of open (15:00) and close (22:00) each day to refer to instead.
So just to close the loop before you go … what was wrong with my idea … use Times in your code?
You can read and store (in your code) OHLC values at 15:00 and 22:00 … if you ask on here somebody will code it for you I’m sure.
Yes – I think we are on the same page now, but I still wait for someone to kindly show me how to code 🙂
Thank you again for help
It be best to open a new Topic with a Title which describes what you want, e.g.
Please – Code to Store OHLC values at Cash Market Hours.
Then you state what you want and the hours etc.
There are a few very helpful members on here, but they need a specification in words as to what needs coding else they may waste their very valuable time.
It’s also useful to be brief and to the point exactly what you want.
I just read back over your posts in this Thread and – am I understanding correctly – you want every OHLC value at open and close of cash session / exchange market hours … what, for the past month, 12 months or just yesterday??
Code would be very cumbersome to capture more than a few days worth of OHLC values.
Anyway, further discussions would be best in a new Topic if you want to continue?
If you’d ask me … this is ridiculous. After a handful of posts it was totally clear what needs to be done. Why open a new topic for it ?
It is only that apparently nobody likes to do it. Or can do it ? This includes me, and I told so (it would be the first from my hand as I exactly never do these things in this forum).
Loop from 15:30 to 22:00 and register OHLC within that period. Actually High and Low would be sufficient, me thinks.
I recall that Fritz suggested that IBKR / PRT-IB would be able to do that automatically, but this is not something I automatically recognize. This is because ETH is explicitly dealt with by PRT, although that is a setting (want to trade ETH Yes/No). Thus, TF = 1 Day and then e.gf. High(Close[1]) ? I bet you that does not work out as desired; it will just incorporate the bars until 00:00.
Maybe nobody provided code because
FritzAlgo never made it clear what he wants?
If all he wants is to open a Buy if Cash Open > Cash Close yesterday and Sell if Cash Close < Cash Close yesterday then that is easy.
For everything a first time.
Once MyOpen = 0
Once MyHigh = 0
Once MyLow = 999999
Once MyClose = 0
If Time = 153000 then
MyOpen = Open
endif
If Time = 220000 then
MyClose = Close
endif
If Time >= 153000 and Time <= 220000 then
MyHigh = Max(Close, MyHigh) // Could be refined with Range and such.
MyLow = Min(Close, MyLow) // Ditto.
else // Reset all.
MyOpen = 0
MyHigh = 0
MyLow = 999999
MyClose = 0
endif
If MyOpen <> 0 then
graphOnPrice(MyOpen) Coloured("Green") as "Cash Open" // Comment the others out and leave one active, views more comfortable.
endif
If MyClose <> 0 then
graphOnPrice(MyClose) Coloured("Yellow") as "Cash Close"
endif
If MyHigh <> 0 then
graphOnPrice(MyHigh) Coloured("Red") as "Cash High"
endif
If MyLow <> 999999 then
graphOnPrice(MyLow) Coloured("White") as "Cash Low"
endif
Of course it requires some more, like undoubtedly the requirement to look at the High etc. from the previous day.
FritzAlgo Peter’s kindly provided code needs to be run on 30 minutes or less Timeframe.
Hello
PeterSt
Thank you very much, I am so grateful to try. Sorry, I tested positive yesterday and not feeling good so will go back to testing early next week I hope. I will come back here and share results. Excited to try