Gamestudio Links
Zorro Links
Newest Posts
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
Release 2.68 replacement of the .par format
by Martin_HH. 09/23/25 20:48
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
1 registered members (TipmyPip), 17,150 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Concretum Intraday Momentum Strategy Performance #488332
08/13/24 02:42
08/13/24 02:42
Joined: Oct 2022
Posts: 16
N/A
J
juanex Offline OP
Newbie
juanex  Offline OP
Newbie
J

Joined: Oct 2022
Posts: 16
N/A
Hello everyone,

I stumbled upon Concretum and their promised market beating strategy with a Sharpe Ratio of 1.33 and tried to recreate it on Zorro right away, however my results were vastly different.

I mostly used chat GPT to recreate it as well as some zorro functions that I know are needed but I am still not sure that it is coded properly to match the functions, including the VWAP which seems to be an aggregate of the whole daily price and volume. any code feedback would be highly appreciated, here's the link for their strategy if anyone is interested in seeing how it works Concretum Strategy

Code
 /// Concretum Intraday SPY strategy ///
/// Based on https://papers.ssrn.com/sol3/papers.cfm?abstract_id=4824172 ///

var UpperBoundary;
var LowerBoundary;

function calculateNoiseArea() {
   int Lookback = 14;
   int i; 
   int BarsPerDay = 13; 
   var volatilityMultiplier = 1.; 
   var OpenPrice = priceOpen(0);
   var SumMove = 0;

   for(i = 1; i <= Lookback; i++) {
      var PreviousOpen = priceOpen(i * BarsPerDay); 
      var PreviousClose = priceClose(i * BarsPerDay - (BarsPerDay - 1)); 
      var Move = abs(PreviousClose / PreviousOpen - 1);
      SumMove += Move;
   }

   var AvgMove = SumMove / Lookback;

   UpperBoundary = OpenPrice * (1 + volatilityMultiplier * AvgMove);
   LowerBoundary = OpenPrice * (1 - volatilityMultiplier * AvgMove);

   var PreviousClose = priceClose(1); 
   if(OpenPrice > PreviousClose) {
      UpperBoundary += (OpenPrice - PreviousClose);
   } else {
      LowerBoundary -= (PreviousClose - OpenPrice);
   }
}

void run() {
   Verbose = 3;
   NumCores = -2; 
   set(PLOTNOW|LOGFILE|TESTNOW);
   setf(PlotMode, PL_DIFF);
   StartDate = 2011;
   EndDate = 2023;
   LookBack = 14 * 13 + 1;
   BarPeriod = 1;  
   // BarZone = EST;
   StartMarket = 0930;  // Start of market hours
   EndMarket = 1600;    // End of market hours
   Capital = Margin = 10000;
	BarMode = BR_NOSHIFT+BR_SLEEP; // Only calculate and trade during market hours 
   asset("SPY");
   MaxLong = MaxShort = -1;
   
   vars Prices = series(priceClose());
   vars Volumes = series(marketVol());
   var VWAP = VWAV(Prices, Volumes, 14); 

   calculateNoiseArea();

   if(crossOver(Prices, UpperBoundary))  
      enterLong();
   
   if(crossUnder(Prices, LowerBoundary)) 
      enterShort();
   
   if(TradeIsLong && (Prices[0] < UpperBoundary || crossUnder(Prices, VWAP)))
      exitLong();

   if(TradeIsShort && (Prices[0] > LowerBoundary || crossOver(Prices, VWAP)))
      exitShort();

   if(tod() == 1530){ 
      exitShort();
      exitLong();
   }

   // Plot the indicators
   plot("VWAP", VWAP, LINE, PURPLE);
   plot("Upper Boundary", UpperBoundary, LINE, BLUE);
   plot("Lower Boundary", LowerBoundary, LINE, YELLOW);
   plot("MarketVol", marketVol(), BARS|NEW, BLUE);
}

Attached Files
Last edited by juanex; 08/19/24 01:30.
Re: Concretum Intraday Momentum Strategy Performance [Re: juanex] #488334
08/13/24 08:47
08/13/24 08:47
Joined: Jan 2024
Posts: 9
Würzburg
J
juergen_wue Offline
Newbie
juergen_wue  Offline
Newbie
J

Joined: Jan 2024
Posts: 9
Würzburg
Very good realized - looks promising! Thanks!

Re: Concretum Intraday Momentum Strategy Performance [Re: juergen_wue] #488335
08/13/24 13:57
08/13/24 13:57
Joined: Oct 2022
Posts: 16
N/A
J
juanex Offline OP
Newbie
juanex  Offline OP
Newbie
J

Joined: Oct 2022
Posts: 16
N/A
The performance I posted is of the author of the strategy through their own backtest with only 2 years of data from polygon.

I would encourage you to run my code with Zorro's M1 data, and you will see vastly different results, besides the obvious fact that you would be testing different periods (Zorro 2011-2023 vs 2022-2024) I am not sure if my code is running with the same logic proposed by the author, specifically the VWAP calculation which Zorro uses, in the paper it looks like their VWAP is calculated with the daily open to close while Zorro's uses a fixed period (I.e. the last 5 bars)

I would really appreciate if someone could look over my code and point out any flaws regarding the logic.

Re: Concretum Intraday Momentum Strategy Performance [Re: juanex] #488339
08/16/24 06:21
08/16/24 06:21
Joined: May 2023
Posts: 27
Hamburg, Germany
M
Martin_HH Offline
Newbie
Martin_HH  Offline
Newbie
M

Joined: May 2023
Posts: 27
Hamburg, Germany
One topic I realized regarding the market. I understood you want to run the SPY during the US market hours. I guess you should include the:

BarZone = EST;

statement.

Re: Concretum Intraday Momentum Strategy Performance [Re: Martin_HH] #488343
08/19/24 01:20
08/19/24 01:20
Joined: Oct 2022
Posts: 16
N/A
J
juanex Offline OP
Newbie
juanex  Offline OP
Newbie
J

Joined: Oct 2022
Posts: 16
N/A
Yes, I included that, as well as BarMode = BR_NOSHIFT+BR_SLEEP; I will update the main post with the new code however it is still far from producing the performance promised by the paper I think the VWAP calculation is still off, probably something to do with the calculations being made between regular and after market hours.

Also, the last trade being made is at 3:30 PM instead of closing at the market's close since if I set the close at the market's close it won't register.


Attached Files
Last edited by juanex; 08/19/24 01:34.

Moderated by  Petra 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1