Easylanguage Question

flipflopper

Newbie
Messages
8
Likes
0
This is a two part question:

I have 3 variables that I want to use to make buy limit orders(Call them moving averages). My approach to this has been to try and find the closest support point to the current market price and create a limit buy order at that variable support price.

Question 1:

I have been trying to create code that will tell me what the closest support point is under the current price and put a limit buy order at that price. If that order gets filled then find the new closest variable for a buy price, etc. Is this the best way to accomplish this? Is there some sort of function that will tell me what I need to know?

Question 2:

Lets say one of the variables is 1142.58. And I do a limit at that price in the ES futures which increments in .25. Will the order be 1142.50 or 1142.75? Also how can you make your order round up to the nearest tick.
 
Q 1
The question really isn't an Easylanguage question. What you need to do is write down the rules in plain English for the closest support point. If you can do that first, the coding will be easy. If you can't, then you are effectively asking the board to implement your ideas for free.

Q2
Either is fine - you can code to do regular rounding, round up or round down.
 
With regards to question 1, I would think this would be a common objective for many trading strategies. I am not trying to "have someone write my code for free." I am simply asking for suggestions. Maybe there is a built in function that would help me out greatly. I just can't think of any efficient conceptual way to code this.

If anyone else has dealt with this let me know what you think.
 
flip flopper - look for code that finds swing highs & swing lows and that will set you on the path for Q1.
 
flipflopper - I'm not going to give the code away - you may have to adapt these somewhat.

In my experience - what you need lies in the area of code for finding swing highs/lows.

Look around teh interweb - you will find better swing high/low finders that comes out of the box with TS
 
Trust me. You must have misunderstood what I am trying to accomplish.

I am looking for help from someone who has coded something similar and understands what I am asking.
 
Trust me. You must have misunderstood what I am trying to accomplish.

I am looking for help from someone who has coded something similar and understands what I am asking.

Well - I have done what you are trying to do. I just don't want to give the code away.

I did base my stuff on something that was public but it was not anything published by Tradestation.
 
I don't think you have done what I am trying to do. I don't even think you understand what I am trying to do.

I am looking for help from someone knowledgeable. Please stop replying.
 
lol !

Method 1
Use an oscillator and take the highs/lows of each cycle to represent a swing high/low. Look for multiple swing highs/lows (within a %age tolerance) to define an area of support & resistance.

Method 2
Similar to the above but uses a swing high/low finder publicly available to catch the support & resistance levels. Again, multiple reversals in the same area becomes a support/resistance point.

There are pros & cons to both when you see them in action.
 
This is an example of method 1(the circled part) :

Hilbert_sine_wave_signals.gif


This is from a guy selling indicators at emini-watch.com. I am not affiliated with him in any way.


What you can see is the dots do catch swing highs & lows. Multiple occurences of those dots in the same area is support & resistance.
 
I have my support levels already!!

This is a technical EasyLanguage question. I am asking how to take all my (Already Calculated) support levels and determine which one is closest to the current market price.

Then I would put limit buy orders with only the closest two (as an example).
 
I have my support levels already!!

This is a technical EasyLanguage question. I am asking how to take all my (Already Calculated) support levels and determine which one is closest to the current market price.

Then I would put limit buy orders with only the closest two (as an example).

OK - you'd be best off building an array of support & resistance levels and then sorting the array as you add each new level.

Then you would take the current price, loop through the array in order to find the closest level.

Array sorting is a bit of a pain in the ass to be honest.

SortArray & Sort2DArray are the functions you need if you already have your S&R levels and need to sort them.
 
Last edited:
Thank you. This is the type of interaction I was looking for.

OK - to keep your code simple, create a few new functions....

StoreSuppportArray - to add a new support point to the support array (this would also call sortArray to sort your array after adding the new support point)
StoreResistanceArray - to add a new resistance point to the resistance array (this would also call sortArray to sort your array after adding the new support point)

GetSupport - to loop through the array to get closest support point
GetArray - to loop through the array to get the closest resistance point

You could use a 2d array to store both support & resistance in a single array BUT from what I recall, the std function to sort 2d arrays does not work the way it should & you'd have to write your own.
 
Lets just look at Support for now to keep it simple.

The only way I have figured out to find the closest support point is to first calculate the difference between the close and each support point.

Then once I have all of those differences I would find the one that is closest to 0 and not negative.

Then I would need to associate that closest difference back to the support variable and place the order at that support variable price.

********************************************

This seems like such a barbaric way to acheive what I am trying to do. Which is why I went to the message boards.
 
I presume you aren't trying to find if support is closer than resistance. Just trying to find the closest support price & the closest resistance point.

Let's say your support points are :

30
28
32
24
40

First - you sort them into order (low to high for support, high to low for resistance).

24
28
30
32
40

You would loop through the list and when you get to a value that is equal or higher to the current price, you would know that the previous value was the closest support.

Either way, it's not elegant but then you are dealing with memory resident data and TS sadly doesn't support a database that would let you implement something more elegant.
 
Simple answer to rounding to the nearest MinMove price

Just use the built-in function, Round2Fraction
 
flipflopper,
Let's say your support points are : 50, 40, 30, 20. Now the market price is 55 and you want to find the closest support price ?

Just use maxlist(sup1, sup2, sup3, sup4) and you will get answer 50 as per this example.
Happy Trading!
 
Top