I am wondering how would I setup a strategy that will signal based on consecutive closes. An example would be say I want a buy signal to be 3 consecutively higher closes followed by two consecutive lower. further example:
Monday close = 10.00
Tuesday close = 10.25
Weds close = 10.34
Thurs close = 10.20
Friday close = 10.16
I hope this makes sense. I don’t understand how to turn that into code that seetu can use to generate a signal. thanks in advance!
Say we are running this code on Monday.
The last bar in the database is Friday.
Last Friday is Close
Thursday is Ref(Close,-1)
Wednesday is Ref(Close,-2)
Tuesday is Ref(Close,-3)
Monday is Ref(Close,-4)
Friday is Ref(Close,-5)
// Buy signal
Buy = Close < Ref(Close,-1) // Last Fri < Thu
Ref(Close,-1) < Ref(Close,-2) // Thu < Wed
Ref(Close,-2) > Ref(Close,-3) // Wed > Tue
Ref(Close,-3) > Ref(Close,-4) // Tue > Mon
Ref(Close,-4) > Ref(Close,-5); // Mon > Fri
// Show signals in Exploration:
Filter = Buy;
AppendColumn(Close,“Last Fri Close”);
thanks. worked perfect. I actually made a mistake on which days needed to be higher/lower but I have it fixed now.
How can I tell it to short shares instead of selling? or buy options, I would prefer options but I cant find anything in the reference for them.
for instance, a buy signal is generated, I want to buy a ATM call option with a minimum of 30 days to exp maximum of 90. then when a sell signal is generated I want to see the call option and buy a ATM put option and continue vice versa.
A type of order (Buy, Sell, Short, Cover) is determined by the SignalType parameter in “C2TradingSignal”.
Use sigBTO, sigSTC, sigSTO or sigBTC parameter.
That “option stuff” looks interesting. But it also looks like a lot of work on our side…
I can’t give you any promise.
I think it needs two things:
- to add a new parameter “Symbol” to the “C2TradingSignal” function. This parameter will allow to change the symbol for which a signal will be generated.
- to create a function findEquityOption( Type, NearMonths) which returns some option symbol.
(Where Type is “Call” or “Put” and NearMonths is a number of months.)
Returned option symbol will be used in the C2TradingSignal function as a new symbol.
OptionSymbol = findEquityOption( “Call”, 3);
C2TradingSignal(sigBTO, Symbol = OptionSymbol )
Do you think it is what you want?
I would just add:
The user of the findEquityOption function probably wants to specify that he wants an at-the-money option. So the Seetu function name ought probably be something like:
findATMoption(underlyingSymbol, putOrCall, 3);
ok cool, c2tradingsignal but how can I backtest that? I got it to generate STO signals under “signals” tab but when I go to statistics it shows nothing under short trades. ideally I would like to be able to backtest a strategy where a buy signal signifies purchase and a sell signifies shorting 100% of the shares we purchased at last buy signal.
as far as options, I really just want to be able to backtest a strategy where instead of purchasing shares, you purchase contracts. so I would guess,
under “buy=” then you would have to have "AND get ATM call option min. 1 month out. AND exit put options IF any are held"
vice versa for sell. sorry im not a programmer so its hard to explain. haha
thanks for the help though made me some money today from the signals I picked up on Friday by purchashing ATM options at open. so I know it works! haha
yes, but then you would have to determine what ATM means, I wonder if it would be easier to have a number and ITM or OTM.
where F = symbol and “30<=” equals days to exp.
Be sure you are using correct variables.
“Buy” means “open a long position and test it in Seetu (Backtest)”
“Sell” means “close a long position and test it in Seetu (Backtest)”
“Short” means “open a short position and test it in Seetu (Backtest)”
“Cover” means “close a short position and test it in Seetu (Backtest)”
To generate and see all trading signals use:
C2TradingSignal(sigBTO, sigfilter = Buy); // open a long position on C2; see all trading signals
C2TradingSignal(sigSTC, sigfilter = Sell); // close a long position on C2; see all trading signals
C2TradingSignal(sigSTO, sigfilter = Short); // open a short position on C2; see all trading signals
C2TradingSignal(sigBTC, sigfilter = Cover); // close a short position on C2; see all trading signals
- “C2TradingSignal” uses “Buy”, “Sell”, “Short”, “Cover” under hood:
C2TradingSignal(sigBTO) generates signals where “Buy” is TRUE
C2TradingSignal(sigSTC) generates signals where “Sell” is TRUE
C2TradingSignal(sigSTO) generates signals where “Short” is TRUE
C2TradingSignal(sigBTC) generates signals where “Cover” is TRUE
- “sigfilter” is not necessary. It just drives visibility of signals on the “Signals” page.
Used as in the example above means: show me all signals.
ah ha… I was not. now it generates short trades as well as cover. But under statistics it shows 0 short trades. ill use an example here
// Buy signal
Buy = Close < Ref(Close,-1)…
Sell = Close > Ref(Close,-1) …
Short= Close > Ref(Close,-1) …
Cover= Close < Ref(Close,-1)…
I didn’t want to take up all kinds of space writing it out. right now I have 4 separate signals like above. it shows all 4 but it doesn’t backtest the way I would like. im a little confused about how to write out what I would like it to do.
IF buy signal, then open new long position or Cover shorts
IF sell signal then close long positions and open shorts
I hope that makes sense.
My fault. Sorry. Try it now.