views:

421

answers:

4

I am working with an Oscillator that fluctuates between 10.000000 and -10.000000

The value changes say every 5 minutes. I want to find the difference between the current value and the value of 5 minutes ago. Here is my logic.

1 bar ago (1BA)= -.2
Current bar (CB) = .3

Wouldn't I get a value of 1 if I did something like:

Abs(CB) - Abs(1BA) = .3 - .2 = 1

Whereas:

Abs(CB- 1BA) = .3 - -.2 = 5

I want to simply calculate the difference between the move of the oscillator from one time frame to another. Am I applying the Abs with the right logic in mind?

Here is my actual code, please assume my method being called is correct:

if (Oscillator(PoFast, PoSlow, PoSmooth)[0] > 
           Oscillator(PoFast, PoSlow, PoSmooth)[3]
    && Math.Abs(Oscillator(PoFast, PoSlow, PoSmooth)[0] - 
           Oscillator(PoFast, PoSlow, PoSmooth)[3]) > .25)
+5  A: 

Of the two, Abs(CB-1BA) would be correct, since there was a change of .5 between the two readings.

EDIT: To make it more readable, and assuming you're getting double values, you'd do something like this, but with error checking, and probably making the .25 a variable.

double[] values = Oscillator(PoFast, PoSlow, PoSmooth);
double currentBar = values[0];
double oneBarAgo = values[3];

if (currentBar > oneBarAgo && Math.Abs(currentBar - oneBarAgo) > .25)
{
    // do something
}
Chris Doggett
+2  A: 

Your logic, Abs(CB-1BA) is correct.

As an aside, if you're not a developer do you really think you should be writing C# code to trade futures contracts? They're risky enough to trade at the best of times, never mind when you're writing code to do it and you're not a developer!!!!

Sean
Agree. @r2kTrader: please tell us what company you work for, so we can be sure not to buy futures contracts from you.
John Saunders
Wait, would you trust trading software written by a programmer who knows nothing about the market?
Bill the Lizard
As an developer working on a trading floor, I can tell you that traders write some "basic" excel applications for their needs.But yeah, most of the time, it is awful when we have to maintain their code ^^'
A: 

LOL!!

This website is absolutely the best.

I am using a platform that allows me to write logic using C#, I am not writing the actual software that speaks with the Brokers' API.

So there are a series of pre-defined classes or a library if you will, that allows me to apply my trading logic using a layman's approach. So while it requires some basic programming skills (which I have), it doesn't require me to be a programmer per se.

What I didn't want to do was have my question start a thread about trading, lol. Oh well.

I would not attempt to write a trading platform. Think EasyLanguage for TradeStation as an example. I don't need to be a programmer to apply a simple MA CrossOver system and backtest 4 years.

Didn't mean to start any trouble. Thank you for the answers though. I also appreciate the code suggestions. Thank you so much all!

A: 

tvanfosson & Chris Doggett (and Matt Cane),

Thank you so much for the help. I am studying C# and there is a lot to absorb, so your suggestions are extremely helpful in regards to improving my approach.

I tried to up you both, but I don't have the power yet. Thanks again~!