ballingerchief
Apr 28 2011, 02:12 PM
HI!
I am new to this forum but not VT Trader. I have been trading since 2006. I am looking to create my own trading system. I am just now getting familar with Java and also VT Scripting language. I think I can get around but I have no programming experience. I am looking to creating the following system:
______________________________________________________________________________
If 'Condition A' is met after a certain number of bars (of my choosing), then trade long or short.
Else, don't trade. If 'else' is the case then look for 'Condition A' again after a certain number of bars.
______________________________________________________________________________
I don't need anybody to write the TS for me, I just need to know where to start with such a trading strategy. (Functions and the like). I have read all of the needed manuals and material on how to create a trading system so I am somewhat familiar with syntax and how things work. I just need a push in the right direction.
I greatly appreciate any help! Thank you.
-K
cskidmore
Apr 29 2011, 08:36 AM
Hello,
Welcome to the forums. Would it be possible for you to be a bit more specific with what you require? When you say "if condition A is met after a certain number of bars", what's your reference point/condition to begin the bar count?
Regards,
Chris
ballingerchief
Apr 30 2011, 10:39 PM
Hi Chris.
Thank you for the quick response.
Simply put, condition A will be looking at the highs and lows of the day, week, etc (depending on the chart I am on).
Thanks in advance,
-K
cskidmore
May 2 2011, 09:44 AM
Hello,
If these values are dependent on the chart interval you're looking at, then is it safe to assume that you'll be looking at the high/low prices over n-bars previous to the current bar? I still need to understand what 'event' triggers your bar count to begin looking for 'condition A' though.
As an example, let's just use the "Close" price crossing above the high of the most recent 5 bars (not including the currently forming bar) as the 'event reference point'. When this event happens we'll begin looking for 'condition A' (whatever that might be for you).
Event:= Cross(Close,ref(HHV(H,5),-1));
BarsSinceEvent:= BarsSince(Event=1);
ConditionA:= "your condition" AND BarsSinceEvent<="your number of bars";
Note: "your condition" and "your number of bars" would be substituted with your actual requirements.
Depending on your actual needs such logic may or may not work for you, but this example should get you pointed in the right direction I hope.
Regards,
Chris
QUOTE(ballingerchief @ Apr 30 2011, 11:39 PM)

Hi Chris.
Thank you for the quick response.
Simply put, condition A will be looking at the highs and lows of the day, week, etc (depending on the chart I am on).
Thanks in advance,
-K
ballingerchief
May 3 2011, 02:25 AM
Chris,
I believe that might do it. I appreciate you help very much.
-K
cskidmore
May 3 2011, 09:16 AM
You're welcome.
Regards,
Chris
ballingerchief
May 16 2011, 03:06 AM
Hello Chris!
I seemed to have hit a snag. I am incorporating the if() function into my programming. The thing is, if the "then" part of my if() function is not met after a certain amount of time (or bars), I need the TS to move onto another if() function (which would be the "else" of my original if() statement). Now, I cannot seem to find an appropriate function. My hunch would be to use the timing functions. I tested around with the timing functions such as hour(), minute(), and day(), but to no avail. Am I looking in the right area?
I do hope I haven't made things too confusing. Thanks in advance for any assistance.
-K
cskidmore
May 16 2011, 11:35 PM
Hello,
You might try using the SignalHold() or BarsSince() functions depending on what you're trying to accomplish.
Regards,
Chris
ballingerchief
May 17 2011, 01:39 AM
Chris.
Thank you again for the help! That looks promising. I can only imagine the look on your face with some of the questions you get. LOL
Thanks again,
-K
cskidmore
May 17 2011, 08:17 AM
You're welcome.
Regards,
Chris
ballingerchief
May 17 2011, 01:47 PM
Chris,
I was playing around with your suggestions and I am having more problems the deeper I delve into my TS formulation. No worries, your suggestions are most informative and I'm going back to the drawing board. I understand it would be simple to just ask for my TS to be coded, but where is the challenge in that?
Without getting too much into the details can you give me a template (as best you can) that would fit the following criteria-
--------------
If “condition” is met within 1 hour of autotrade initiation (or last long/short position), open long/short. Else, goto next line of code.
--------------
The keyword is "WITHIN 1 HOUR" as my TS is time sensitive. "Open long/short" is obviously dependent on the condition and I believe I have a firm grasp on said "condition". I am most concerned with the part of my formulation that will deal with the "within 1 hour".
It would be ideal if the template is worded with functions represented as needed.
Again appreciated,
-K
cskidmore
May 18 2011, 10:25 AM
Hello,
Do you run the trading system on any specific chart interval (or more than 1 chart interval)? If it's only 1 chart interval it may be possible to do what you require with a reasonable degree of accuracy using "time".
Regards,
Chris
QUOTE(ballingerchief @ May 17 2011, 02:47 PM)

