Gamestudio Links
Zorro Links
Newest Posts
DirectX : 3d Hardware Reset Failure
by jumpman. 11/27/20 07:29
Sortino(vars Data, int TimePeriod): var
by danatrader. 11/26/20 20:45
Need code for Williams Sentiment Index
by danatrader. 11/26/20 20:42
Binance Futures Plugin
by Mio. 11/26/20 10:54
Optimizing global & local parameters
by dBc. 11/25/20 15:16
Enter FOK orders simultaneously
by jcl. 11/25/20 10:55
looking how basic functions are made
by jcl. 11/25/20 10:47
AUM Magazine
Latest Screens
Paradox Vector
The Space Between
Pogostuck: Rage With Your Friends
Worst Case Z
Who's Online Now
5 registered members (3run, danatrader, jumpman, NnamueN, MatPed), 472 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
MMK, raed, liquidbread, Dmitry_Shesterin, ddczp
18543 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Special Bars Script #481477
09/19/20 00:41
09/19/20 00:41
Joined: Mar 2019
Posts: 338
D
danatrader Online OP
Senior Member
danatrader  Online OP
Senior Member
D

Joined: Mar 2019
Posts: 338
How would I create here a multi - asset Renko strategy?

Whatever I fill in where it says "perform algorithm" seems to have no effect at all.


void run()
{
BarPeriod = 1; // determines here the time resolution of the bar
StartDate = 20180601;
EndDate = 20180901;
LookBack = 13;
set(PLOTNOW);
set(TICKS);
assetList("P:\\AssetsCur3.csv");
while(asset(loop("EUR/USD","GBP/USD")))
{
_bar = HA;
vars O = series(priceOpen(),-LookBack), // series must be static here
H = series(priceHigh(),-LookBack),
L = series(priceLow(),-LookBack),
C = series(priceClose(),-LookBack);
if(nextBar(O,H,L,C)) {

// ... perform the algorithm. Shift other series.
printf("#\nNew Bar");
}
plot("Renko",C,LINE,RED);
}
}
#endif

Re: Special Bars Script [Re: danatrader] #481488
09/21/20 06:37
09/21/20 06:37
Joined: Jul 2000
Posts: 27,401
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,401
Frankfurt
The script collection contains a script for multi-asset Renko.

Re: Special Bars Script [Re: danatrader] #481739
10/25/20 11:08
10/25/20 11:08
Joined: Mar 2017
Posts: 23
A
atr Offline
Newbie
atr  Offline
Newbie
A

Joined: Mar 2017
Posts: 23
You mentioned that the collection contains a script for multi-asset Renko. I found the script specialBars.c .The problem for me because I am a beginner programing in C-lite is that where it says in the script " // ... perform the algorithm. Use only static series. // Do not use indicators that internally create series." there is not an exemple of an algorithm that use only static series. Could anyone put a simple algorithm with static series in the multi-asset script specialBars.c as an exemple in order to know how an algo with static series work?

Thanks.

Re: Special Bars Script [Re: danatrader] #481741
10/25/20 12:30
10/25/20 12:30
Joined: Mar 2017
Posts: 23
A
atr Offline
Newbie
atr  Offline
Newbie
A

Joined: Mar 2017
Posts: 23
As an exemple I put a simple algo int the specialBars.c script. It doesn't work. So what I have to do in order to make work the algo with multi asset special bars?


// Special bars example //////////////////////////////

#define MULTI_ASSET

var BarRange = 0.0030; // 0.3 cents bar range

// Range Bars
int Range(vars Open,vars High,vars Low,vars Close)
{
if(Open[0] != Close[1]) {
High[0] = max(Open[0],Close[1]);
Low[0] = min(Open[0],Close[1]);
Open[0] = Close[1];
}
if(High[0]-Low[0] >= BarRange)
return 1;
return 4;
}

// Renko Bars, variant 1
int Renko1(vars Open,vars High,vars Low,vars Close)
{
Open[0] = roundto(Close[1],BarRange);
if(Close[0]-Open[0] >= BarRange) {
Close[0] = Open[0]+BarRange;
High[0] = Close[0];
Low[0] = Open[0];
return 1;
}
if(Open[0]-Close[0] >= BarRange) {
Close[0] = Open[0]-BarRange;
High[0] = Open[0];
Low[0] = Close[0];
return 1;
}
return 4;
}

