Hi guys
I’ve reach a problem when I want to do something with 2 timeframe (very simple…).
I saw in some others strategy that it’s possible to share and use a variable of a specific timeframe in an other one.
But in my case an error message say that I cannot and that I can read variables of others timeframe.
This is my little example :
// PING PONG AI - V2 TER
Defparam cumulateorders = false
ctime = time > 083000 and time < 180000
if not ctime then
limitH = 0
//limitB = 0
endif
timeframe (1hour)
IF Openhour <> openhour[1] THEN
myLastHigh = myHigh
myLastLow = myLow
myHigh = High
myLow = Low
ELSE
myHigh = Max(myHigh, High)
myLow = Min(myLow, Low)
ENDIF
if myLastHigh > Myhigh and myLastLow < myLow and ctime then
limitH = myHigh
//limitB = myLow
endif
timeframe(default)
c1a = close crosses over limitH
//c1v = close crosses under limitB
if c1a and not onmarket then
buy 0 contract at market
set stop ploss 500
set target pprofit 500
endif
Do you know the good way to share the parameters with my default timeframe ?
Thanks in advance,
Variables need to have exclusive names for each Timeframe, you can’t share the same name.
So for example you could name limitB as
hourLimitH under the 1 hour TF and minLimitH under a 10 minute TF.
You can READ variables from any TF, but they must be created (and their contents changed) in only one TF!
You can follow GraHal’s suggestions to keep names quite similar still different.
Nevermind !
I found why it was not working.
On line 6 to 8 I reseted the value “LimitH” but not in the good timeframe…
Sorry for this bad mistake 🙂
Thanks for the support guys 🙂