Hi Everyone,
I have tested a code in the backtesting environment and it worked well.
when I tested it today in the proOrder autotrading it totally ignored my TimeFrame command
The code is something like this:
TIMEFRAME (30 minutes,updateonclose )
//check cond and set signal 1 or -1
TimeFrame(default)
//if -1 do...
//if 1 do ...
I run it on a 1 min TF and at the end of every 1 min bar it gave me a new signal (instead of giving a new signal every 30 min)
I read in the forum a question about it in 2018 and it said TF will be enabled soon. so I guess they are long live by now, but this is my first attempt with them (so far I love them!)
That’s correct, if you run it from 1-minute TF it may enter 30 times.
You have to write code non to!
If you post an idea I may help you.
So I am confused.
Why does TM exist in the first place if it can not work in the “real world”?
is TF for testing purposes only?
You can use anything in real trading, provided it is used correctly!
Examples (both tested on DAX, 1-minute chart):
// This version may enter severeal times on the same signal
//
DEFPARAM CumulateOrders = false
TIMEFRAME(4 hour,UpdateOnClose)
CrossOver = close crosses over average[10]
TIMEFRAME(default) //say 1-minute TF
if CrossOver and Not OnMarket then
buy at market
endif
set stop pLoss 20
set target pProfit 40
// This version may enter only once on the same signal
//
DEFPARAM CumulateOrders = false
TIMEFRAME(4 hour,UpdateOnClose)
CrossOver = close crosses over average[10]
TIMEFRAME(default) //say 1-minute TF
ONCE TradeON = 0
IF CrossOver AND Not CrossOver[1] THEN
TradeON = 1
Endif
if CrossOver AND Not OnMarket AND TradeON then
buy at market
TradeON = 0
endif
set stop pLoss 20
set target pProfit 40
It’s basically the same code, but I have added some code, in te latter, to avoid re-entering on the same signal.
You can do (almost) anything using the correct code to!
Thanks,
But I’m still confused. what is not “correct” with the code I tried, that worked in the test environment?
Just to be clear, the TimeFrame 30 is chaging the MyRSI paremeter every minute. one bar it sets it to buy, the next to sell again and again. whereas the plan is to set the MyRSI once every 30 minutes and get into a trade (or leave it) when the other conditions are met.
to put it simply: I don’t understand why it would change the myRSI signal every minute not every 30 min. again, in test it works fine only in the proauto trading platform it does not. which led me to believe the problem is in the settings.
//this should occur only every 30 min - but in fact this is activated every minute on a 1min TF
TIMEFRAME (30 minutes,updateonclose )
MyRSI = RSI[5](close)
IF MyRSI>50 THEN
Signal = 1
ELSIF MyRSI<50 THEN
Signal=-1
ENDIF
//this should occur every minute
TimeFrame(default)
IF Signal = 1 THEN
IF SHORTONMARKET THEN
EXITSHORT AT MARKET
BUY StakeSize CONTRACTS AT high+EntryBuffer stop
SET STOP LOSS high-low+2*EntryBuffer
ELSIF NOT ONMARKET THEN
BUY StakeSize CONTRACTS AT high+EntryBuffer stop
SET STOP LOSS high-low+2*EntryBuffer
ENDIF
ENDIF
IF Signal = -1 THEN
IF LONGONMARKET THEN
SELL AT MARKET
SELLSHORT StakeSize CONTRACTS AT low-EntryBuffer stop
SET STOP LOSS high-low+2*EntryBuffer
ELSIF NOT ONMARKET THEN
BUY StakeSize CONTRACTS AT low-EntryBuffer stop
SET STOP LOSS high-low+2*EntryBuffer
ENDIF
ENDIF
No, UpdateOnClose will allow changing MyRsi when the 30-minute candle closes.
Append
GRAPH MyRsi
to your code to monitor its value each 1-minute candle in the variable window opened by ProBackTest.
I think that is the problem.
in the test environment I used GRAPH of course, and it works fine.
In the AutoTrading environment I can’t use GRAPH and it doesn’t work as intended.
There is something basic here that I seem t be missing.
Here is the GRAPH output.
RSI changes value every 30 minutes on a 1min chart.
Yet in the AutoTrading it changes the value every 1 min.
Again, my guess is that something is wrong with the AutoTrading settings and not the code
How do you know it changes every minute?
I realized it was a bug in the code. not a problem with TF. Thank you very much for your help…
aland – Not sure how this topic went quite so far without anyone spotting that you posted it in the wrong forum but you did! ProBuilder where you posted it is is for indicator topics and ProOrder is for strategy topics. I will move this topic but please try to post in the correct forum with any future topics.