// Renko Bars, variant 2
int Renko2(vars Open, vars High, vars Low, vars Close)
{
var OpenDiff = abs(Close[0]-Open[1]);
var CloseDiff = abs(Close[0]-Close[1]);
if(OpenDiff < CloseDiff) // we have a valley or peak
Open[0] = Open[1];
else // we are moving with the trend
Open[0] = roundto(Close[1],BarRange);
if(Close[0]-Open[0] >= BarRange) { // going up
Close[0] = Open[0]+BarRange;
High[0] = Close[0];
Low[0] = Open[0];
return 1;
}
if(Open[0]-Close[0] >= BarRange) { // going down
Close[0] = Open[0]-BarRange;
High[0] = Open[0];
Low[0] = Close[0];
return 1;
}
return 4;
}

// Mean Renko Bars
int Renko3(vars Open, vars High, vars Low, vars Close)
{
Open[0] = 0.5*(Close[1]+Open[1]);
if(Close[0] <= Open[0] - BarRange) {
Close[0] = Open[0] - BarRange;
return 1;
} else if(Close[0] >= Open[0] + BarRange) {
Close[0] = Open[0] + BarRange;
return 1;
}
return 4;
}

// Haiken Ashi Bars
int HA(vars Open,vars High,vars Low,vars Close)
{
Close[0] = (Open[0]+High[0]+Low[0]+Close[0])/4;
Open[0] = (Open[1]+Close[1])/2;
High[0] = max(High[0],max(Open[0],Close[0]));
Low[0] = min(Low[0],min(Open[0],Close[0]));
return 8;
}

// Point-and-Figure Bars
int PAF(vars Open,vars High,vars Low,vars Close)
{
static int direction = 0;
if(direction == 1 && High[0]-Close[0] >= BarRange) {
Open[0] = roundto(Low[0],BarRange);
Close[0] = roundto(High[0],BarRange);
Low[0] = Open[0];
High[0] = Close[0];
direction = 0;
return 1;
}
if(direction == 0 && Close[0]-Low[0] >= BarRange) {
Open[0] = roundto(High[0],BarRange);
Close[0] = roundto(Low[0],BarRange);
High[0] = Open[0];
Low[0] = Close[0];
direction = 1;
return 1;
}
return 4;
}

#ifndef MULTI_ASSET // single asset user bars ////////////////////

int bar() {} // dummy function to be set to the real bar function

