2 registered members (TipmyPip, vicknick),
1,024
guests, and 7
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Yesterday at 13:21
Here is a working version of the Gaussian Indicator : function gauss_elimination(int n, var* a, var* b, var* x) {
int i, j, k, l;
var q, m, t;
for (k = 0; k < n - 1; k++) {
l = k;
m = fabs(a[k * n + k]);
for (i = k + 1; i < n; i++) {
if (fabs(a[i * n + k]) > m) {
m = fabs(a[i * n + k]);
l = i;
}
}
if (m == 0) return; // Singular matrix
if (l != k) {
for (j = 0; j < n; j++) {
t = a[k * n + j];
a[k * n + j] = a[l * n + j];
a[l * n + j] = t;
}
t = b[k];
b[k] = b[l];
b[l] = t;
}
for (i = k + 1; i < n; i++) {
q = a[i * n + k] / a[k * n + k];
for (j = k; j < n; j++) {
a[i * n + j] -= q * a[k * n + j];
}
b[i] -= q * b[k];
}
}
for (i = n - 1; i >= 0; i--) {
t = b[i];
for (j = i + 1; j < n; j++) {
t -= a[i * n + j] * x[j];
}
x[i] = t / a[i * n + i];
}
}
function calculateRegressionIndicator(vars ClosePrices, vars Filtered, vars UpperBand, vars LowerBand, int period, int RegressionDegree, var KNL_Dev) {
// Variables for regression calculation
var a[100], b[10], x[10], sx[20];
var sum, sq;
int i, j, k, n, nn;
n = period - 1;
nn = RegressionDegree + 1;
// Calculate sx
sx[0] = n + 1;
for (i = 1; i <= nn * 2 - 1; i++) {
sum = 0.0;
for (k = 0; k <= n; k++) sum += pow(k, i);
sx[i] = sum;
}
// Calculate syx
for (i = 0; i < nn; i++) {
sum = 0.0;
for (k = 0; k <= n; k++) {
if (i == 0) sum += ClosePrices[k];
else sum += ClosePrices[k] * pow(k, i);
}
b[i] = sum;
}
// Fill matrix a
for (k = 0; k < nn; k++)
for (j = 0; j < nn; j++)
a[j * nn + k] = sx[j + k];
// Perform Gauss elimination
gauss_elimination(nn, a, b, x);
// Calculate the sum of squares
sq = 0.0;
for (k = 0; k <= n; k++) {
sum = 0.0;
for (i = 1; i <= RegressionDegree; i++) {
sum += x[i] * pow(k, i);
}
var fx = x[0] + sum;
sq += pow(ClosePrices[k] - fx, 2);
}
sq = KNL_Dev * sqrt(sq / (n + 1));
// Calculate regression values and bands
for (i = 0; i <= n; i++) {
sum = 0.0;
for (j = 1; j <= RegressionDegree; j++) {
sum += x[j] * pow(i, j);
}
var fx = x[0] + sum;
Filtered[i] = fx;
UpperBand[i] = fx + sq;
LowerBand[i] = fx - sq;
}
}
function run() {
set(PLOTNOW);
// Input parameters
int period = 20; // Calculate only for the last 20 bars
int RegressionDegree = 5;
var KNL_Dev = 2.72;
vars ClosePrices = series(priceClose());
vars Filtered = series(0);
vars UpperBand = series(0);
vars LowerBand = series(0);
if (Bar < period) return;
// Call the indicator calculation function
calculateRegressionIndicator(ClosePrices, Filtered, UpperBand, LowerBand, period, RegressionDegree, KNL_Dev);
// Ensure valid values for plotting
if (is(LOOKBACK)) {
plot("Close Price", ClosePrices, NEW, BLUE); // Plot the closing prices
plot("Filtered", Filtered, 0, RED); // Plot the filtered value
plot("Upper Band", UpperBand, 0, GREEN); // Plot the upper band
plot("Lower Band", LowerBand, 0, ORANGE); // Plot the lower band
}
}
5
412
Read More
|
|
07/20/24 06:46
I must confess, my fascination with automation knows no bounds. While resolving coding problems can be a daunting task, the correct implementation of automation can significantly simplify much of this work.
Imagine the incredible efficiency we could achieve by quickly resolving problems and eliminating the need for error corrections in our code. This would not only save us time but also enrich our lives by allowing us to focus on more creative and fulfilling pursuits.
It's true that addressing errors in automated code generation can be a slow process. However, developing and debugging code manually without automation demands just as much effort and time.
My enthusiasm for automation is matched by my eagerness to share its benefits with others. Please forgive my insistence, but I wholeheartedly encourage you to embrace automation as I have. Together, we can transform our manual trading tasks into streamlined, automated solutions. :-) Hahahah!
I surely, will need to many errors, in my code, But if anyone, feels like sharing any solutions, or ideas, please do.
34
5,553
Read More
|
|
07/17/24 11:38
I would also double check your BarMode configuration, time zone configuration, market hours configuration, etc. The defaults could be incorrect for whatever you’re trading.
4
620
Read More
|
|
07/16/24 11:39
Here is a "clever" way to utilize Zorro's ability to use a different data source and trading source for a symbol to work around the limitation of not being able to trade CME futures using the outstanding SierraChart plugin that is available. This limitation stems from the SierraChart DTC server needing to block the quote data because of limitations imposed by the mean ol' CME. This limitation is documented in elsewhere the Zorro forum. The workaround is documented in the Symbols section of the Help docs and in the Broker Arbitrage section. - Source is an optional price source or broker name. It can be an online price source (such as STOOQ:), or a name from the first column of the account list. This way the same asset can get prices from broker A and can trade with broker B (Zorro S is required for multiple brokers). - An asset can have multiple symbols that are separated by exclamation marks '!'. It looks like Zorro S may be required unless I am confused about if there is a difference between a broker arb setup and just using a different quote and trading source. You are only trading with one broker in this setup and not multiple as with Broker Arbitrage. I did not test without Zorro S. I have tested this method and it seems to work well. The symbol names need to be set up for each system with the "!" seperator. I chose to open an account with IB as the data provider for the symbol and trade with the SierraChart symbol. SierraChart has an excellent service called the Trading Evaluator that can be used for testing this setup and great for performance tracking as well. You can setup multiple accounts on this service. I used the IB TWS to try and fill out the Assets.csv file with the correct symbol data but I'm not positive the Assets setup for each symbol is correct but it seems like it is. I would enter the symbol in the Watch List in IB TWS and Right-click to get the Symbol Information. Futures symbols are always a royal pain to get right. I then setup the IB Gateway once everything looked good as suggested in the Help docs. If you are already trading with SierraChart then you pay for CME data there and you will also need to pay for CME data with IB. You can have as many instances of SierraChart on the same computer as you want as far as I can tell. I have one for manual trading, one for the Trading Evaluator, and even am trying out the TopStep Prop service with another instance. Here are some example data for the Assets and Accounts files: (I was just dabbling with the grain symbols so they may be off - no guarantees with any of these symbols!!!) Please let me know if something doesn't look right. History\AssetsFix_futures-TWS-GW2.csv: In the Symbol column, the Sierra Account:Symbol is first and then "!" then IB Account:Symbol. eg. SierraIB-GW:MESU24!IB-Gateway2:MES-FUT-202409-MES-CME-USD
Name,Price,Spread,RollLong,RollShort,PIP,PIPCost,MarginCost,Market,Multiplier,Commission,Symbol,Centage,Desc,
10Y,4.427,0.015625,0,0,0.015625,1.5625,77,UTC:1300-2100,1,1.5,SierraIB-GW:10YM24!IB-Gateway2:10Y-FUT-10YM4-10Y-CBOT-USD,0,Micro 10Y,
MES,5310.5,0.25,0,0,0.25,1.25,77.88,UTC:1330-2000,1,1.5,SierraIB-GW:MESU24!IB-Gateway2:MES-FUT-202409-MES-CME-USD,0,Micro ES,
MNQ,18730.5,0.5,0,0,0.25,0.5,116.82,UTC:1330-2000,1,1.5,SierraIB-GW:MNQU24!IB-Gateway2:MNQ-FUT-202409-MNQ-CME-USD,0,Micro NQ,
MYM,38842,0.5,0,0,0.5,1,55.44,UTC:1330-2000,1,1.5,SierraIB-GW:MYMU24!IB-Gateway2:MYM-FUT-202409-MYM-CBOT-USD,0,Micro Dow,
M2K,2042.3,0.5,0,0,0.1,0.5,42.9,UTC:1330-2000,1,1.5,SierraIB-GW:M2KU24!IB-Gateway2:M2K-FUT-202409-M2K-CME-USD,0,Micro Russel,
XK,1180,1.25,0,0,0.125,1.25,75,UTC:1430-1915,1,1.5,SierraIB-GW:XKN24!IB-Gateway2:YK-FUT-202407-XK-CBOT-USD,64,Mini Beans,
XC,448,1.25,0,0,0.125,1.25,75,UTC:1430-1915,1,1.5,SierraIB-GW:XCN24!IB-Gateway2:YC-FUT-202407-XC-CBOT-USD,64,Mini Corn,
XW,628,1.25,0,0,0.125,1.25,75,UTC:1430-1915,1,1.5,SierraIB-GW:XWN24!IB-Gateway2:YW-FUT-202407-XW-CBOT-USD,64,Mini Wheat,
MCL,75.38,0.01,0,0,0.01,1,140.8,UTC:1400-1930,1,1.5,SierraIB-GW:MCLQ24!IB-Gateway2:MCL-FUT-MCLQ4-MCL-NYMEX-USD,64,Micro Crude,
MNG,2.927,0.001,0,0,0.001,1,130,UTC:1400-1930,1,1.5,SierraIB-GW:MNGQ24!IB-Gateway2:MHNG-FUT-202408-MNG-NYMEX-USD,64,Micro Nat Gas,
MGC,2.927,0.1,0,0,0.1,1,90,UTC:1310-1830,1,1.5,SierraIB-GW:MGCQ24!IB-Gateway2:MGC-FUT-202408-MGC-COMEX-USD,64,Micro Gold,
MHG,4.448,0.0005,0,0,0.0005,1.25,90,UTC:1320-1830,1,1.5,SierraIB-GW:MHGU24!IB-Gateway2:MHG-FUT-202409-MHG-COMEX-USD,64,Micro Copper,
M6E,1.0807,0.0001,0,0,0.0001,1.25,90,UTC:1320-2000,1,1.5,SierraIB-GW:M6EU24!IB-Gateway2:M6E-FUT-202409-M6E-CME-USD,64,Micro EUR,
M6B,1.2718,0.0001,0,0,0.0001,0.625,90,UTC:1320-2000,1,1.5,SierraIB-GW:M6BU24!IB-Gateway2:M6B-FUT-202409-M6B-CME-USD,64,Micro BP,
Accounts.csv (SierraScalp and IB-Gateway2 are the entries referenced by the above Assets.csv example. I included more example accounts to show how that can works but you may need a unique Assets.csv file or symbol entry for each unique account that you have setup on SierraChart.):
Name,Server,AccountId,User,Pass,Assets,CCY,Real,NFA,Plugin
SierraIB-GW,Sierra,0,ta:zorro h:127.0.0.1 p1:11099 p2:11097,password,AssetsFix_futures-TWS-GW,USD,0,1,SierraChart.dll
SierraScalp,Sierra,0,ta:microscalp h:127.0.0.1 p1:11099 p2:11097,password,AssetsFix_futures-TWS-GW2,USD,0,1,SierraChart2.dll
IB-Gateway,IB,ACCOUNT1,1,0,AssetsFix_futures-TWS-GW,USD,1,14,IB.dll
IB-Gateway2,IB,ACCOUNT2,2,0,AssetsFix_futures-TWS-GW2,USD,1,14,IB2.dll
Please let me know what you think or if you see anything wrong with this setup! FYI: SierraChart has the Teton CME order routing that seems to be a good deal and very fast and solid for futures trading.
0
389
Read More
|
|
07/14/24 16:39
Yes, the variance in results in huge. I tried all the methods - Dual, Homodyne, Talib, Autocorrelation, Zero Crossings, Phase Accumulation
The results vary significantly with each other and with Zorro. the DominantPeriod can be very different based on what method is chosen. I can confirm that PhaseAccumulation is closest to what Zorro shows but only with about a 70% correlation
251
48,800
Read More
|
|
07/13/24 07:15
Thanks Grant, is solved now. Its Kerberos and have nothing to do with Zorro etc
2
420
Read More
|
|
07/12/24 13:56
Zorro 2.62.0 is now available on https://zorro-project.com/download.php under "New versions". This release candidate will become the official release when no bugs are found in the next time. Please test everything and report any issues here! As usual, if you're the first one to find a new and serious bug in the release candidate, you can get a free Zorro S subscription or support extension.
0
205
Read More
|
|
07/10/24 15:06
Looking for new games to score!
92
35,744
Read More
|
|
07/10/24 10:34
I added a description about how to modify an existing program to use the SGT_FW. You can find it in the repo mentioned in the opening post.
1
318
Read More
|
|
07/09/24 23:07
I would recommend something like this (when it comes to movement and gravity):
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// good working/well tested gravity script with basic player movement controller - free to use
// supports walking up (for example on steps)
// rayp 2024 ...credits are always nice
//
// needs: player.mdl (best is to use a simple "box" model for collision), test.wmb map file
// usage: run this script
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// --- some var's and def's we want to use
// --------------------------------------------------------------------------------------------------------------------
//SOUND* snd_land = "hitfloor.wav";
var player_movement_speed = 5; // speed of player's movement
var mouse_speed = 1; // speed for camera rotation
var std_cam_height = 17; // eye height of the camera
#define myheight skill99 // used by apply_gravity function = distance to ground from c_trace
#define distZ skill98 // used by apply_gravity function = Z movement for c_move in the ent-move-controller
//#define falling skill97
//#define footstep skill96
//#define step_sndconcrete 100
#define group_player 1 // for c_ignore groups
// --------------------------------------------------------------------------------------------------------------------
// --- the simple (and well) gravity part (with example for floor-texture-footstep-detection)
// --------------------------------------------------------------------------------------------------------------------
void apply_gravity (ENTITY* ent){
if (!ent) return;
VECTOR temp_pos;
vec_set (temp_pos, vector(0, 0, -1000)); // 1000 should be enough for most levels
vec_rotate (temp_pos, ent.pan);
vec_add (temp_pos, ent.x);
c_ignore (group_player, 0);
trace_mode = IGNORE_ME | IGNORE_PASSABLE | USE_BOX | IGNORE_SPRITES;// | SCAN_TEXTURE;
ent.myheight = c_trace (vector(ent.x,ent.y,ent.z), temp_pos, trace_mode);
//DEBUG_VAR (ent.myheight, 300);
// -----------------------------------------------------------------------------------------------------------------
// --- footstep example depending on floor texture, needs SCAN_TEXTURE in trace_mode above
/*
if (HIT_TARGET){
if (hit.texname){
//draw_text (hit.texname, 10,200,vector(255,0,0));
if(str_cmpi(hit.texname,"#default") || str_cmpi(hit.texname,"concrete")){
ent.footstep = step_sndconcrete;
}
}
}
*/
// --- footstep surface detection end, rest of gravity part below
// -----------------------------------------------------------------------------------------------------------------
if (ent.myheight > 2 || ent.myheight == 0){
accelerate(ent.distZ, -3 * time_step, -1);
//if (ent.myheight > 15) ent.falling = 1; // in the air!
}
else{
ent.distZ = 0;
/*if (ent.falling){ // in the air ? play land sound
ent.falling = 0;
snd_play (snd_land, 50, 0);
}*/
}
}
// ---------------------------------------------------------------------------------------------------------------------
// --- a simple and basic player controller with gravity (first person cam)
// ---------------------------------------------------------------------------------------------------------------------
action Test_Player(){
VECTOR player_dist; // movement vector used for XY, for Z we use my.distZ calculated in apply_gravity
// ------------------------------------------------------------------------------------------------------------------
// --- collision box
// ------------------------------------------------------------------------------------------------------------------
wait (1);
my.eflags &= ~FAT;
my.eflags &= ~NARROW;
vec_set (my.min_x, vector(-12,-12,-17));
vec_set (my.max_x, vector(12,12,25));
// ------------------------------------------------------------------------------------------------------------------
my.group = group_player;
while (me){ // dont use while(1), this would crash on, for example, level switch when the entity is lost
// ---------------------------------------------------------------------------------------------------------------
// --- use WASD to move
// ---------------------------------------------------------------------------------------------------------------
//if (key_shift) player_movement_speed = 10;
//else player_movement_speed = 5;
player_dist.x = (key_w-key_s)*time_step*player_movement_speed;
player_dist.y = (key_a-key_d)*time_step*player_movement_speed;
// ---------------------------------------------------------------------------------------------------------------
// --- handle camera rotation and movement
// ---------------------------------------------------------------------------------------------------------------
camera.pan -= mickey.x*time_step*mouse_speed;
camera.tilt -= mickey.y*time_step*mouse_speed;
camera.tilt = clamp (camera.tilt, -80, 80);
camera.x = my.x; // or vec_set (camera.x, my.x) instead of setting X and Y
camera.y = my.y;
camera.z = my.z + std_cam_height;
// ---------------------------------------------------------------------------------------------------------------
// --- prepare our XY movement vector now
// ---------------------------------------------------------------------------------------------------------------
vec_rotate (player_dist, vector (camera.pan,0,0));
// ---------------------------------------------------------------------------------------------------------------
// --- calculate the gravity / Z movement for ME (into my.distZ)
// ---------------------------------------------------------------------------------------------------------------
apply_gravity (me);
// ---------------------------------------------------------------------------------------------------------------
// --- finally move the player (best performance because only one c_move call is used for XYZ)
// ---------------------------------------------------------------------------------------------------------------
c_ignore (group_player, 0);
c_move (me, nullvector, vector (player_dist.x, player_dist.y, my.distZ), GLIDE|IGNORE_ME|IGNORE_PASSABLE);
// ---------------------------------------------------------------------------------------------------------------
wait (1);
}
}
// ---------------------------------------------------------------------------------------------------------------------
// --- the main function
// ---------------------------------------------------------------------------------------------------------------------
void main(){
level_load ("test.wmb");
ent_create ("player.mdl", vector (0,0,50), Test_Player);
}
// ---------------------------------------------------------------------------------------------------------------------
// --- end
// ---------------------------------------------------------------------------------------------------------------------
1
196
Read More
|
|
07/07/24 09:47
Zorro is not a charting program. It is an algorithmic trading program with limited support for charts. Also, run() is called when the bar is complete, never when it’s incomplete.
If you must have real time indicators, use a charting program. That’s what they’re designed for. Some of us are in the business of writing those indicators too.
1
163
Read More
|
|
07/02/24 10:32
run() is a just a regular function, that gets' called at each bar (by a Zorro's engine).
So, all variables declared in run are 'local', i.e. they get destroyed/ reinitialized at each new run ().
To retain their values, you need to declare them static or global (i.e. outside run() )..or save them in a series object.
2
337
Read More
|
|
|