Entry/Trigger price and time of an indicator

Moderator: admin

Entry/Trigger price and time of an indicator

Postby Hug Coder » Fri Jan 13, 2012 6:07 am

Hi!

Okay, so what I'm trying to do is to modify an indicator. This has been done quite successfully, just using text editors. However, I cannot seem to achieve quite what I want, at a closer look.

1. How do I obtain the market price at which the indicator actually triggered? (also historically) I.e. what price made the indicator trigger?

I have tried with bid.close[period] and source.close[period] and median and so on. Nothing actually saves the entry value, even if I try to only obtain the value at the trigger (it draws arrows up/down for buy/sell for a period). It just takes the candle and uses the close value, not where it actually triggered. Only for the most current period it works as intended, but at update the graph it takes the close price instead. I also tried instance.bid[instance.bid:size() - 1] (from documentation), but that even gave me an error saying it doesn't return a number.

2. How do I time stamp the entry/trigger of the indicator with hour:min:second resolution?

All I have achieved is time stamps with resolution of what the actual time frame I'm looking in. So if my indicator triggered at 11:13:21, it will in 1 min show 11:13:00, 5 min 11:15:00, etc..
Hug Coder
 
Posts: 38
Joined: Fri Jan 13, 2012 5:43 am

Re: Entry/Trigger price and time of an indicator

Postby Apprentice » Sun Jan 15, 2012 4:28 am

You can use something like this.


local date;
if core.crosses(FirstStream, SecondStream, period) then
date = core.dateToTable(source:date(period));
local hour = date.hour
local minute = date.minute
.....
end


For more info use SDK Documentation.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36478
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: Entry/Trigger price and time of an indicator

Postby sunshine » Tue Jan 17, 2012 1:14 am

If you need to know exact price/time when the update function of indicator is called, you should apply the indicator on ticks (use "indicator:requiredSource(core.Tick)"), not the bars.
When you apply the indicator on historical bars, the update is called for each bar only. The bar is not divided to ticks.
sunshine
 

Re: Entry/Trigger price and time of an indicator

Postby Hug Coder » Fri Jan 20, 2012 7:30 am

Appentice:
That's what I have achieved already. I can time-stamp the candles, but not the exact time it triggered.

sunshine:
I have thought about that too. I guess I would have to read the seconds from the Ticks, but... If I use "indicator:requiredSource(core.Tick)" I get an error at the line "bid = core.host:execute("getBidPrice");".

From what I understand "indicator:requiredSource(core.Tick)" will make every instance.source:**** entry to take it's value from Tick. But the indicator is using the Bars... so how would they be mixed? How do I take the time from Tick (when Ticks are available) but everything else from Bars?
Hug Coder
 
Posts: 38
Joined: Fri Jan 13, 2012 5:43 am

Re: Entry/Trigger price and time of an indicator

Postby Apprentice » Sun Jan 22, 2012 5:10 pm

You would need to record, time server in a variable, or display it on char.
Write an algorithm that allows only one signal per period.
That is, after receiving first signal, the subsequent signals should be ignored, for that period.
Data source Type is not crucial.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36478
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: Entry/Trigger price and time of an indicator

Postby Hug Coder » Tue Jan 24, 2012 6:03 pm

Apprentice:
Yeah, I guess something like that works. But that would still be obsolete for any update, since historically it wouldn't be exactly the same trigger point, since the indicator takes closed candles into account. But as long as I wouldn't update I guess it could work. But right now I have settled with recording only Hour:Min, no seconds. Seconds are only worth recording for 1 min chart analyzing and it's not that important for my indicator anyway. I prefer following the 5 min and higher timeframe charts for this indicator.
Hug Coder
 
Posts: 38
Joined: Fri Jan 13, 2012 5:43 am



Return to Indicator Development

Who is online

Users browsing this forum: No registered users and 67 guests