Chris,
I was playing around with your suggestions and I am having more problems the deeper I delve into my TS formulation. No worries, your suggestions are most informative and I'm going back to the drawing board. I understand it would be simple to just ask for my TS to be coded, but where is the challenge in that?
Without getting too much into the details can you give me a template (as best you can) that would fit the following criteria-
--------------
If “condition” is met within 1 hour of autotrade initiation (or last long/short position), open long/short. Else, goto next line of code.
--------------
The keyword is "WITHIN 1 HOUR" as my TS is time sensitive. "Open long/short" is obviously dependent on the condition and I believe I have a firm grasp on said "condition". I am most concerned with the part of my formulation that will deal with the "within 1 hour".
It would be ideal if the template is worded with functions represented as needed.
Again appreciated,
-K
ballingerchief
May 18 2011, 06:18 PM
If possible I would like to be able to do it on different intervals. I imagine the formulation can be tweaked according to interval. But for the sake of figuring things out, let's begin at the one minute chart. Thanks.
-k
cskidmore
May 18 2011, 10:57 PM
This is a tricky one. I think the best suggestion I can make is to use a bar count to simulate the "within 1 hour" logic requirement. This would entail manually providing this value using an input variable that is dependent on the chart interval the system is being attached to. For example, if attached to a 5-minute interval, the bar count for 1 hour would be 12 (i.e. there's 12 5-minute bars in an hour). We can then use the BarsSince() or SignalHold() functions to check your condition against the number of bars that have passed since the 'event' that triggers the count occurred. If this seems like a workable solution, then the next issue is to determine what "event" triggers your 'bar count' to begin.
Can you provide any additional details as to what we might be able to use as an 'event' that we can begin to base our bar count off of? We cannot use the 'activation of the trading system' for this since there's no way to get the time the system is started into the system's logic. And, even if we could that start time only happens once so it would not work for any signals beyond the first one given after the system was started.
Regards,
Chris
ballingerchief
May 18 2011, 11:40 PM
You've read my mind. The activation of the TS would have been when the bar count (or timing) would start. Hmmm...well what if the TS resets at a certain time of day (ie after a certain number of bars)? If this cannot be done automatically, I can accept a TS that I would reset myself at a certain time or after a certain number of bars have passed. Either choice will be regardless of open trades. Open trades won't affect my TS.
cskidmore
May 19 2011, 09:18 AM
It's a bit easier to identify a recurring time event. For example, let's say that we want to identify the bar that closes at 8:30AM (or at least the first available bar with that closing time or more recent in the case of chart intervals that might not have a :30 closing minute in their time stamp. We can do something like this:
TimeEvent:= Cross(Hour()=8 AND Minute()>=30),0.5);
//the hour and minute values should be made input variables so you can adjust them as needed for your chart interval
BarsSinceTimeEvent:= BarsSince(TimeEvent=1)<=12;
// on a 5-minute chart interval, create true condition for the next 12 bars or ~1hour; this barssince value should also be made an input variable
FinalConditionCheck:= BarsSinceTimeEvent=1 AND yourconditionhere;
// checks to ensure condition will happen within 12 bars of your designated 'time event'
Regards,
Chris
ballingerchief
May 30 2011, 09:38 AM
Almost finished! I have just one last question. I was trying to get the formula for volume, but it looks like it is an array or constant. Do you know the formula for volume? I'm looking for the actual formula, not what is in the indicator formula. -K
cskidmore
May 31 2011, 10:00 AM
The Forex market has no centralized volume data so what is used in VT Trader's scripting language as "volume" is simply the number of price changes (ticks) in a given bar/candle as provided by CMS Forex's demo services.
* It should be noted that once the Forex.com integrated version of VT Trader is rolled out, the "volume" function will no longer be available since Forex.com's backend services does not currently provide that data. However, through a bit of trial and error, I determined that a 2-period ATR reading gives a similarly shaped indicator output/curve (obviously different data values) as the current CMS "volume" data. That idea may be worth exploring in your trading system logic as well.
Regards,
Chris
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please
click here.