void run()
{
bar = Renko1;
BarPeriod = 15; // determines only the number of allocated bars, not the bar period
StartDate = 20180601;
EndDate = 20180901;
LookBack = 0;
set(PLOTNOW);
// ... perform the algorithm.



#else // multi asset user bars ///////////////////////////////////

int _bar(vars Open,vars High,vars Low,vars Close); // prototype

int nextBar(vars Open,vars High,vars Low,vars Close)
{
var O[2],H[2],L[2],C[2]; // parameters for the bar function
O[0] = priceOpen(0); O[1] = Open[1];
H[0] = priceHigh(0); H[1] = High[1];
L[0] = priceLow(0); L[1] = Low[1];
C[0] = priceClose(0); C[1] = Close[1];
if(_bar(O,H,L,C) == 1) {
shift(Open,O[0],LookBack);
shift(High,H[0],LookBack);
shift(Low,L[0],LookBack);
shift(Close,C[0],LookBack);
return 1;
} else return 0;
}

void run()
{
BarPeriod = 1; // determines here the time resolution of the bar
StartDate = 20180601;
EndDate = 20180901;
LookBack = 0;
set(PLOTNOW+TICKS);

while(asset(loop("EUR/USD","GBP/USD")))
{
_bar = Renko1;
vars O = series(priceOpen(),-LookBack), // series must be static here
H = series(priceHigh(),-LookBack),
L = series(priceLow(),-LookBack),
C = series(priceClose(),-LookBack);
if(nextBar(O,H,L,C)) {
// ... perform the algorithm. Use only static series.
// Do not use indicators that internally create series.

vars Closes=series(priceClose());

if(Closes[0]>Closes[1] and NumOpenLong<1)
{
enterLong(1);
}

if(Closes[0]<Closes[1] and NumOpenShort<1)
{
enterShort(1);
}


printf("#\nNew Bar");
}
plot("Renko",C,LINE,RED);
}
}
#endif

Last edited by atr; 10/25/20 12:31.
Re: Special Bars Script [Re: danatrader] #481757
10/27/20 09:06
10/27/20 09:06
Joined: Mar 2017
Posts: 23
A
atr Offline
Newbie
atr  Offline
Newbie
A

Joined: Mar 2017
Posts: 23
Please. Does anybody have any ideas about how to perform an algorithm in the specialBars.c script for multiasset user bars?
Any help will be appreciated.
Thanks.

Re: Special Bars Script [Re: atr] #481852
11/09/20 09:20
11/09/20 09:20
Joined: Mar 2017
Posts: 23
A
atr Offline
Newbie
atr  Offline
Newbie
A

Joined: Mar 2017
Posts: 23
I tried to write an algo with static series in the multi asset special bars script specialBars.c. Is it correct the way I wrote the algo?

// Special bars example //////////////////////////////

#define MULTI_ASSET

var BarRange = 0.0030; // 0.3 cents bar range

// Range Bars
int Range(vars Open,vars High,vars Low,vars Close)
{
if(Open[0] != Close[1]) {
High[0] = max(Open[0],Close[1]);
Low[0] = min(Open[0],Close[1]);
Open[0] = Close[1];
}
if(High[0]-Low[0] >= BarRange)
return 1;
return 4;
}

// Renko Bars, variant 1
int Renko1(vars Open,vars High,vars Low,vars Close)
{
Open[0] = roundto(Close[1],BarRange);
if(Close[0]-Open[0] >= BarRange) {
Close[0] = Open[0]+BarRange;
High[0] = Close[0];
Low[0] = Open[0];
return 1;
}
if(Open[0]-Close[0] >= BarRange) {
Close[0] = Open[0]-BarRange;
High[0] = Open[0];
Low[0] = Close[0];
return 1;
}
return 4;
}

// Renko Bars, variant 2
int Renko2(vars Open, vars High, vars Low, vars Close)
{
var OpenDiff = abs(Close[0]-Open[1]);
var CloseDiff = abs(Close[0]-Close[1]);
if(OpenDiff < CloseDiff) // we have a valley or peak
Open[0] = Open[1];
else // we are moving with the trend
Open[0] = roundto(Close[1],BarRange);
if(Close[0]-Open[0] >= BarRange) { // going up
Close[0] = Open[0]+BarRange;
High[0] = Close[0];
Low[0] = Open[0];
return 1;
}
if(Open[0]-Close[0] >= BarRange) { // going down
Close[0] = Open[0]-BarRange;
High[0] = Open[0];
Low[0] = Close[0];
return 1;
}
return 4;
}

// Mean Renko Bars
int Renko3(vars Open, vars High, vars Low, vars Close)
{
Open[0] = 0.5*(Close[1]+Open[1]);
if(Close[0] <= Open[0] - BarRange) {
Close[0] = Open[0] - BarRange;
return 1;
} else if(Close[0] >= Open[0] + BarRange) {
Close[0] = Open[0] + BarRange;
return 1;
}
return 4;
}

// Haiken Ashi Bars
int HA(vars Open,vars High,vars Low,vars Close)
{
Close[0] = (Open[0]+High[0]+Low[0]+Close[0])/4;
Open[0] = (Open[1]+Close[1])/2;
High[0] = max(High[0],max(Open[0],Close[0]));
Low[0] = min(Low[0],min(Open[0],Close[0]));
return 8;
}

// Point-and-Figure Bars
int PAF(vars Open,vars High,vars Low,vars Close)
{
static int direction = 0;
if(direction == 1 && High[0]-Close[0] >= BarRange) {
Open[0] = roundto(Low[0],BarRange);
Close[0] = roundto(High[0],BarRange);
Low[0] = Open[0];
High[0] = Close[0];
direction = 0;
return 1;
}
if(direction == 0 && Close[0]-Low[0] >= BarRange) {
Open[0] = roundto(High[0],BarRange);
Close[0] = roundto(Low[0],BarRange);
High[0] = Open[0];
Low[0] = Close[0];
direction = 1;
return 1;
}
return 4;
}

#ifndef MULTI_ASSET // single asset user bars ////////////////////

int bar() {} // dummy function to be set to the real bar function

void run()
{
bar = Renko1;
BarPeriod = 15; // determines only the number of allocated bars, not the bar period
StartDate = 20180601;
EndDate = 20180901;
LookBack = 0;
set(PLOTNOW);
// ... perform the algorithm.



#else // multi asset user bars ///////////////////////////////////

int _bar(vars Open,vars High,vars Low,vars Close); // prototype

int nextBar(vars Open,vars High,vars Low,vars Close)
{
var O[2],H[2],L[2],C[2]; // parameters for the bar function
O[0] = priceOpen(0); O[1] = Open[1];
H[0] = priceHigh(0); H[1] = High[1];
L[0] = priceLow(0); L[1] = Low[1];
C[0] = priceClose(0); C[1] = Close[1];
if(_bar(O,H,L,C) == 1) {
shift(Open,O[0],LookBack);
shift(High,H[0],LookBack);
shift(Low,L[0],LookBack);
shift(Close,C[0],LookBack);
return 1;
} else return 0;
}

void run()
{
BarPeriod = 1; // determines here the time resolution of the bar
StartDate = 20180601;
EndDate = 20180901;
LookBack = 0;
set(PLOTNOW+TICKS);
TradesPerBar=5;
while(asset(loop("EUR/USD","GBP/USD")))
{
_bar = Renko1;
vars O = series(priceOpen(),-LookBack), // series must be static here
H = series(priceHigh(),-LookBack),
L = series(priceLow(),-LookBack),
C = series(priceClose(),-LookBack);
if(nextBar(O,H,L,C)) {
// ... perform the algorithm. Use only static series.
// Do not use indicators that internally create series.

vars Closes=series(priceClose());
vars ClosesCurrent=series(0,-20);

if(Closes[0]<Closes[1] and NumOpenLong<1)
shift(ClosesCurrent, Closes[0],20);
{
enterLong();
}

if(Closes[0]>Closes[1] and NumOpenShort<1)
shift(ClosesCurrent, Closes[0],20);
{
enterShort();
}


printf("#\nNew Bar");
}
plot("Renko",C,LINE,RED);
}
}
#endif

Re: Special Bars Script [Re: danatrader] #481853
11/09/20 10:36
11/09/20 10:36
Joined: Mar 2019
Posts: 338
D
danatrader Online OP
Senior Member
danatrader  Online OP
Senior Member
D

Joined: Mar 2019
Posts: 338
I think you need to manually shift both series:

vars Closes=series(priceClose()); <--- shifting missing? Needs to be static too I guess.
vars ClosesCurrent=series(0,-20);

if(Closes[0]<Closes[1] and NumOpenLong<1)
shift(ClosesCurrent, Closes[0],20);

Re: Special Bars Script [Re: danatrader] #481854
11/09/20 10:52
11/09/20 10:52
Joined: Mar 2017
Posts: 23
A
atr Offline
Newbie
atr  Offline
Newbie
A

Joined: Mar 2017
Posts: 23
Thank you very much for your answer! How can I do that? I am lost... I tried to do vars Closes into static series but I don't know how to do that... I am just a beginner.

Re: Special Bars Script [Re: danatrader] #481856
11/09/20 11:19
11/09/20 11:19
Joined: Mar 2019
Posts: 338
D
danatrader Online OP
Senior Member
danatrader  Online OP
Senior Member
D

Joined: Mar 2019
Posts: 338
Since you shift ClosesCurrent, why do you use a series for Closes?
Just use a var maybe, I am beginner too wink

Re: Special Bars Script [Re: danatrader] #481857
11/09/20 11:36
11/09/20 11:36
Joined: Mar 2017
Posts: 23
A
atr Offline
Newbie
atr  Offline
Newbie
A

Joined: Mar 2017
Posts: 23
Do you think this is correct answer?

var Closes[100];
vars ClosesCurrent=series(0,-20);

if(Closes[0]<Closes[1] and NumOpenLong<1)
shift(ClosesCurrent, Closes[0],20);
{
enterLong();
}

if(Closes[0]>Closes[1] and NumOpenShort<1)
shift(ClosesCurrent, Closes[0],20);
{
enterShort();
}

Page 1 of 2 1 2

Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1